#[non_exhaustive]pub struct AssistantMessage {
pub content: Vec<AssistantContent>,
pub origin: Option<Origin>,
pub stop: Option<StopReason>,
}Expand description
One assistant turn.
content holds one block per provider output item, in the order the
provider produced them. origin names the wire, provider and model that
produced the turn; a hand-built turn has none and always replays from its
canonical fields.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.content: Vec<AssistantContent>The blocks, in provider order.
origin: Option<Origin>Who produced the turn.
stop: Option<StopReason>How the turn ended.
Implementations§
Source§impl AssistantMessage
impl AssistantMessage
Sourcepub fn new(content: Vec<AssistantContent>) -> AssistantMessage
pub fn new(content: Vec<AssistantContent>) -> AssistantMessage
A hand-built turn of content: no origin or stop.
Sourcepub fn rolled_back(
origin: Option<Origin>,
content: Vec<AssistantContent>,
) -> AssistantMessage
pub fn rolled_back( origin: Option<Origin>, content: Vec<AssistantContent>, ) -> AssistantMessage
The turn a runtime rolls back over: what arrived of a reply from
origin, stopped to call tools, since the runtime answers its calls.
content keeps only the provider items its fold kept.
Sourcepub fn aborted(
origin: Option<Origin>,
content: Vec<AssistantContent>,
reason: impl Into<String>,
) -> AssistantMessage
pub fn aborted( origin: Option<Origin>, content: Vec<AssistantContent>, reason: impl Into<String>, ) -> AssistantMessage
The turn a run failed on before the reply ended: kept in history, never replayed.
Sourcepub fn with_content(self, content: Vec<AssistantContent>) -> AssistantMessage
pub fn with_content(self, content: Vec<AssistantContent>) -> AssistantMessage
This turn holding content in place of its blocks.
Sourcepub fn with_origin(self, origin: impl Into<Option<Origin>>) -> AssistantMessage
pub fn with_origin(self, origin: impl Into<Option<Origin>>) -> AssistantMessage
This turn with origin as who produced it.
Sourcepub fn with_stop(self, stop: impl Into<Option<StopReason>>) -> AssistantMessage
pub fn with_stop(self, stop: impl Into<Option<StopReason>>) -> AssistantMessage
This turn with stop as how it ended.
Sourcepub fn tool_calls(&self) -> impl Iterator<Item = &ToolCall>
pub fn tool_calls(&self) -> impl Iterator<Item = &ToolCall>
The tool calls, in order.
Trait Implementations§
Source§impl Clone for AssistantMessage
impl Clone for AssistantMessage
Source§fn clone(&self) -> AssistantMessage
fn clone(&self) -> AssistantMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more