pub struct CreateChatCompletionRequest {
pub model: String,
pub messages: Vec<Message>,
pub max_tokens: Option<usize>,
pub max_completion_tokens: Option<usize>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub stop: Option<Vec<String>>,
pub tools: Option<Vec<Tool>>,
pub stream: Option<bool>,
pub n: Option<usize>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
}Expand description
Request to create a chat completion.
Fields§
§model: StringModel to use.
messages: Vec<Message>Messages in the conversation.
max_tokens: Option<usize>Maximum tokens to generate.
max_completion_tokens: Option<usize>Maximum completion tokens (for o1/o3 models).
temperature: Option<f32>Temperature for sampling.
top_p: Option<f32>Top-p sampling.
stop: Option<Vec<String>>Stop sequences.
tools: Option<Vec<Tool>>Available tools.
stream: Option<bool>Whether to stream the response.
n: Option<usize>Number of completions to generate.
presence_penalty: Option<f32>Presence penalty.
frequency_penalty: Option<f32>Frequency penalty.
Implementations§
Source§impl CreateChatCompletionRequest
impl CreateChatCompletionRequest
Sourcepub fn new(model: impl Into<String>, messages: Vec<Message>) -> Self
pub fn new(model: impl Into<String>, messages: Vec<Message>) -> Self
Create a new chat completion request.
Sourcepub fn with_max_tokens(self, max_tokens: usize) -> Self
pub fn with_max_tokens(self, max_tokens: usize) -> Self
Set max tokens.
Sourcepub fn with_max_completion_tokens(self, max_tokens: usize) -> Self
pub fn with_max_completion_tokens(self, max_tokens: usize) -> Self
Set max completion tokens (for o1/o3 models).
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set temperature.
Sourcepub fn with_top_p(self, top_p: f32) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
Set top-p sampling.
Sourcepub fn with_tools(self, tools: Vec<Tool>) -> Self
pub fn with_tools(self, tools: Vec<Tool>) -> Self
Set available tools.
Trait Implementations§
Source§impl Clone for CreateChatCompletionRequest
impl Clone for CreateChatCompletionRequest
Source§fn clone(&self) -> CreateChatCompletionRequest
fn clone(&self) -> CreateChatCompletionRequest
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 moreSource§impl Debug for CreateChatCompletionRequest
impl Debug for CreateChatCompletionRequest
Auto Trait Implementations§
impl Freeze for CreateChatCompletionRequest
impl RefUnwindSafe for CreateChatCompletionRequest
impl Send for CreateChatCompletionRequest
impl Sync for CreateChatCompletionRequest
impl Unpin for CreateChatCompletionRequest
impl UnwindSafe for CreateChatCompletionRequest
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