#[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 stopped before the reply ended: kept in history as no answer, replayed as its text alone.
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.
Sourcepub fn is_empty_turn(&self) -> bool
pub fn is_empty_turn(&self) -> bool
Whether this generated turn is empty: every part is blank
(AssistantContent::is_blank, the rule replay drops parts by). An
empty turn must not enter history.
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