parse_provider_block

Function parse_provider_block 

Source
pub fn parse_provider_block(
    header_name: Option<&str>,
    content: &str,
) -> Result<ProviderDef, ConfigError>
Expand description

Parse a provider fence block from YAML content into a ProviderDef.

Parses content as YAML into a ProviderConfig, applies name precedence between the optional header_name and the payload name (header wins; conflict is an error), resolves the provider_type, and converts api_key into an environment-aware EnvValue.

§Errors

Returns ConfigError::YamlParse if the YAML is invalid, ConfigError::NameConflict if both header and payload names are provided, ConfigError::MissingName if no name is present, or other ConfigError variants produced while parsing provider_type or api_key.

§Examples

use cellstate_pipeline::parse_provider_block;

let yaml = r#"
provider_type: openai
api_key: env:OPENAI_KEY
model: gpt-4
options: []
"#;

let def = parse_provider_block(Some("my-provider"), yaml).unwrap();
assert_eq!(def.name, "my-provider");