pub enum ToolResultContent {
Text(Text),
Image(Image),
Json {
value: Value,
},
}Expand description
Describes one typed item in a tool result.
Variants§
Text(Text)
Literal text. Providers must not reinterpret it as structured JSON.
Image(Image)
An image supplied explicitly by the tool.
Json
Structured JSON supplied explicitly by the tool runtime.
Implementations§
Source§impl ToolResultContent
impl ToolResultContent
Sourcepub fn deserialize_json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn deserialize_json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Deserialize JSON content into a typed value.
Structured JSON is decoded directly. Literal text is parsed only because the caller explicitly requested JSON decoding, which supports transcripts recorded before structured tool output was preserved canonically. This helper never changes the content sent to a model or provider.
Source§impl ToolResultContent
impl ToolResultContent
Sourcepub fn text(text: impl Into<String>) -> ToolResultContent
pub fn text(text: impl Into<String>) -> ToolResultContent
Helper constructor to make creating tool result text content easier.
Sourcepub fn json(value: Value) -> ToolResultContent
pub fn json(value: Value) -> ToolResultContent
Helper constructor for structured JSON tool-result content.
Sourcepub fn image_base64(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> ToolResultContent
pub fn image_base64( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> ToolResultContent
Helper constructor to make tool result images from a base64-encoded string.
Sourcepub fn image_raw(
data: impl Into<Vec<u8>>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> ToolResultContent
pub fn image_raw( data: impl Into<Vec<u8>>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> ToolResultContent
Helper constructor to make tool result images from a base64-encoded string.
Sourcepub fn image_url(
url: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> ToolResultContent
pub fn image_url( url: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> ToolResultContent
Helper constructor to make tool result images from a URL.
Trait Implementations§
Source§impl Clone for ToolResultContent
impl Clone for ToolResultContent
Source§fn clone(&self) -> ToolResultContent
fn clone(&self) -> ToolResultContent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more