Expand description
Provider: the interface for communicating with an LLM.
This module defines the Provider trait and its companion data types:
requests (ChatRequest), responses (ChatResponse / StreamEvent),
errors (ProviderError), and usage (Usage). The trait itself is
vendor-agnostic; the implementations (OpenAiProvider / FakeProvider
/ RetryProvider) all implement the same trait, and any implementation
can be wrapped by RetryProvider to gain retry capability.
Structs§
- Chat
Request - A single conversation request.
- Chat
Response - The reply to one conversation.
- Fake
Provider - A programmable fake
Provider— a script is a sequence of per-turn replies, consumed in order bychat/stream_chat. - Model
Options - Model options for one conversation.
- Open
AiProvider - Provider implementation for OpenAI-compatible APIs.
- Retry
Policy - Retry policy (with defaults;
Defaultis “exponential backoff + jitter, 3 attempts”). - Retry
Provider - Retry wrapper: implements
Providerand retries inner failures perRetryPolicy. - Usage
- Token usage for one conversation.
Enums§
- Backoff
- Backoff strategy: how long to wait after each failure before the next attempt.
- Fake
Reply - One turn of reply from the script.
- Finish
Reason - Why the model ended its reply.
- Provider
Error - Why a Provider call failed.
- Retryable
- Retry judgment: which errors are worth retrying.
- Stream
Event - An event in a streamed conversation reply.
- Structured
Output Mode - Transport shape for structured output (an OpenAiProvider construction
setting): decides how
response_formatis sent. - Timeout
Stage - The stage at which a timeout occurred: one-to-one with
OpenAiProvider’s four timeouts (connect / non-streaming total / streaming event interval / streaming total), plus the error-response-body read timeout and a generic transport timeout.
Traits§
- Provider
- The interface for chatting with an LLM.