pub enum Message {
User {
content: String,
},
Assistant {
content: String,
tool_calls: Vec<AssistantToolCall>,
},
Tool {
tool_call_id: String,
content: String,
is_error: bool,
},
}Expand description
One message in the conversation, as it goes to and from the model.
The wire shape is the provider’s business, not ours. This is the vocabulary, and it keeps tool results as a first-class message rather than as text glued into an assistant turn, because the model has to be able to tell them apart.
Variants§
User
Assistant
Tool
Fields
§
is_error: boolWhether the tool failed.
Not serialised: the provider’s tool message has no such field, and sending one is at best ignored and at worst rejected. The session file records it separately, so resuming a session knows a result was an error even though the model was never told in so many words.
Implementations§
Source§impl Message
impl Message
pub fn user(content: impl Into<String>) -> Self
pub fn assistant(content: impl Into<String>) -> Self
pub fn assistant_with_calls( content: impl Into<String>, tool_calls: Vec<AssistantToolCall>, ) -> Self
pub fn tool(call_id: impl Into<String>, content: impl Into<String>) -> Self
pub fn tool_result( call_id: impl Into<String>, content: impl Into<String>, is_error: bool, ) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Forget for Message
impl Freeze for Message
impl Move for Message
impl RefUnwindSafe for Message
impl Send for Messagewhere
RawVecInner: Send,
impl Sync for Messagewhere
RawVecInner: Sync,
impl Unpin for Message
impl UnsafeUnpin for Messagewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<AssistantToolCall>: UnsafeUnpin,
impl UnwindSafe for Messagewhere
RawVecInner: UnwindSafe,
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