pub enum Message {
Human(HumanMessage),
Ai(AiMessage),
System(SystemMessage),
Tool(ToolMessage),
}Expand description
A single message in an LLM conversation.
Variants§
Human(HumanMessage)
User input.
Ai(AiMessage)
Assistant response.
System(SystemMessage)
System prompt or instruction.
Tool(ToolMessage)
Tool execution result.
Implementations§
Source§impl Message
Convenience constructors.
impl Message
Convenience constructors.
Sourcepub fn human_with_parts(
content: impl Into<String>,
parts: Vec<ContentPart>,
) -> Message
pub fn human_with_parts( content: impl Into<String>, parts: Vec<ContentPart>, ) -> Message
Build a Human message that carries multimodal parts alongside text.
Providers that support multimodal will serialize the parts; others
silently ignore them and use the text content alone.
Sourcepub fn ai(content: impl Into<String>) -> Message
pub fn ai(content: impl Into<String>) -> Message
Build an Ai message with text only (no tool calls, no parts).
Sourcepub fn ai_with_parts(
content: impl Into<String>,
parts: Vec<ContentPart>,
) -> Message
pub fn ai_with_parts( content: impl Into<String>, parts: Vec<ContentPart>, ) -> Message
Build an Ai message with multimodal parts alongside text.
Sourcepub fn tool(call_id: impl Into<String>, content: impl Into<String>) -> Message
pub fn tool(call_id: impl Into<String>, content: impl Into<String>) -> Message
Build a Tool message.
Sourcepub fn content(&self) -> &str
pub fn content(&self) -> &str
Get the message’s primary text content (empty string for messages that are tool-call-only with no text).
Sourcepub fn tool_calls(&self) -> &[ToolCall]
pub fn tool_calls(&self) -> &[ToolCall]
Returns the tool calls if this is an Ai message; empty otherwise.
Sourcepub fn has_tool_calls(&self) -> bool
pub fn has_tool_calls(&self) -> bool
True if this is an Ai message with at least one tool call.
Sourcepub fn parts(&self) -> &[ContentPart]
pub fn parts(&self) -> &[ContentPart]
Multimodal parts on a Human or Ai message. Empty for System
/ Tool (they don’t carry multimodal content).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Runnable<Vec<Message>, Message> for Client
impl Runnable<Vec<Message>, Message> for Client
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Vec<Message>,
__arg2: RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Vec<Message>,
__arg2: RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn batch<'life0, 'async_trait>(
&'life0 self,
inputs: Vec<I>,
config: RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<Vec<O>, CognisError>> + Send + 'async_trait>>
fn batch<'life0, 'async_trait>( &'life0 self, inputs: Vec<I>, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<O>, CognisError>> + Send + 'async_trait>>
buffer_unordered
honouring config.max_concurrency.Source§fn stream<'life0, 'async_trait>(
&'life0 self,
input: I,
config: RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<RunnableStream<O>, CognisError>> + Send + 'async_trait>>
fn stream<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<RunnableStream<O>, CognisError>> + Send + 'async_trait>>
O). Default emits one item via
invoke — non-streaming runnables are correct without override.Source§fn stream_events<'life0, 'async_trait>(
&'life0 self,
input: I,
config: RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<EventStream, CognisError>> + Send + 'async_trait>>
fn stream_events<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<EventStream, CognisError>> + Send + 'async_trait>>
invoke call. Graph engines override to surface per-node events.