pub enum ChatMessage {
Developer {
content: Content,
name: Option<String>,
},
System {
content: Content,
name: Option<String>,
},
User {
content: UserContent,
name: Option<String>,
},
Assistant {
content: Option<AssistantContent>,
refusal: Option<String>,
name: Option<String>,
audio: Option<AssistantAudio>,
tool_calls: Option<Vec<AssistantToolCall>>,
function_call: Option<AssistantFunctionCall>,
},
Tool {
content: Content,
tool_call_id: String,
},
}
Variants§
Developer
Fields
System
Fields
User
Fields
§
content: UserContent
The contents of the user message.
Assistant
Fields
§
content: Option<AssistantContent>
The contents of the assistant message. Required unless tool_calls
or function_call
is specified.
§
name: Option<String>
An optional name for the participant. Provides the model information to differentiate between participants of the same role.
§
audio: Option<AssistantAudio>
Data about a previous audio response from the model. Learn more.
§
tool_calls: Option<Vec<AssistantToolCall>>
The tool calls generated by the model, such as function calls.
§
function_call: Option<AssistantFunctionCall>
👎Deprecated
Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.
Tool
Implementations§
Source§impl ChatMessage
impl ChatMessage
pub fn system(content: impl Into<Content>) -> Self
pub fn developer(content: impl Into<Content>) -> Self
pub fn user(content: impl Into<String>) -> Self
pub fn user_image(image_url: impl Into<ImageUrl>) -> Self
pub fn user_image_with_text( text: impl Into<String>, image_url: impl Into<ImageUrl>, ) -> Self
pub fn user_parts(parts: Vec<UserContentPart>) -> Self
pub fn assistant(content: impl Into<AssistantContent>) -> Self
pub fn tool( content: impl Into<Content>, tool_call_id: impl Into<String>, ) -> Self
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ChatMessage
impl Debug for ChatMessage
Source§impl<'de> Deserialize<'de> for ChatMessage
impl<'de> Deserialize<'de> for ChatMessage
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 ChatMessage
impl PartialEq for ChatMessage
Source§impl Serialize for ChatMessage
impl Serialize for ChatMessage
impl StructuralPartialEq for ChatMessage
Auto Trait Implementations§
impl Freeze for ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin for ChatMessage
impl UnwindSafe for ChatMessage
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