Skip to main content

Table of Contents

Module spoon_ai.llm.config

Configuration management for LLM providers using environment variables.

ProviderConfig Objects​

@dataclass
class ProviderConfig()

Configuration for a specific LLM provider.

__post_init__​

def __post_init__()

Validate configuration after initialization.

model_dump​

def model_dump() -> Dict[str, Any]

Convert the configuration to a dictionary.

Returns:

Dict[str, Any]: Configuration as dictionary

ConfigurationManager Objects​

class ConfigurationManager()

Manages environment-driven configuration for LLM providers.

__init__​

def __init__() -> None

Initialize configuration manager and load environment variables.

load_provider_config​

def load_provider_config(provider_name: str) -> ProviderConfig

Load and validate provider configuration.

Arguments:

  • provider_name - Name of the provider

Returns:

  • ProviderConfig - Validated provider configuration

Raises:

  • ConfigurationError - If configuration is invalid or missing

validate_config​

def validate_config(config: ProviderConfig) -> bool

Validate provider configuration.

Arguments:

  • config - Provider configuration to validate

Returns:

  • bool - True if configuration is valid

Raises:

  • ConfigurationError - If configuration is invalid

get_default_provider​

def get_default_provider() -> str

Get default provider from configuration with intelligent selection.

Returns:

  • str - Default provider name

get_fallback_chain​

def get_fallback_chain() -> List[str]

Get fallback chain from configuration.

Returns:

  • List[str] - List of provider names in fallback order

list_configured_providers​

def list_configured_providers() -> List[str]

List all configured providers.

Returns:

  • List[str] - List of provider names that have configuration

get_available_providers_by_priority​

def get_available_providers_by_priority() -> List[str]

Get available providers ordered by priority and quality.

Returns:

  • List[str] - List of available provider names in priority order

get_provider_info​

def get_provider_info() -> Dict[str, Dict[str, Any]]

Get information about all providers and their availability.

Returns:

Dict[str, Dict[str, Any]]: Provider information including availability

reload_config​

def reload_config() -> None

Reload configuration from file.