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>) -> Request
pub fn new(model: impl Into<CompactString>) -> Request
Create a new request for the given model.
Sourcepub fn with_messages(self, messages: Vec<Message>) -> Request
pub fn with_messages(self, messages: Vec<Message>) -> Request
Set the messages for this request.
Sourcepub fn with_tools(self, tools: Vec<Tool>) -> Request
pub fn with_tools(self, tools: Vec<Tool>) -> Request
Set the tools for this request.
Sourcepub fn with_tool_choice(self, tool_choice: ToolChoice) -> Request
pub fn with_tool_choice(self, tool_choice: ToolChoice) -> Request
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<Request, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Request, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Request
impl Serialize for Request
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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