#[non_exhaustive]pub enum AssistantContent {
Text(Text),
ToolCall(ToolCall),
Reasoning(Reasoning),
Image(Image),
Opaque(Opaque),
}Expand description
One block of an assistant turn: one provider output item.
Deserialization requires the lowercase type tag.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text(Text)
Answer text.
ToolCall(ToolCall)
A tool call requested by the assistant.
Reasoning(Reasoning)
Reasoning the model showed.
Image(Image)
An image the assistant produced.
Opaque(Opaque)
A provider item with no canonical meaning.
Implementations§
Source§impl AssistantContent
impl AssistantContent
Sourcepub fn replay(&self, target: &dyn ReplayTarget, ids: &WireIds) -> Replay<'_>
pub fn replay(&self, target: &dyn ReplayTarget, ids: &WireIds) -> Replay<'_>
What target’s encoder sends for this block, with call ids spelled
by ids. Encoders read provider items only through this.
Source§impl AssistantContent
impl AssistantContent
Sourcepub fn canonical(&self) -> Self
pub fn canonical(&self) -> Self
This block without its provider item: what a different provider can use, and what its fingerprint covers.
Sourcepub fn is_answer(&self) -> bool
pub fn is_answer(&self) -> bool
Whether the block answers the user: text that is not blank, a call or an image. Reasoning and provider-only items are not an answer.
Sourcepub fn is_blank(&self) -> bool
pub fn is_blank(&self) -> bool
Whether the block has nothing to send, so replay drops it: blank text or reasoning, and redacted reasoning, without a provider item that is still current (with one, its identity pairs it with what follows, and pi replays it whatever its text), and an opaque item that does not replay.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
The fingerprint of the block’s canonical fields, through a fixed, versioned projection rather than the block’s serde layout, so a field added to a canonical type never stales stored items. A rig-issued call id counts as one placeholder: rig issues a fresh id each time it decodes a call the provider sent without one.
Sourcepub fn with_native(self, item: Value) -> Self
pub fn with_native(self, item: Value) -> Self
The provider item this block was decoded from, held for its current
canonical form. An Opaque block has no separate item.
Sourcepub fn native_item(&self) -> Option<&Value>
pub fn native_item(&self) -> Option<&Value>
The provider item, while the block is still what it was decoded from. An edited block has none: encoders rebuild it.
Source§impl AssistantContent
impl AssistantContent
Sourcepub fn image_base64(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_base64( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Creates assistant image content from base64-encoded data.
Trait Implementations§
Source§impl Clone for AssistantContent
impl Clone for AssistantContent
Source§impl Debug for AssistantContent
impl Debug for AssistantContent
Source§impl<'de> Deserialize<'de> for AssistantContent
impl<'de> Deserialize<'de> for AssistantContent
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<AssistantContent> for Message
impl From<AssistantContent> for Message
Source§fn from(content: AssistantContent) -> Self
fn from(content: AssistantContent) -> Self
Source§impl From<String> for AssistantContent
impl From<String> for AssistantContent
Source§impl PartialEq for AssistantContent
impl PartialEq for AssistantContent
Source§impl Serialize for AssistantContent
impl Serialize for AssistantContent
impl StructuralPartialEq for AssistantContent
Auto Trait Implementations§
impl Freeze for AssistantContent
impl RefUnwindSafe for AssistantContent
impl Send for AssistantContent
impl Sync for AssistantContent
impl Unpin for AssistantContent
impl UnsafeUnpin for AssistantContent
impl UnwindSafe for AssistantContent
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