Expand description
LLM provider abstraction.
Provider is the trait every backend implements. Today there’s one
production impl (anthropic::AnthropicProvider) and one test impl
([MockProvider]). OpenAI and Ollama follow-ups will plug in here
without touching the rest of the crate (per Phase 7 plan Q4 —
Anthropic-first, others later).
The trait is deliberately narrow: one method, sync, one prompt
shape in, one parsed response out. Schema-aware prompt construction
lives one layer up in crate::prompt, so providers stay generic
over what’s being asked.
Modules§
- anthropic
- Anthropic Messages API adapter.
Structs§
- Request
- One LLM call’s worth of input. Mirrors the Anthropic Messages
request shape because it’s the most expressive of the three
providers we’ll support; OpenAI and Ollama adapters convert to
their native shapes inside their own
completeimpls. - Response
- What every provider returns. We keep this minimal —
textis the raw string the model produced (the caller parses it),usagesurfaces token counts so callers can verify cache hits. - Usage
- Token-usage breakdown. Names match Anthropic’s API field names so
the mapping stays obvious; OpenAI’s
prompt_tokens/completion_tokenswill fan intoinput_tokens/output_tokenswhen that adapter lands.
Traits§
- Provider
- A single one-shot call. Sync because every supported provider has
a sync HTTPS entry point and
ask()itself is sync (matches the engine’s surface —Connection::executeetc. are all sync).