Skip to main content

Module llm

Module llm 

Source
Expand description

LLM provider abstraction.

A provider takes a transcript plus tool specs and returns either free-form content, structured tool calls, or both. The trait is the only thing the agent depends on; everything beyond it (HTTP, retries, mocking) lives in adapters.

Re-exports§

pub use anthropic::AnthropicProvider;
pub use openai::OpenAiProvider;

Modules§

anthropic
Anthropic Messages API adapter.
mock
Deterministic LLM for tests and offline development.
openai
OpenAI-compatible chat-completions adapter.
search
Tool search engine: keyword-based discovery of deferred tools.

Structs§

Completion
One step of model output.
ModelPricing
Per-million-token pricing for one model. USD.
RetryPolicy
Retry policy for transient LLM provider failures (network timeouts, 5xx).
StructuredRequest
Request for a structured JSON response conforming to a JSON schema.
TokenUsage
Token usage data from an LLM response.
ToolCall
A structured request to invoke one of the registered tools.
ToolSpec
JSON-schema description of a tool, sent verbatim to the model.

Traits§

LlmProvider

Functions§

context_window_tokens_for_model
Returns the context window size in tokens for the given model.
default_compact_threshold_chars
Compute the default compaction character-count threshold for a model.
pricing_for
Returns pricing for a model by looking it up in the bundled providers.toml. Returns None if the model is not listed or has no pricing field.

Type Aliases§

StreamSender
Channel sender for streaming partial tokens during a streaming LLM call. Each String is a delta chunk (partial token) emitted by the provider.