Expand description
One provider-neutral API layer for the assistant (design:
docs/src/research/agent-interface.md).
This module knows nothing about TeamCraft (no Actor, no mcp): it
holds the neutral conversation types, the pure Provider trait (encode a
request, decode a reply, map an error – no I/O, so recorded provider
bodies test it directly) and the Transport trait with its one HTTP
implementation in http. The wire formats live in one file each
(anthropic).
The tool loop in crate::assistant only sees these types.
Modules§
- anthropic
- The Anthropic Messages API: request encoding (prompt caching, the server-side fallback beta), reply decoding and the error table.
- http
- The one HTTP client of the LLM layer: timeouts, no redirects (a 3xx is an error, so the API key never goes to a second host), the key only in its request header.
- openai
- Chat Completions (
POST {base}/chat/completions), the format OpenAI, Azure OpenAI (v1), Mistral, OpenRouter, Groq, Ollama, vLLM and LM Studio speak. Stateless like the Messages API, so the loop stays the same.
Structs§
- Http
Call - A request ready to send: the path below the base URL, headers (without the API key) and the JSON body.
- Http
Response - An HTTP answer.
- Reply
- A decoded model reply.
- Request
- One model call.
- Tool
Call - One tool call of the model.
- Tool
Result - The result of one tool call, handed back to the model.
- Tool
Spec - A tool the model may call.
schemais the JSON Schema of the input. - Usage
- Token counts of one call.
inputmeans all prompt tokens (cached ones included).
Enums§
- Auth
Style - How the API key is sent.
- LlmError
- Why a model call failed.
- Stop
- Why the model stopped.
- Turn
- One entry of the conversation.
Traits§
- Provider
- One wire format. Pure: no network, no clock, no database.
- Transport
- Sends one HTTP call and returns the response as it is (any status).
Functions§
- complete
- One model call, one attempt: encode, send, map errors, decode.
- cut
- Cuts
sto at mostmaxbytes at a character boundary. - error_
message - The
error.messageof a JSON error body, cut short. - retry_
after retry-afterin seconds (the HTTP-date form is not used by the APIs).- status_
error - The one error table of all providers (design page): 401/403 are an
authentication error, 402 and a billing-quota 429 a quota error (no
retry), other 429s are rate limits with their
retry-after, 5xx (also 529) an overloaded service, a context-length rejection its own error, everything else a rejected request.