pub struct Message {
pub role: Role,
pub content: Vec<Content>,
}Expand description
One turn in a conversation.
Fields§
§role: Role§content: Vec<Content>Implementations§
Source§impl Message
impl Message
pub fn new(role: Role, content: Vec<Content>) -> Message
pub fn system(text: impl Into<String>) -> Message
pub fn user(text: impl Into<String>) -> Message
pub fn assistant(text: impl Into<String>) -> Message
Sourcepub fn tool_result(
id: impl Into<String>,
name: impl Into<String>,
output: Json,
) -> Message
pub fn tool_result( id: impl Into<String>, name: impl Into<String>, output: Json, ) -> Message
The answer from a tool the assistant asked for.
Sourcepub fn tool_error(
id: impl Into<String>,
name: impl Into<String>,
message: impl Into<String>,
) -> Message
pub fn tool_error( id: impl Into<String>, name: impl Into<String>, message: impl Into<String>, ) -> Message
A tool that failed.
Handed back to the model rather than raised, because a model that hears “that city does not exist” usually corrects itself, and a model that hears nothing at all just hangs the loop.
pub fn with(self, part: Content) -> Message
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Every text part joined, which is what a caller usually means by “what did it say”.
Sourcepub fn tool_uses(&self) -> impl Iterator<Item = (&str, &str, &Json)>
pub fn tool_uses(&self) -> impl Iterator<Item = (&str, &str, &Json)>
The tool requests in this turn, if any.
pub fn is_empty(&self) -> bool
Trait Implementations§
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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