Skip to main content

ModelContentItem

Enum ModelContentItem 

Source
pub enum ModelContentItem {
    System(SystemModelContent),
    User(UserModelContent),
    Agent(AgentModelContent),
    MergeDownstream(String),
    MergeUpstream(String),
}
Expand description

An enum that represents a single piece of content in a conversation or prompt sent to a model. It distinguishes between system instructions, user input, and agent responses.

Each variant wraps a specific content type ([SystemModelContent], [UserModelContent], [AgentModelContent]), allowing the execution engine to categorize and format different parts of a prompt appropriately for an external model.

Variants§

§

System(SystemModelContent)

Content provided by the system, typically for instructions or context.

§

User(UserModelContent)

Content provided by the user, representing direct input or queries.

§

Agent(AgentModelContent)

Content generated by an AI agent or a previous model response.

§

MergeDownstream(String)

Content to merge to next message as a prefix. This is used internally to handle special merging logic during prompt construction.

§

MergeUpstream(String)

Content to merge to previous message as a postfix. This is used internally to handle special merging logic during prompt construction.

Implementations§

Source§

impl ModelContentItem

Source

pub fn user(text: &str) -> Self

Creates a new ModelContentItem::User from a string slice.

§Arguments
  • text - The text content for the user message.
§Returns

A ModelContentItem variant containing the user’s text.

Source

pub fn system(text: &str) -> Self

Creates a new ModelContentItem::System from a string slice.

§Arguments
  • text - The text content for the system message.
§Returns

A ModelContentItem variant containing the system’s text.

Source

pub fn agent(author: Option<String>, text: &str) -> Self

Creates a new ModelContentItem::Agent from a string slice.

§Arguments
  • author - The author of the agent message.
  • text - The text content for the agent’s message.
§Returns

A ModelContentItem variant containing the agent’s text.

Source

pub fn merge_downstream(text: &str) -> Self

Creates a new ModelContentItem::MergeDownstream from a string slice.

This variant is used internally to indicate that its content should be prepended to the next non-merge ModelContentItem during prompt construction.

§Arguments
  • text - The text content to be merged downstream.
§Returns

A ModelContentItem::MergeDownstream variant.

Source

pub fn merge_upstream(text: &str) -> Self

Creates a new ModelContentItem::MergeUpstream from a string slice.

This variant is used internally to indicate that its content should be appended to the previous non-merge ModelContentItem during prompt construction.

§Arguments
  • text - The text content to be merged upstream.
§Returns

A ModelContentItem::MergeUpstream variant.

Source

pub fn is_empty(&self) -> bool

Checks if the content of the ModelContentItem is empty or contains only whitespace.

This is useful for filtering out empty messages during prompt construction.

§Returns

true if the item’s text content is empty or only whitespace, false otherwise.

Trait Implementations§

Source§

impl Clone for ModelContentItem

Source§

fn clone(&self) -> ModelContentItem

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 ModelContentItem

Source§

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

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

impl<'de> Deserialize<'de> for ModelContentItem

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 ModelContentItem

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
Source§

impl ToString for ModelContentItem

Source§

fn to_string(&self) -> String

Converts the ModelContentItem into its raw text content.

This implementation of ToString simply returns the underlying text of the content item, without any additional formatting or headers.

§Returns

A String containing the raw text content.

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more