pub struct ChatOptions {
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub top_p: Option<f32>,
pub stop: Option<Vec<String>>,
pub system: Option<String>,
pub model: Option<String>,
pub cache_strategy: CacheStrategy,
pub request_id: Option<String>,
pub cancel: Option<CancellationToken>,
}Expand description
Chat completion options
Fields§
§temperature: Option<f32>Temperature (0.0 - 1.0)
max_tokens: Option<u32>Maximum tokens to generate
top_p: Option<f32>Top-p sampling
stop: Option<Vec<String>>Stop sequences
system: Option<String>System prompt
model: Option<String>Per-request model override.
When Some, providers MUST use this model name instead of their default.
This enables per-session model switching without replacing the provider.
cache_strategy: CacheStrategyPrompt-cache strategy. Ignored by providers without prompt caching.
request_id: Option<String>Caller-supplied identifier used to attribute the resulting cost,
tokens, and duration in telemetry. ChatAgent generates a fresh
id per turn; multi-tenant deployments can stamp their own
(e.g. "<tenant>-<msg_id>") so the analytics query
cost_by_request(id) can pull every event for one request.
cancel: Option<CancellationToken>Cooperative cancellation handle for stream_chat. When the token
cancels, the provider stops emitting chunks at the next
poll-point and drops the underlying HTTP connection. Has no
effect on the non-streaming chat call (use tokio::select!
against the future instead).
Not serialised — only meaningful inside one process.
Implementations§
Source§impl ChatOptions
impl ChatOptions
Sourcepub fn new() -> ChatOptions
pub fn new() -> ChatOptions
Create new chat options with defaults
Sourcepub fn temperature(self, temperature: f32) -> ChatOptions
pub fn temperature(self, temperature: f32) -> ChatOptions
Set temperature
Sourcepub fn max_tokens(self, max_tokens: u32) -> ChatOptions
pub fn max_tokens(self, max_tokens: u32) -> ChatOptions
Set max tokens
Sourcepub fn system<S>(self, system: S) -> ChatOptions
pub fn system<S>(self, system: S) -> ChatOptions
Set system prompt
Sourcepub fn top_p(self, top_p: f32) -> ChatOptions
pub fn top_p(self, top_p: f32) -> ChatOptions
Set top-p sampling
Sourcepub fn model<S>(self, model: S) -> ChatOptions
pub fn model<S>(self, model: S) -> ChatOptions
Override the model for this request.
Sourcepub fn cache_strategy(self, strategy: CacheStrategy) -> ChatOptions
pub fn cache_strategy(self, strategy: CacheStrategy) -> ChatOptions
Set the prompt-cache strategy.
Sourcepub fn request_id<S>(self, request_id: S) -> ChatOptions
pub fn request_id<S>(self, request_id: S) -> ChatOptions
Stamp a caller-supplied request_id so telemetry can attribute
the resulting tokens / cost to this specific call.
Sourcepub fn cancel_with(self, token: CancellationToken) -> ChatOptions
pub fn cancel_with(self, token: CancellationToken) -> ChatOptions
Attach a cancellation token to stream_chat. Cancelling stops
chunk delivery at the next poll-point and drops the upstream HTTP
connection.
Sourcepub fn deterministic(max_tokens: u32) -> ChatOptions
pub fn deterministic(max_tokens: u32) -> ChatOptions
Deterministic classification/routing (temp=0, few tokens)
Sourcepub fn factual(max_tokens: u32) -> ChatOptions
pub fn factual(max_tokens: u32) -> ChatOptions
Low-temperature factual generation
Sourcepub fn creative(max_tokens: u32) -> ChatOptions
pub fn creative(max_tokens: u32) -> ChatOptions
Creative generation with moderate temperature
Trait Implementations§
Source§impl Clone for ChatOptions
impl Clone for ChatOptions
Source§fn clone(&self) -> ChatOptions
fn clone(&self) -> ChatOptions
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 ChatOptions
impl Debug for ChatOptions
Source§impl Default for ChatOptions
impl Default for ChatOptions
Source§fn default() -> ChatOptions
fn default() -> ChatOptions
Source§impl<'de> Deserialize<'de> for ChatOptions
impl<'de> Deserialize<'de> for ChatOptions
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChatOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChatOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ChatOptions
impl Serialize for ChatOptions
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for ChatOptions
impl RefUnwindSafe for ChatOptions
impl Send for ChatOptions
impl Sync for ChatOptions
impl Unpin for ChatOptions
impl UnsafeUnpin for ChatOptions
impl UnwindSafe for ChatOptions
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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