#[non_exhaustive]pub struct ChatRequest {
pub messages: Vec<Message>,
pub system_prompt: Option<SystemPrompt>,
pub tools: Option<Vec<ToolDefinition>>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub top_k: Option<u32>,
pub stop_sequences: Vec<String>,
pub max_tokens: u32,
pub tool_choice: Option<ToolChoice>,
pub disable_parallel_tool_use: Option<bool>,
pub additional_params: Option<Value>,
}Expand description
Per-turn request the engine assembles and the adapter lowers to the provider’s wire format.
The struct is #[non_exhaustive], so external construction goes
through Default / ChatRequest::new rather than struct
literals. Adapters that don’t natively support a control (e.g.
top_k on Chat Completions) ignore it; provider-specific knobs
outside the typed surface ride Self::additional_params.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.messages: Vec<Message>Conversation history sent to the provider, in order. Adapters
translate each Message block to the provider’s content
shape.
system_prompt: Option<SystemPrompt>System instructions sent out-of-band from messages. None
lets the provider use its default behaviour.
tools: Option<Vec<ToolDefinition>>Tools the model may call this turn. None disables tool use
entirely and lets adapters omit the tools field on the wire,
which some providers require when no tools are configured.
temperature: Option<f32>Sampling temperature in the provider’s native range
(typically [0.0, 1.0] or [0.0, 2.0]). None keeps the
provider default.
top_p: Option<f32>Nucleus sampling cutoff. None keeps the provider default.
top_k: Option<u32>Top-k sampling cutoff. Only honoured by providers that expose
the parameter (Anthropic). None keeps the provider default;
adapters without top_k ignore the field.
stop_sequences: Vec<String>Strings that, if produced, terminate the response with
crate::FinishReason::StopSequence.
max_tokens: u32Maximum output tokens the provider should generate this turn.
tool_choice: Option<ToolChoice>How the model should pick among the available tools. None
leaves the provider default (typically Auto). Mapped to each
provider’s wire format by the adapter.
disable_parallel_tool_use: Option<bool>Forbid the model from emitting more than one tool_use block
per turn. None leaves the provider default (parallel allowed).
Adapters lower this to the field their API expects:
tool_choice.disable_parallel_tool_use for Anthropic,
parallel_tool_calls (negated) for Chat Completions.
additional_params: Option<Value>Free-form JSON merged into the provider’s request body.
Escape hatch for provider-specific knobs not yet typed in the
shared shape (Anthropic thinking, OpenAI reasoning_effort,
future betas). Adapters merge this last so it can override
any field the typed surface set.
Implementations§
Trait Implementations§
Source§impl Clone for ChatRequest
impl Clone for ChatRequest
Source§fn clone(&self) -> ChatRequest
fn clone(&self) -> ChatRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more