Expand description
Chat completion data types.
These types are the wire contract between the [ChatProvider] trait and
its callers. All provider implementations produce and consume these
shapes; nothing in tools/ or agent/ depends on provider internals.
Structs§
- Completion
- One step of model output.
- Context
Breakdown - Locally-estimated per-component token breakdown of the prompt sent to the provider.
- Structured
Request - Request for a structured JSON response conforming to a JSON schema.
- Token
Usage - Token usage data from an LLM response.
- Tool
Call - A structured request to invoke one of the registered tools.
- Tool
Spec - JSON-schema description of a tool, sent verbatim to the model.
Enums§
- Stream
Chunk - A single streamed delta emitted by a provider during a streaming LLM call.
Functions§
- estimate_
tokens - Rough token estimate for budget/breakdown display. Uses a bytes/4 heuristic (≈4 bytes/token for English; over-counts CJK ~3× because CJK chars are 3 UTF-8 bytes each). This is intentionally byte-based for speed (no char iteration) and is only an estimate — exact tokenization would require the provider’s tokenizer. Do not use for billing.
Type Aliases§
- Stream
Sender - Channel sender for streaming partial deltas during a streaming LLM call.
Each
StreamChunkis a delta emitted by the provider.