pub struct Request {
pub model: CompactString,
pub messages: Vec<Message>,
pub think: bool,
pub tools: Option<Vec<Tool>>,
pub tool_choice: Option<ToolChoice>,
pub usage: bool,
}Expand description
A chat completion request.
Contains everything needed to make an LLM call: model, messages, tools,
and streaming hints. Provider implementations convert this to their
wire format via From<Request>.
Fields§
§model: CompactStringThe model to use.
messages: Vec<Message>The conversation messages.
think: boolWhether to enable thinking.
tools: Option<Vec<Tool>>The tools available for this request.
tool_choice: Option<ToolChoice>Controls which tool is called by the model.
usage: boolWhether to return usage information in stream mode.
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(model: impl Into<CompactString>) -> Self
pub fn new(model: impl Into<CompactString>) -> Self
Create a new request for the given model.
Sourcepub fn with_messages(self, messages: Vec<Message>) -> Self
pub fn with_messages(self, messages: Vec<Message>) -> Self
Set the messages for this request.
Sourcepub fn with_tools(self, tools: Vec<Tool>) -> Self
pub fn with_tools(self, tools: Vec<Tool>) -> Self
Set the tools for this request.
Sourcepub fn with_tool_choice(self, tool_choice: ToolChoice) -> Self
pub fn with_tool_choice(self, tool_choice: ToolChoice) -> Self
Set the tool choice for this request.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
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 Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
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