ExAthena.Config (ExAthena v0.3.1)

Copy Markdown View Source

Resolves the provider and per-call options for an ExAthena request.

Resolution order (per key):

  1. opts[:key] — per-call override always wins.
  2. Application.get_env(:ex_athena, provider)[:key] — provider-specific config.
  3. Application.get_env(:ex_athena, :key) — top-level library config.
  4. Provider default (if the provider declares one).

Matches the stripity_stripe / ex_aws pattern: per-call overrides win, application config is the default, no global mutable state.

Known providers

AtomModule
:ollamaExAthena.Providers.Ollama
:openai_compatibleExAthena.Providers.OpenAICompatible
:openaiExAthena.Providers.OpenAICompatible
:llamacppExAthena.Providers.OpenAICompatible
:claudeExAthena.Providers.Claude
:mockExAthena.Providers.Mock

You may also pass any module that implements ExAthena.Provider directly.

Summary

Functions

Look up a single configuration value for provider_module with the tiered resolution order. opts wins, then provider-specific config, then top-level config, then the supplied default.

Pop :provider from opts and return {provider_module, remaining_opts}.

Resolve a provider atom (or module) to its implementing module.

Build the keyword list passed to a provider's query/2 / stream/3 callback.

Translate an ExAthena provider atom into the req_llm provider tag used in "tag:model-id" specs. Returns nil when the atom doesn't map to req_llm (e.g. :mock, or a user-supplied module).

Functions

get(provider_module, key, opts, default \\ nil)

@spec get(module(), atom(), keyword(), term()) :: term()

Look up a single configuration value for provider_module with the tiered resolution order. opts wins, then provider-specific config, then top-level config, then the supplied default.

The provider atom is derived from the module name: Providers.Ollama:ollama.

pop_provider!(opts)

@spec pop_provider!(keyword()) :: {module(), keyword()}

Pop :provider from opts and return {provider_module, remaining_opts}.

Raises ArgumentError if no provider is set in opts or in application env.

provider_module(mod)

@spec provider_module(atom() | module()) :: module()

Resolve a provider atom (or module) to its implementing module.

provider_opts(provider_module, opts)

@spec provider_opts(
  module(),
  keyword()
) :: keyword()

Build the keyword list passed to a provider's query/2 / stream/3 callback.

Flattens per-call overrides + application env for this provider into one keyword list. Providers use Keyword.get/3 on the result.

req_llm_provider_tag(atom)

@spec req_llm_provider_tag(atom() | module()) :: String.t() | nil

Translate an ExAthena provider atom into the req_llm provider tag used in "tag:model-id" specs. Returns nil when the atom doesn't map to req_llm (e.g. :mock, or a user-supplied module).