#[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>) -> Self
pub fn new(content: Vec<AssistantContent>) -> Self
A hand-built turn of content: no origin or stop.
Sourcepub fn rolled_back(
origin: Option<Origin>,
content: Vec<AssistantContent>,
) -> Self
pub fn rolled_back( origin: Option<Origin>, content: Vec<AssistantContent>, ) -> Self
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>,
) -> Self
pub fn aborted( origin: Option<Origin>, content: Vec<AssistantContent>, reason: impl Into<String>, ) -> Self
The turn a run failed on before the reply ended: kept in history, never replayed.
Sourcepub fn with_content(self, content: Vec<AssistantContent>) -> Self
pub fn with_content(self, content: Vec<AssistantContent>) -> Self
This turn holding content in place of its blocks.
Sourcepub fn with_origin(self, origin: impl Into<Option<Origin>>) -> Self
pub fn with_origin(self, origin: impl Into<Option<Origin>>) -> Self
This turn with origin as who produced it.
Sourcepub fn with_stop(self, stop: impl Into<Option<StopReason>>) -> Self
pub fn with_stop(self, stop: impl Into<Option<StopReason>>) -> Self
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§impl Debug for AssistantMessage
impl Debug for AssistantMessage
Source§impl Default for AssistantMessage
impl Default for AssistantMessage
Source§impl<'de> Deserialize<'de> for AssistantMessage
impl<'de> Deserialize<'de> for AssistantMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<AssistantMessage> for Message
impl From<AssistantMessage> for Message
Source§fn from(message: AssistantMessage) -> Self
fn from(message: AssistantMessage) -> Self
Source§impl PartialEq for AssistantMessage
impl PartialEq for AssistantMessage
Source§impl Serialize for AssistantMessage
impl Serialize for AssistantMessage
impl StructuralPartialEq for AssistantMessage
Auto Trait Implementations§
impl Freeze for AssistantMessage
impl RefUnwindSafe for AssistantMessage
impl Send for AssistantMessage
impl Sync for AssistantMessage
impl Unpin for AssistantMessage
impl UnsafeUnpin for AssistantMessage
impl UnwindSafe for AssistantMessage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more