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>) -> Self
pub fn text(text: impl Into<String>) -> Self
Helper constructor to make creating tool result text content easier.
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
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>,
) -> Self
pub fn image_raw( data: impl Into<Vec<u8>>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
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>,
) -> Self
pub fn image_url( url: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
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 moreSource§impl Debug for ToolResultContent
impl Debug for ToolResultContent
Source§impl<'de> Deserialize<'de> for ToolResultContent
impl<'de> Deserialize<'de> for ToolResultContent
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<String> for ToolResultContent
impl From<String> for ToolResultContent
Source§impl From<ToolResultContent> for Message
impl From<ToolResultContent> for Message
Source§fn from(tool_result_content: ToolResultContent) -> Self
fn from(tool_result_content: ToolResultContent) -> Self
Source§impl From<ToolResultContent> for ToolResultContent
impl From<ToolResultContent> for ToolResultContent
Source§fn from(content: ToolResultContent) -> Self
fn from(content: ToolResultContent) -> Self
Source§impl From<ToolResultContent> for ToolOutput
impl From<ToolResultContent> for ToolOutput
Source§fn from(content: ToolResultContent) -> Self
fn from(content: ToolResultContent) -> Self
Source§impl PartialEq for ToolResultContent
impl PartialEq for ToolResultContent
Source§impl Serialize for ToolResultContent
impl Serialize for ToolResultContent
impl StructuralPartialEq for ToolResultContent
Auto Trait Implementations§
impl Freeze for ToolResultContent
impl RefUnwindSafe for ToolResultContent
impl Send for ToolResultContent
impl Sync for ToolResultContent
impl Unpin for ToolResultContent
impl UnsafeUnpin for ToolResultContent
impl UnwindSafe for ToolResultContent
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> 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