pub struct ChatCompletionRequest {
pub model: String,
pub messages: Vec<Message>,
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub stream: Option<bool>,
pub top_p: Option<f32>,
pub frequency_penalty: Option<f32>,
pub presence_penalty: Option<f32>,
pub functions: Option<Vec<Tool>>,
pub function_call: Option<FunctionCallPolicy>,
}
Fields§
§model: String
§messages: Vec<Message>
§temperature: Option<f32>
§max_tokens: Option<u32>
§stream: Option<bool>
§top_p: Option<f32>
§frequency_penalty: Option<f32>
§presence_penalty: Option<f32>
§functions: Option<Vec<Tool>>
Optional function/tool definitions for Function Calling
function_call: Option<FunctionCallPolicy>
Function call policy: “auto”/“none”/specific name
Implementations§
Source§impl ChatCompletionRequest
impl ChatCompletionRequest
pub fn new(model: String, messages: Vec<Message>) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_functions(self, functions: Vec<Tool>) -> Self
pub fn with_function_call(self, function_call: FunctionCallPolicy) -> Self
pub fn with_provider_specific(self, _key: &str, _value: Value) -> Self
Sourcepub fn ignore_previous(self) -> Self
pub fn ignore_previous(self) -> Self
Drop previous conversational messages while keeping system messages and the last non-system message. Useful to reset context while preserving system instructions.
Trait Implementations§
Source§impl Clone for ChatCompletionRequest
impl Clone for ChatCompletionRequest
Source§fn clone(&self) -> ChatCompletionRequest
fn clone(&self) -> ChatCompletionRequest
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 ChatCompletionRequest
impl Debug for ChatCompletionRequest
Source§impl<'de> Deserialize<'de> for ChatCompletionRequest
impl<'de> Deserialize<'de> for ChatCompletionRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ChatCompletionRequest
impl RefUnwindSafe for ChatCompletionRequest
impl Send for ChatCompletionRequest
impl Sync for ChatCompletionRequest
impl Unpin for ChatCompletionRequest
impl UnwindSafe for ChatCompletionRequest
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