pub struct ChatRequest {
pub model: String,
pub messages: Vec<Message>,
pub tools: Vec<ToolSpec>,
pub tool_choice: Option<ToolChoice>,
pub temperature: Option<f64>,
pub top_p: Option<f64>,
pub max_tokens: Option<u32>,
pub stop: Vec<String>,
pub response_format: Option<ResponseFormat>,
pub extra: Map<String, Value>,
}Expand description
A provider-neutral chat request.
Fields§
§model: String§messages: Vec<Message>§tools: Vec<ToolSpec>§tool_choice: Option<ToolChoice>§temperature: Option<f64>§top_p: Option<f64>§max_tokens: Option<u32>§stop: Vec<String>§response_format: Option<ResponseFormat>§extra: Map<String, Value>Provider-specific parameters merged into the request body as-is.
Implementations§
Source§impl ChatRequest
impl ChatRequest
pub fn new(model: impl Into<String>, messages: Vec<Message>) -> Self
Sourcepub fn with_tools(self, tools: Vec<ToolSpec>) -> Self
pub fn with_tools(self, tools: Vec<ToolSpec>) -> Self
Set the tools offered to the model.
Sourcepub fn with_tool_choice(self, choice: ToolChoice) -> Self
pub fn with_tool_choice(self, choice: ToolChoice) -> Self
Set how the model may use tools.
pub fn with_temperature(self, temperature: f64) -> Self
pub fn with_top_p(self, top_p: f64) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_stop(self, stop: Vec<String>) -> Self
pub fn with_response_format(self, format: ResponseFormat) -> Self
Sourcepub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
Add a provider-specific body parameter.
Trait Implementations§
Source§impl Clone for ChatRequest
impl Clone for ChatRequest
Source§impl Debug for ChatRequest
impl Debug for ChatRequest
Source§impl Default for ChatRequest
impl Default for ChatRequest
Source§impl<'de> Deserialize<'de> for ChatRequest
impl<'de> Deserialize<'de> for ChatRequest
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
Source§impl PartialEq for ChatRequest
impl PartialEq for ChatRequest
Source§impl Serialize for ChatRequest
impl Serialize for ChatRequest
impl StructuralPartialEq for ChatRequest
Auto Trait Implementations§
impl Forget for ChatRequest
impl Freeze for ChatRequest
impl Move 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