pub struct ChatRequest {Show 13 fields
pub model: String,
pub messages: Vec<Message>,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub tools: Option<Vec<Tool>>,
pub tool_choice: Option<ToolChoice>,
pub parallel_tool_calls: Option<bool>,
pub stop_sequences: Option<Vec<String>>,
pub top_k: Option<u32>,
pub user: Option<String>,
pub budget_tokens: Option<u32>,
pub prompt_cache: Option<bool>,
}Expand description
A chat completion request.
Fields§
§model: String§messages: Vec<Message>§max_tokens: Option<u32>§temperature: Option<f32>§top_p: Option<f32>§tools: Option<Vec<Tool>>§tool_choice: Option<ToolChoice>Strategy for tool selection.
parallel_tool_calls: Option<bool>Whether to allow parallel tool calls.
OpenAI: parallel_tool_calls; Anthropic: tool_choice.disable_parallel_tool_use.
stop_sequences: Option<Vec<String>>Custom stop sequences.
OpenAI: stop; Anthropic: stop_sequences.
top_k: Option<u32>Top-k sampling parameter (Anthropic only; ignored for OpenAI).
user: Option<String>End-user identifier for abuse detection.
OpenAI: user; Anthropic: metadata.user_id.
budget_tokens: Option<u32>Budget tokens for extended thinking (Anthropic).
prompt_cache: Option<bool>Enable prompt caching.
OpenAI: sets store: true; Anthropic: sets top-level cache_control.
Implementations§
Source§impl ChatRequest
impl ChatRequest
pub fn new(model: impl Into<String>, messages: Vec<Message>) -> Self
pub fn max_tokens(self, n: u32) -> Self
pub fn temperature(self, t: f32) -> Self
pub fn top_p(self, p: f32) -> Self
pub fn tools(self, tools: Vec<Tool>) -> Self
pub fn tool_choice(self, choice: ToolChoice) -> Self
pub fn parallel_tool_calls(self, enabled: bool) -> Self
pub fn stop_sequences(self, sequences: Vec<String>) -> Self
pub fn top_k(self, k: u32) -> Self
pub fn user(self, user: impl Into<String>) -> Self
pub fn budget_tokens(self, n: u32) -> Self
pub fn prompt_cache(self, enabled: bool) -> Self
Trait Implementations§
Source§impl Clone for ChatRequest
impl Clone for ChatRequest
Source§fn clone(&self) -> ChatRequest
fn clone(&self) -> ChatRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto 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
Mutably borrows from an owned value. Read more