Skip to main content

MessagesState

Struct MessagesState 

Source
pub struct MessagesState {
    pub messages: Vec<Message>,
}
Expand description

Built-in state for simple chat agents

Provides a zero-config entry point for simple chat agents with a single messages field using the messages reducer semantics.

§Examples

use juncture_core::state::messages::{MessagesState, Message};

let mut state = MessagesState::default();
state.messages.push(Message::human("Hello"));
state.messages.push(Message::ai("Hi there!"));

Fields§

§messages: Vec<Message>

Message history using append+merge+delete semantics

Implementations§

Source§

impl MessagesState

Source

pub fn try_apply_messages( &mut self, update: MessagesStateUpdate, ) -> Result<FieldsChanged, InvalidUpdateError>

Apply an update with structured error propagation for reducer violations

The messages reducer is an append+merge+delete reducer that never conflicts, so this always succeeds. Provided for trait consistency.

§Errors

This method never returns an error, as the messages reducer has no write-conflict semantics. The Result return type is for API consistency with State::try_apply().

Trait Implementations§

Source§

impl Clone for MessagesState

Source§

fn clone(&self) -> MessagesState

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 MessagesState

Source§

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

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

impl Default for MessagesState

Source§

fn default() -> MessagesState

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MessagesState

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<MessagesState, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl Node<MessagesState> for ValidationNode

Source§

fn call( &self, state: &MessagesState, _config: &RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Command<MessagesState>, JunctureError>> + Send + '_>>

Execute the node logic Read more
Source§

fn name(&self) -> &'static str

Get the node name Read more
Source§

fn call_arc( &self, state: Arc<S>, config: &RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Command<S>, JunctureError>> + Send + '_>>

Execute node logic with Arc<S> to avoid O(N) state clone. Read more
Source§

impl Serialize for MessagesState

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl State for MessagesState

Source§

type Update = MessagesStateUpdate

Partial update type generated by #[derive(State)]
Source§

type FieldVersions = FieldVersions

Field version tracking type generated by #[derive(State)].
Source§

fn apply(&mut self, update: <MessagesState as State>::Update) -> FieldsChanged

Apply an update to this state, returning which fields changed
Source§

fn reset_ephemeral(&mut self)

Reset ephemeral fields (called after each superstep)
Source§

fn field_versions(&self) -> Self::FieldVersions

Get the current field version numbers. Read more
Source§

fn bump_versions(&mut self, _changed: &FieldsChanged)

Increment version numbers for the fields marked in changed. Read more
Source§

fn try_apply( &mut self, update: Self::Update, ) -> Result<FieldsChanged, InvalidUpdateError>

Apply an update to this state, returning which fields changed or an error Read more
Source§

fn finish_field(&mut self, _field_idx: usize)

Finish a specific field (called when graph execution completes) Read more
Source§

fn consume_field(&mut self, _field_idx: usize)

Consume a specific field (called after apply_writes() per superstep) Read more
Source§

fn consume_field_indices() -> &'static [usize]

Indices of fields that use the ephemeral reducer. Read more
Source§

fn schema_version() -> u32

Schema version for migration
Source§

fn migrate(_from_version: u32, value: Value) -> Value

Migrate from older schema version
Source§

fn replace_field_indices() -> &'static [usize]

Indices of fields that use the replace reducer. Read more
Source§

fn replace_after_finish_field_indices() -> &'static [usize]

Indices of fields that use the replace_after_finish reducer. Read more
Source§

fn field_is_set(_update: &Self::Update, _field_idx: usize) -> bool

Check if a specific field is set (Some) in an update. Read more
Source§

fn field_count() -> usize

Number of fields in this state type. Read more
Source§

fn field_names() -> &'static [&'static str]

Names of fields in declaration order. Read more
Source§

fn delta_channel_specs() -> &'static [(usize, usize)]

Field indices and snapshot frequencies for DeltaChannel fields. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromState<S> for S
where S: State,

Source§

fn from_state(state: &S) -> S

Extract Self from a reference to the full state type S.
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<S> IntoState<S> for S
where S: State,

Source§

fn into_state(self) -> S

Convert self into the full state type S.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

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

Source§

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