ExLLM.ConfigProvider behaviour (ex_llm v0.1.0)

View Source

Behaviour for configuration providers.

This allows modules to receive configuration through dependency injection rather than directly accessing application configuration, making them more portable and testable.

Example

# Using static configuration
config = %{
  openai: %{api_key: "sk-..."},
  anthropic: %{api_key: "api-..."}
}
{:ok, provider} = ExLLM.ConfigProvider.Static.start_link(config)
ExLLM.OpenAI.chat(messages, config_provider: provider)

# Using environment-based configuration
ExLLM.OpenAI.chat(messages, config_provider: ExLLM.ConfigProvider.Env)

Summary

Callbacks

Gets configuration value for a provider and key.

Gets all configuration for a provider.

Callbacks

get(provider, key)

@callback get(provider :: atom(), key :: atom()) :: any()

Gets configuration value for a provider and key.

get_all(provider)

@callback get_all(provider :: atom()) :: map()

Gets all configuration for a provider.