pub struct DialogueStore { /* private fields */ }Expand description
Concurrent map of session ID → DialogueSession.
DialogueStore is cheap to clone — the inner map is wrapped in an
Arc<Mutex<_>> so all clones share the same underlying storage.
Implementations§
Source§impl DialogueStore
impl DialogueStore
Sourcepub fn upsert(&self, session: DialogueSession) -> Result<(), AgentRuntimeError>
pub fn upsert(&self, session: DialogueSession) -> Result<(), AgentRuntimeError>
Insert or completely replace the session for session_id.
Sourcepub fn get(
&self,
session_id: &str,
) -> Result<Option<DialogueSession>, AgentRuntimeError>
pub fn get( &self, session_id: &str, ) -> Result<Option<DialogueSession>, AgentRuntimeError>
Retrieve a clone of the session for session_id, or None if absent.
Sourcepub fn append_turn(
&self,
session_id: impl Into<String>,
role: Role,
content: impl Into<String>,
) -> Result<(), AgentRuntimeError>
pub fn append_turn( &self, session_id: impl Into<String>, role: Role, content: impl Into<String>, ) -> Result<(), AgentRuntimeError>
Append a turn to an existing session, creating the session if it does not yet exist.
Sourcepub fn remove(
&self,
session_id: &str,
) -> Result<Option<DialogueSession>, AgentRuntimeError>
pub fn remove( &self, session_id: &str, ) -> Result<Option<DialogueSession>, AgentRuntimeError>
Remove and return the session for session_id.
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Return the number of sessions currently stored.
Sourcepub fn session_ids(&self) -> Vec<String>
pub fn session_ids(&self) -> Vec<String>
Return a sorted list of all session IDs.
Trait Implementations§
Source§impl Clone for DialogueStore
impl Clone for DialogueStore
Source§fn clone(&self) -> DialogueStore
fn clone(&self) -> DialogueStore
Returns a duplicate of the value. Read more
1.0.0 · 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 DialogueStore
impl Debug for DialogueStore
Source§impl Default for DialogueStore
impl Default for DialogueStore
Source§fn default() -> DialogueStore
fn default() -> DialogueStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DialogueStore
impl RefUnwindSafe for DialogueStore
impl Send for DialogueStore
impl Sync for DialogueStore
impl Unpin for DialogueStore
impl UnsafeUnpin for DialogueStore
impl UnwindSafe for DialogueStore
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