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
impl MessagesState
Sourcepub fn try_apply_messages(
&mut self,
update: MessagesStateUpdate,
) -> Result<FieldsChanged, InvalidUpdateError>
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
impl Clone for MessagesState
Source§fn clone(&self) -> MessagesState
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MessagesState
impl Debug for MessagesState
Source§impl Default for MessagesState
impl Default for MessagesState
Source§fn default() -> MessagesState
fn default() -> MessagesState
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MessagesState
impl<'de> Deserialize<'de> for MessagesState
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MessagesState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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
impl Node<MessagesState> for ValidationNode
Source§fn call(
&self,
state: &MessagesState,
_config: &RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<Command<MessagesState>, JunctureError>> + Send + '_>>
fn call( &self, state: &MessagesState, _config: &RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Command<MessagesState>, JunctureError>> + Send + '_>>
Execute the node logic Read more
Source§impl Serialize for MessagesState
impl Serialize for MessagesState
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
impl State for MessagesState
Source§type Update = MessagesStateUpdate
type Update = MessagesStateUpdate
Partial update type generated by #[derive(State)]
Source§type FieldVersions = FieldVersions
type FieldVersions = FieldVersions
Field version tracking type generated by
#[derive(State)].Source§fn apply(&mut self, update: <MessagesState as State>::Update) -> FieldsChanged
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)
fn reset_ephemeral(&mut self)
Reset ephemeral fields (called after each superstep)
Source§fn field_versions(&self) -> Self::FieldVersions
fn field_versions(&self) -> Self::FieldVersions
Get the current field version numbers. Read more
Source§fn bump_versions(&mut self, _changed: &FieldsChanged)
fn bump_versions(&mut self, _changed: &FieldsChanged)
Increment version numbers for the fields marked in
changed. Read moreSource§fn try_apply(
&mut self,
update: Self::Update,
) -> Result<FieldsChanged, InvalidUpdateError>
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)
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)
fn consume_field(&mut self, _field_idx: usize)
Consume a specific field (called after
apply_writes() per superstep) Read moreSource§fn consume_field_indices() -> &'static [usize]
fn consume_field_indices() -> &'static [usize]
Indices of fields that use the
ephemeral reducer. Read moreSource§fn schema_version() -> u32
fn schema_version() -> u32
Schema version for migration
Source§fn replace_field_indices() -> &'static [usize]
fn replace_field_indices() -> &'static [usize]
Indices of fields that use the
replace reducer. Read moreSource§fn replace_after_finish_field_indices() -> &'static [usize]
fn replace_after_finish_field_indices() -> &'static [usize]
Indices of fields that use the
replace_after_finish reducer. Read moreSource§fn field_is_set(_update: &Self::Update, _field_idx: usize) -> bool
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
fn field_count() -> usize
Number of fields in this state type. Read more
Source§fn field_names() -> &'static [&'static str]
fn field_names() -> &'static [&'static str]
Names of fields in declaration order. Read more
Auto Trait Implementations§
impl Freeze for MessagesState
impl RefUnwindSafe for MessagesState
impl Send for MessagesState
impl Sync for MessagesState
impl Unpin for MessagesState
impl UnsafeUnpin for MessagesState
impl UnwindSafe for MessagesState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromState<S> for Swhere
S: State,
impl<S> FromState<S> for Swhere
S: State,
Source§fn from_state(state: &S) -> S
fn from_state(state: &S) -> S
Extract
Self from a reference to the full state type S.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<S> IntoState<S> for Swhere
S: State,
impl<S> IntoState<S> for Swhere
S: State,
Source§fn into_state(self) -> S
fn into_state(self) -> S
Convert
self into the full state type S.