Skip to main content

Assistant

Struct Assistant 

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

An assistant-output transcript record.

content is the sole source of truth. Text, thinking, and calls remain in their original provider order rather than being flattened into parallel collections. Record-level provider data is metadata, not another segment.

An assistant record is ModelVisibility::Visible unless Assistant::with_visibility says otherwise: the model said it, so by default the model may see it again. ModelVisibility::Hidden is what a hook selects when it replaces the record through AfterModelDecision::Modify or supplies one through BeforeModelDecision::ShortCircuit, which is how a history stays complete for a user-facing timeline while the model is sent less than all of it. Because reef propagates this record’s visibility onto every result committed with it, hiding a record that carries tool calls also hides their results, and the projected request stays legal.

use reef_core::transcript::item;
use reef_core::value::content;
let extensions = || content::SegmentExtensions::new(String::new(), None, None);
let item = item::Assistant::new(vec![
    content::Segment::Text { text: "a".into(), extensions: extensions() },
    content::Segment::Thinking { text: "b".into(), extensions: extensions() },
], Some(vec![]));
assert_eq!(item.content().len(), 2);
assert!(item.provider_data().is_some_and(<[_]>::is_empty));
assert_eq!(item.visibility(), item::ModelVisibility::Visible);

let hidden = item.with_visibility(item::ModelVisibility::Hidden);
assert_eq!(hidden.visibility(), item::ModelVisibility::Hidden);
ⓘ
use reef_core::transcript::item;
let _forged = item::Assistant {
    content: vec![], provider_data: None, visibility: item::ModelVisibility::Visible,
};

Implementations§

Source§

impl Assistant

Source

pub const fn new( content: Vec<Segment>, provider_data: Option<Vec<Envelope>>, ) -> Self

Creates a model-visible assistant record from ordered segments and record metadata.

Source

pub const fn with_visibility(self, visibility: ModelVisibility) -> Self

Declares whether this record participates in model projection.

Source

pub fn content(&self) -> &[Segment]

Returns the authoritative ordered segments.

Source

pub fn provider_data(&self) -> Option<&[Envelope]>

Returns ordered record-level provider metadata, preserving presence.

Source

pub const fn visibility(&self) -> ModelVisibility

Returns this record’s model visibility.

Trait Implementations§

Source§

impl Clone for Assistant

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 Assistant

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Assistant

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 Assistant

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.