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.

Structs§

Completion
One step of model output.
ModelPricing
Per-million-token pricing for one model. USD.
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§

load_pricing_from_yaml
Load pricing from a YAML file. The file should have a “models” key mapping model names to pricing structs. Returns a HashMap of model name -> ModelPricing.
pricing_for
Returns pricing for known models, or None if unknown.

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.