Agentic.LLM
(agentic v0.2.2)
Copy Markdown
Top-level entry point for chat and embedding calls.
Wraps Agentic.LLM.Provider with two conveniences:
chat/2andchat_tier/3for chat completionsembed/2andembed_tier/3for vector embeddings
Both flavours route through the configured provider stack and
return canonical %Response{} / {:ok, vectors, model_id} shapes.
Embed return shape
embed/2 and embed_tier/3 always return a list of vectors,
even when called with a single string input. The third tuple
element is the model id used to produce the vectors so callers
(e.g. recollect's reembed pipeline) can store provenance.
{:ok, [vector, ...], "text-embedding-3-small"} | {:error, %Error{}}
Summary
Functions
Chat completion via a provider module + canonical params.
Chat completion via tier resolution with full failover.
Generate embeddings for one or more strings via an explicit provider.
Generate embeddings via tier-based model resolution.
Types
@type embed_result() :: {:ok, [[float()]], String.t()} | {:error, Agentic.LLM.Error.t()}
Functions
Chat completion via a provider module + canonical params.
Chat completion via tier resolution with full failover.
Resolves every healthy route in tier from the ModelRouter and walks
them in priority order with error classification and health reporting.
Accepts an optional llm_chat callback (same shape as the loop callback)
for callers that want to customise dispatch (e.g. host app credential
injection). Falls back to direct provider dispatch when no callback is
provided. Returns {:ok, %Response{}} or {:error, %Error{}}.
Options
:llm_chat—(map() -> {:ok, response} | {:error, term()})callback. When provided, each route is injected asparams["_route"]and the callback is invoked. Otherwise directProvider.chat/3is used.
@spec embed( String.t() | [String.t()], keyword() ) :: embed_result()
Generate embeddings for one or more strings via an explicit provider.
Required opts:
:provider— provider id atom (e.g.:openai):model— model id string (e.g."text-embedding-3-small")
@spec embed_tier(String.t() | [String.t()], atom(), keyword()) :: embed_result()
Generate embeddings via tier-based model resolution.
Tier resolution order:
- Explicit
opts[:model]+opts[:provider](skips Catalog) Catalog.find(has: :embeddings, tier: tier)→ first match- Fallback to first model with the
:embeddingscapability