Handles loading and merging of packaged snapshots with runtime customization.
Phase 2 of LLMDB: Load the packaged snapshot, apply custom overlays, compile filters, and build indexes for runtime queries.
This module encapsulates all snapshot loading logic, keeping the main LLMDB module focused on the query API.
Summary
Functions
Computes a digest for a snapshot configuration.
Loads the packaged snapshot and applies runtime configuration.
Builds an empty snapshot with no providers or models.
Functions
Computes a digest for a snapshot configuration.
Used to detect if a reload would result in the same snapshot, enabling idempotent load operations.
Parameters
providers- List of provider mapsbase_models- List of all models before filteringruntime- Runtime configuration map
Returns
Integer digest (phash2 hash)
Loads the packaged snapshot and applies runtime configuration.
This is the main entry point for Phase 2 (runtime) loading. It:
- Loads the packaged snapshot
- Normalizes providers/models from v1 or v2 format
- Merges custom providers/models overlay
- Compiles and applies filters
- Builds indexes for O(1) queries
- Returns snapshot ready for Store
Parameters
opts- Keyword list passed to Runtime.compile/1
Returns
{:ok, snapshot}- Successfully loaded and prepared snapshot{:error, :no_snapshot}- No packaged snapshot available{:error, term}- Other errors
Examples
{:ok, snapshot} = Loader.load()
{:ok, snapshot} = Loader.load(
allow: [:openai],
custom: %{
local: [
models: %{"llama-3" => %{capabilities: %{chat: true}}}
]
}
)
Builds an empty snapshot with no providers or models.
Used as a fallback when no packaged snapshot is available.
Examples
{:ok, snapshot} = Loader.load_empty()