LlmCall.Config (llm_call v0.1.0)

Copy Markdown View Source

Codec defaults and capture policy.

Holds no credentials and no base URL: those belong to the transport. default_provider_options is merged before a request's provider_options (completion or media), and the request wins per key.

json and capture_raw have compile-time defaults:

config :llm_call,
  json_library: Torque,
  capture_raw: :all

Both are read with Application.compile_env/3, so changing them recompiles the library; a %LlmCall.Config{} built with new/1 overrides them per client without touching the compiled default.

Summary

Functions

Deep-merges native provider options over a canonical body.

Builds a config from the compile-time defaults.

Merged provider options for a request, keyed by provider namespace.

Types

t()

@type t() :: %LlmCall.Config{
  capture_raw: LlmCall.capture_raw(),
  default_provider_options: map(),
  json: module()
}

Functions

deep_merge(canonical, native)

@spec deep_merge(map(), map()) :: map()

Deep-merges native provider options over a canonical body.

Nested maps merge recursively, so a native generationConfig keeps the canonical temperature. Lists and scalars from the native side replace the canonical value.

new(opts \\ [])

@spec new(keyword()) :: t()

Builds a config from the compile-time defaults.

json_library: and capture_raw: override the compiled defaults per config. The JSON default is Elixir's built-in JSON; any module exposing either tagged encode/1/decode/1 (Torque, Jason, Poison) or bang encode!/1/decode!/1 (Elixir JSON) can be configured, and LlmCall.JSON normalizes both to tagged tuples. The capture default is :none.

provider_options(map, config)

@spec provider_options(LlmCall.Request.t() | LlmCall.Media.Request.t(), t()) :: map()

Merged provider options for a request, keyed by provider namespace.

Namespaces present in both the config and the request are merged recursively, with the request value winning per key, so a nested native object keeps the config keys the request does not repeat.