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
impl ToolOutput
Sourcepub const fn new(
model_content: Vec<ToolPart>,
user_view: Option<String>,
log_preview: Option<String>,
metadata: MetadataPresence,
) -> Self
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.
Sourcepub fn model_content(&self) -> &[ToolPart]
pub fn model_content(&self) -> &[ToolPart]
Returns ordered, verified model-facing content.
Sourcepub fn user_view(&self) -> Option<&str>
pub fn user_view(&self) -> Option<&str>
Returns the optional complete user-facing representation.
Sourcepub fn log_preview(&self) -> Option<&str>
pub fn log_preview(&self) -> Option<&str>
Returns the optional bounded log representation.
Sourcepub const fn metadata(&self) -> &MetadataPresence
pub const fn metadata(&self) -> &MetadataPresence
Returns the exact metadata presence state.
Sourcepub fn into_parts(
self,
) -> (Vec<ToolPart>, Option<String>, Option<String>, MetadataPresence)
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
impl Clone for ToolOutput
Source§impl Debug for ToolOutput
impl Debug for ToolOutput
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
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
impl<'de> Deserialize<'de> for ToolOutput
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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more