pub struct InMemoryHistoryProvider { /* private fields */ }Expand description
In-memory HistoryProvider: keeps history in an Arc<Mutex<Vec<Message>>>,
shared across clones.
Implementations§
Source§impl InMemoryHistoryProvider
impl InMemoryHistoryProvider
Sourcepub fn new() -> InMemoryHistoryProvider
pub fn new() -> InMemoryHistoryProvider
An empty history provider.
Sourcepub fn with_messages(messages: Vec<Message>) -> InMemoryHistoryProvider
pub fn with_messages(messages: Vec<Message>) -> InMemoryHistoryProvider
A history provider seeded with messages.
Sourcepub fn list_messages(&self) -> Vec<Message>
pub fn list_messages(&self) -> Vec<Message>
The stored messages, in chronological order.
Sourcepub fn from_dict(state: &Value) -> Result<InMemoryHistoryProvider, Error>
pub fn from_dict(state: &Value) -> Result<InMemoryHistoryProvider, Error>
Reconstruct a provider from state produced by InMemoryHistoryProvider::to_dict.
Trait Implementations§
Source§impl Clone for InMemoryHistoryProvider
impl Clone for InMemoryHistoryProvider
Source§fn clone(&self) -> InMemoryHistoryProvider
fn clone(&self) -> InMemoryHistoryProvider
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 ContextProvider for InMemoryHistoryProvider
impl ContextProvider for InMemoryHistoryProvider
Source§fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut SessionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
InMemoryHistoryProvider: 'async_trait,
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut SessionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
InMemoryHistoryProvider: 'async_trait,
Called before the model is invoked; mutate ctx to inject instructions,
messages, and/or tools. Read ctx.input_messages / ctx.session_id.
Source§fn after_run<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request_messages: &'life1 [Message],
response_messages: &'life2 [Message],
error: Option<&'life3 Error>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
InMemoryHistoryProvider: 'async_trait,
fn after_run<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request_messages: &'life1 [Message],
response_messages: &'life2 [Message],
error: Option<&'life3 Error>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
InMemoryHistoryProvider: 'async_trait,
Called after an invocation completes, on BOTH success and failure.
On success, error is None and response_messages holds the output.
On failure, error is Some and response_messages is empty.
Source§fn is_history_provider(&self) -> bool
fn is_history_provider(&self) -> bool
Whether this provider manages conversation history (a
HistoryProvider). Agent
and WorkflowAgent use this to
detect an already-attached history provider among a session’s
context_providers and avoid auto-attaching a redundant
InMemoryHistoryProvider.
Defaults to false; history providers override it to true.Source§impl Default for InMemoryHistoryProvider
impl Default for InMemoryHistoryProvider
Source§fn default() -> InMemoryHistoryProvider
fn default() -> InMemoryHistoryProvider
Returns the “default value” for a type. Read more
impl HistoryProvider for InMemoryHistoryProvider
Auto Trait Implementations§
impl Freeze for InMemoryHistoryProvider
impl RefUnwindSafe for InMemoryHistoryProvider
impl Send for InMemoryHistoryProvider
impl Sync for InMemoryHistoryProvider
impl Unpin for InMemoryHistoryProvider
impl UnsafeUnpin for InMemoryHistoryProvider
impl UnwindSafe for InMemoryHistoryProvider
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