pub enum Message {
System {
content: String,
},
User {
content: Vec<UserContent>,
},
Assistant(AssistantMessage),
}Expand description
A provider-agnostic chat message.
Messages are role-tagged and may contain one or many content items, including text, images, audio, documents, tool calls, and tool results. Provider modules are responsible for translating these generic messages into provider-native request bodies. That conversion may be lossy when a provider does not support a particular content type.
Variants§
System
System message containing instruction text.
User
User message containing one or more content types defined by UserContent.
Fields
content: Vec<UserContent>Assistant(AssistantMessage)
An assistant turn: its blocks in the order the provider produced them, and where they came from.
Implementations§
Source§impl Message
impl Message
Sourcepub fn rag_text(&self) -> Option<String>
pub fn rag_text(&self) -> Option<String>
Clones the first text block of a user message, or returns None.
Sourcepub fn user(text: impl Into<String>) -> Message
pub fn user(text: impl Into<String>) -> Message
Creates a user message containing one text block.
Sourcepub fn assistant(text: impl Into<String>) -> Message
pub fn assistant(text: impl Into<String>) -> Message
Creates a hand-built assistant message containing one text block.
Sourcepub fn tool_result(
call: CallId,
name: ToolName,
content: impl Into<String>,
) -> Message
pub fn tool_result( call: CallId, name: ToolName, content: impl Into<String>, ) -> Message
Creates a user message containing a text tool result answering the
call call to the tool name. To answer a call you hold, prefer
ToolCall::result with Self::tool_results.
Sourcepub fn tool_results(results: Vec<ToolResult>) -> Message
pub fn tool_results(results: Vec<ToolResult>) -> Message
Creates a user message carrying results, in order.