#[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) -> AssistantContent
pub fn canonical(&self) -> AssistantContent
This block without its provider item: what a different provider can use, and what its fingerprint covers. The item is not copied.
Sourcepub fn into_canonical(self) -> AssistantContent
pub fn into_canonical(self) -> AssistantContent
Self::canonical, taking the block.
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, so it replays 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) -> AssistantContent
pub fn with_native(self, item: Value) -> AssistantContent
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 text(text: impl Into<String>) -> AssistantContent
pub fn text(text: impl Into<String>) -> AssistantContent
Creates assistant text content.
Sourcepub fn image_base64(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> AssistantContent
pub fn image_base64( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> AssistantContent
Creates assistant image content from base64-encoded data.
Sourcepub fn tool_call(
id: impl Into<String>,
name: ToolName,
arguments: Value,
) -> AssistantContent
pub fn tool_call( id: impl Into<String>, name: ToolName, arguments: Value, ) -> AssistantContent
Creates a tool call from a provider-issued ID, name, and arguments.
Rig issues an id when id is empty.
Sourcepub fn reasoning(reasoning: impl Into<String>) -> AssistantContent
pub fn reasoning(reasoning: impl Into<String>) -> AssistantContent
Creates reasoning text with no provider item.
Trait Implementations§
Source§impl Clone for AssistantContent
impl Clone for AssistantContent
Source§fn clone(&self) -> AssistantContent
fn clone(&self) -> AssistantContent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more