Skip to main content

ToolOutput

Struct ToolOutput 

Source
pub struct ToolOutput { /* private fields */ }
Expand description

The payload carried by an explicit successful or business-error result.

use reef_core::value::{content, tool_call};
let verified = tool_call::ToolPart::try_from_part(content::Part::text("ok".into())).unwrap();
let output = tool_call::ToolOutput::new(
    vec![verified], Some(String::new()), None,
    tool_call::MetadataPresence::Present(content::Metadata::new()),
);
assert_eq!(output.model_content().len(), 1);
assert_eq!(output.user_view(), Some(""));
assert_eq!(output.log_preview(), None);
ⓘ
use reef_core::value::{content, tool_call};
let _unchecked = tool_call::ToolOutput::new(
    vec![content::Part::text("not verified".into())], None, None, tool_call::MetadataPresence::Absent,
);

Implementations§

Source§

impl ToolOutput

Source

pub const fn new( model_content: Vec<ToolPart>, user_view: Option<String>, log_preview: Option<String>, metadata: MetadataPresence, ) -> Self

Creates an owned output from already verified model content.

Source

pub fn model_content(&self) -> &[ToolPart]

Returns ordered, verified model-facing content.

Source

pub fn user_view(&self) -> Option<&str>

Returns the optional complete user-facing representation.

Source

pub fn log_preview(&self) -> Option<&str>

Returns the optional bounded log representation.

Source

pub const fn metadata(&self) -> &MetadataPresence

Returns the exact metadata presence state.

Source

pub fn into_parts( self, ) -> (Vec<ToolPart>, Option<String>, Option<String>, MetadataPresence)

Transfers every output field and its presence state.

Trait Implementations§

Source§

impl Clone for ToolOutput

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolOutput

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Sizes both rendered views and keeps their presence apart.

user_view and log_preview are the two fields an end user sees, so they are the last place a formatter should quote. model_content needs no special handling: every element redacts itself.

Source§

impl<'de> Deserialize<'de> for ToolOutput

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ToolOutput

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.