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 ChatProvider trait is the only thing the agent depends on; everything beyond it (HTTP, retries, mocking) lives in adapters.

§Sub-modules

  • chat — data types: Completion, ToolSpec, ToolCall, TokenUsage, …
  • pricing — ModelPricing, RetryPolicy, and catalog lookup helpers
  • openai / anthropic / mock — concrete provider implementations

Re-exports§

pub use chat::estimate_tokens;
pub use chat::Completion;
pub use chat::ContextBreakdown;
pub use chat::StreamChunk;
pub use chat::StreamSender;
pub use chat::StructuredRequest;
pub use chat::TokenUsage;
pub use chat::ToolCall;
pub use chat::ToolSpec;
pub use pricing::context_window_tokens_for_model;
pub use pricing::context_window_tokens_for_model_effective;
pub use pricing::default_compact_threshold_chars;
pub use pricing::default_compact_threshold_tokens;
pub use pricing::pricing_for;
pub use pricing::ModelPricing;
pub use pricing::RetryPolicy;
pub use anthropic::AnthropicProvider;
pub use openai::OpenAiProvider;

Modules§

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

Constants§

DEFAULT_MAX_TOKENS
Default per-response output token cap used when neither the RECURSIVE_MAX_TOKENS env var, the active provider preset’s ModelSpec.max_tokens, nor the config-file agent.max_tokens is set.

Traits§

ChatProvider
Core trait for LLM chat-completion providers.