# `LLMDB.Config`
[🔗](https://github.com/agentjido/llm_db/blob/main/lib/llm_db/config.ex#L1)

Configuration reading and normalization for LLMDB.

Reads from Application environment and provides normalized config maps
and compiled filter patterns.

# `compile_filters`

```elixir
@spec compile_filters(
  allow :: :all | map(),
  deny :: map(),
  known_providers :: [atom()] | nil
) ::
  {%{allow: :all | :none | map(), deny: map()}, [{:unknown, [term()]}]}
```

Compiles allow/deny filter patterns to regexes for performance.

## Parameters

- `allow` - `:all` or `%{provider_atom => [pattern_strings]}`
- `deny` - `%{provider_atom => [pattern_strings]}`
- `known_providers` - Optional list of known provider atoms for validation (defaults to all existing atoms)

Patterns support glob syntax with `*` wildcards via `LLMDB.Merge.compile_pattern/1`.

Provider keys that don't correspond to existing atoms are silently ignored.

Deny patterns always win over allow patterns.

## Returns

`{%{allow: compiled_patterns, deny: compiled_patterns}, unknown_providers}`

Where allow patterns are `:all`, `:none`, or
`%{provider => :all | [%Regex{}]}`,
and `unknown_providers` is a list of provider keys that were ignored.

# `get`

```elixir
@spec get() :: map()
```

Returns normalized configuration map from Application environment.

Reads `:llm_db` application config and normalizes with defaults.

## Configuration Format

    config :llm_db,
      allow: :all,  # or [:openai, :anthropic] or %{openai: ["gpt-4*"]}
      deny: %{},    # or [:provider] or %{provider: ["pattern"]}
      prefer: [:openai, :anthropic],
      custom: %{
        vllm: [
          name: "Local vLLM Provider",
          base_url: "http://localhost:8000/v1",
          models: %{
            "llama-3" => %{capabilities: %{chat: true}},
            "mistral-7b" => %{capabilities: %{chat: true, tools: %{enabled: true}}}
          }
        ],
        custom_provider: [
          name: "My Custom Provider",
          models: %{
            "model-1" => %{capabilities: %{chat: true}}
          }
        ]
      }

Provider keys can be atoms or strings. Patterns support glob syntax with `*` wildcards.

Custom providers are defined with provider ID as key, and a keyword list containing:
- `:name` - Provider name (optional)
- `:base_url` - Base URL for API (optional)
- `:models` - Map of model ID to model config

## Returns

A map with keys:
- `:compile_embed` - Whether to compile-time embed snapshot (default: false)
- `:snapshot_source` - Snapshot source descriptor (default: `:packaged`)
- `:allow` - Allow patterns (`:all` or `%{provider => [patterns]}`)
- `:deny` - Deny patterns (`%{provider => [patterns]}`)
- `:prefer` - List of preferred provider atoms
- `:custom` - Custom providers map (provider_id => provider_config)

# `sources!`

```elixir
@spec sources!() :: [{module(), map()}]
```

Returns the list of sources to load, in precedence order.

These are build-time inputs to `LLMDB.Engine`. The engine processes only the
configured sources, in precedence order; it does not automatically merge the
packaged runtime snapshot into the source list.

## Configuration

    config :llm_db,
      sources: [
        {LLMDB.Sources.ModelsDev, %{}},
        {LLMDB.Sources.Local, %{dir: "priv/llm_db"}}
      ]

## Default Behavior

If not configured, returns an empty list `[]`, meaning no build-time sources
are configured. Runtime `LLMDB.load/1` independently defaults to the packaged,
version-pinned snapshot.

## Returns

List of `{module, opts}` tuples in precedence order (first = lowest precedence).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
