pub struct ChatRequest {
pub model: String,
pub messages: Vec<Message>,
pub system: Option<String>,
pub max_tokens: Option<u32>,
pub temperature: Option<f64>,
pub top_p: Option<f64>,
pub tools: Vec<ToolSpec>,
pub stream: bool,
pub trace_id: Option<String>,
pub cancel: CancellationFlag,
}Expand description
One canonical chat request — provider-neutral. Per-provider adapters translate to the wire JSON the provider expects.
Fields§
§model: StringEmpty string → backend uses its default_model().
messages: Vec<Message>§system: Option<String>System prompt — Anthropic puts it in a top-level field; OpenAI & compats prepend a system message to the messages array.
max_tokens: Option<u32>§temperature: Option<f64>Temperature; ignored when the resolved model is locked-params.
top_p: Option<f64>§tools: Vec<ToolSpec>§stream: boolfalse → call complete(). true → call stream() and consume
the chunk stream incrementally.
trace_id: Option<String>Trace ID propagated from the calling flow step. Surfaces in tracing spans so log lines correlate.
cancel: CancellationFlag§Fase 33.x.e — Cancellation flag observed INSIDE the reqwest
body. Each per-provider Backend::stream() impl wraps its
returned chunk stream with sse_streaming::cancel_aware
so the next-chunk poll races a cancel.cancelled() future
against the upstream HTTP body — when the flag fires the
stream returns None within ≤100ms p95 + the dropped
reqwest Response aborts the upstream HTTP request body.
Default is an uncancelled flag; adopters that don’t supply
one get pre-33.x.e semantics (the stream runs to completion).
Cloning is cheap (Arc-backed inside).
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 moreSource§impl Debug for ChatRequest
impl Debug for ChatRequest
Source§impl Default for ChatRequest
impl Default for ChatRequest
Source§fn default() -> ChatRequest
fn default() -> ChatRequest
Auto Trait Implementations§
impl Freeze for ChatRequest
impl RefUnwindSafe for ChatRequest
impl Send for ChatRequest
impl Sync for ChatRequest
impl Unpin for ChatRequest
impl UnsafeUnpin for ChatRequest
impl UnwindSafe for ChatRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more