pub struct ToolOutput { /* private fields */ }Expand description
The canonical model-visible output produced by a tool.
Every output is stored as one or more typed ToolResultContent blocks.
Ordinary serializable Rust values are converted through IntoToolOutput:
values that serialize as JSON strings become literal text blocks and all
other values become structured JSON blocks. An explicit
serde_json::Value, including a JSON string, stays JSON. Multimodal tools
opt in explicitly with Self::content. Rig never reparses text as JSON to
guess whether it represents rich content.
Implementations§
Source§impl ToolOutput
impl ToolOutput
Sourcepub fn json(value: Value) -> Self
pub fn json(value: Value) -> Self
Construct structured JSON output.
Unlike an ordinary Rust string tool output, an explicit JSON string stays a JSON content block.
Sourcepub fn content(content: OneOrMany<ToolResultContent>) -> Self
pub fn content(content: OneOrMany<ToolResultContent>) -> Self
Construct explicit model content.
Sourcepub fn one(content: ToolResultContent) -> Self
pub fn one(content: ToolResultContent) -> Self
Construct one explicit model-content block.
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
Return literal text when this output is exactly one plain text block.
Sourcepub fn as_json(&self) -> Option<&Value>
pub fn as_json(&self) -> Option<&Value>
Return structured JSON when this output is exactly one JSON block.
Sourcepub fn as_content(&self) -> &OneOrMany<ToolResultContent>
pub fn as_content(&self) -> &OneOrMany<ToolResultContent>
Borrow the canonical ordered content blocks.
Sourcepub fn into_content(self) -> OneOrMany<ToolResultContent>
pub fn into_content(self) -> OneOrMany<ToolResultContent>
Convert this output into the canonical message content sent to a model.
Trait Implementations§
Source§impl Clone for ToolOutput
impl Clone for ToolOutput
Source§fn clone(&self) -> ToolOutput
fn clone(&self) -> ToolOutput
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 ToolOutput
impl Debug for ToolOutput
Source§impl From<&str> for ToolOutput
impl From<&str> for ToolOutput
Source§impl From<OneOrMany<ToolResultContent>> for ToolOutput
impl From<OneOrMany<ToolResultContent>> for ToolOutput
Source§fn from(content: OneOrMany<ToolResultContent>) -> Self
fn from(content: OneOrMany<ToolResultContent>) -> Self
Source§impl From<String> for ToolOutput
impl From<String> for ToolOutput
Source§impl From<ToolResultContent> for ToolOutput
impl From<ToolResultContent> for ToolOutput
Source§fn from(content: ToolResultContent) -> Self
fn from(content: ToolResultContent) -> Self
Source§impl From<Value> for ToolOutput
impl From<Value> for ToolOutput
Source§impl IntoToolOutput for ToolOutput
impl IntoToolOutput for ToolOutput
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§impl PartialEq for ToolOutput
impl PartialEq for ToolOutput
impl StructuralPartialEq for ToolOutput
Auto Trait Implementations§
impl Freeze for ToolOutput
impl RefUnwindSafe for ToolOutput
impl Send for ToolOutput
impl Sync for ToolOutput
impl Unpin for ToolOutput
impl UnsafeUnpin for ToolOutput
impl UnwindSafe for ToolOutput
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,
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