pub struct InMemoryMemoryStore { /* private fields */ }Expand description
A process-local MemoryStore. Same semantics as the SQLite store,
nothing persisted. Lexical scores use word overlap.
Implementations§
Trait Implementations§
Source§impl Default for InMemoryMemoryStore
impl Default for InMemoryMemoryStore
Source§impl MemoryStore for InMemoryMemoryStore
impl MemoryStore for InMemoryMemoryStore
Source§fn upsert_fact<'life0, 'async_trait>(
&'life0 self,
fact: NewFact,
embedding: Option<StoredEmbedding>,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<UpsertOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upsert_fact<'life0, 'async_trait>(
&'life0 self,
fact: NewFact,
embedding: Option<StoredEmbedding>,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<UpsertOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert, reinforce or supersede (see the trait docs).
embedding
describes the new value’s search text, when one was computed.Source§fn upsert_fact_with_access<'life0, 'life1, 'async_trait>(
&'life0 self,
fact: NewFact,
embedding: Option<StoredEmbedding>,
access: &'life1 FactAccess,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<UpsertOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn upsert_fact_with_access<'life0, 'life1, 'async_trait>(
&'life0 self,
fact: NewFact,
embedding: Option<StoredEmbedding>,
access: &'life1 FactAccess,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<UpsertOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
MemoryStore::upsert_fact that records who may see the fact,
atomically with the write. A reinforced fact keeps the narrowest of
its access and access (FactAccess::narrowest); a new version
takes access. The default ignores access, which leaves the fact
unclassified and so private.Source§fn fact_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
ids: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, FactAccess>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fact_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
ids: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, FactAccess>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Who may see these facts, by id, for ids in
scope the store knows. A
fact absent from the map is unclassified and treated as private.Source§fn supersede_fact<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 str,
category: &'life2 str,
key: &'life3 str,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn supersede_fact<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 str,
category: &'life2 str,
key: &'life3 str,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Mark the active fact for this key superseded.
false if none.Source§fn active_facts<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<FactRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn active_facts<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<FactRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Every active fact in
scope, with embeddings.Source§fn fact_graph_scores<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
seed_ids: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fact_graph_scores<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
seed_ids: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
How related each active fact in
scope is to the seed_ids (facts
that matched the query), 0.0-1.0 by fact id. The default has no graph:
an empty map leaves the graph signal at 0 and ranking as it was. A
store that keeps no edges can use related_fact_scores.Source§fn fact_history<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 str,
category: &'life2 str,
key: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Fact>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn fact_history<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 str,
category: &'life2 str,
key: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Fact>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
All versions of one key, oldest first, superseded ones included.
Source§fn record_fact_recalls<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [String],
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn record_fact_recalls<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [String],
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Bump
recall_count and set last_recalled_at for these facts.fn insert_episode<'life0, 'async_trait>(
&'life0 self,
episode: NewEpisode,
embedding: Option<StoredEmbedding>,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<Episode>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn insert_episode_with_access<'life0, 'life1, 'async_trait>(
&'life0 self,
episode: NewEpisode,
embedding: Option<StoredEmbedding>,
access: &'life1 FactAccess,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<Episode>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn insert_episode_with_access<'life0, 'life1, 'async_trait>(
&'life0 self,
episode: NewEpisode,
embedding: Option<StoredEmbedding>,
access: &'life1 FactAccess,
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<Episode>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
MemoryStore::insert_episode that records who may see the episode.
The default ignores access, leaving the episode private.Source§fn episode_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
ids: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, FactAccess>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn episode_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
ids: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, FactAccess>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Who may see these episodes; see
MemoryStore::fact_access.Source§fn episodes<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<EpisodeRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn episodes<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<EpisodeRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Every episode in
scope, with embeddings.fn record_episode_recalls<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [String],
now: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn decay<'life0, 'life1, 'async_trait>(
&'life0 self,
now: DateTime<Utc>,
config: &'life1 RetentionConfig,
) -> Pin<Box<dyn Future<Output = Result<DecayReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn decay<'life0, 'life1, 'async_trait>(
&'life0 self,
now: DateTime<Utc>,
config: &'life1 RetentionConfig,
) -> Pin<Box<dyn Future<Output = Result<DecayReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Apply recall decay and retention (see
RetentionConfig). The
default does nothing, for stores whose backend handles expiry.Source§fn stale_embeddings<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
kind: RecordKind,
after_id: Option<&'life2 str>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<StaleEmbedding>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stale_embeddings<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model: &'life1 str,
kind: RecordKind,
after_id: Option<&'life2 str>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<StaleEmbedding>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Up to
limit records of kind with no vector or a vector from a
model other than model, in ascending id order after after_id.
Superseded facts are excluded: they are never compared. The default
finds none, so such a store keeps lexical recall for old rows.Source§fn replace_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
stale: &'life1 StaleEmbedding,
embedding: StoredEmbedding,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn replace_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
stale: &'life1 StaleEmbedding,
embedding: StoredEmbedding,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Replace a stale record’s vector, only if it still has the model
stale reported; false otherwise. Changes nothing else about the
record: updated_at feeds ranking and this is not a new statement.fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MemoryStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn fact_lexical_scores<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fact_lexical_scores<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Lexical relevance (0.0-1.0) of active facts to
query, by fact id.
Facts absent from the map score 0. The default is word overlap over
Fact::search_text.Source§fn search_facts<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_scope: &'life1 str,
_query: &'life2 str,
_query_embedding: Option<&'life3 StoredEmbedding>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ScoredFact>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn search_facts<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_scope: &'life1 str,
_query: &'life2 str,
_query_embedding: Option<&'life3 StoredEmbedding>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ScoredFact>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Native ranked search. Return
Some to bypass the scorer: the result
is used as is (already filtered, ordered, at most limit). The
default None lets crate::Memory score candidates itself.Source§fn episode_lexical_scores<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn episode_lexical_scores<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Lexical relevance of episodes; default word overlap.
Source§fn search_episodes<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_scope: &'life1 str,
_query: &'life2 str,
_query_embedding: Option<&'life3 StoredEmbedding>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ScoredEpisode>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn search_episodes<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_scope: &'life1 str,
_query: &'life2 str,
_query_embedding: Option<&'life3 StoredEmbedding>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ScoredEpisode>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Native ranked episode search; see
MemoryStore::search_facts.Auto Trait Implementations§
impl !Freeze for InMemoryMemoryStore
impl Forget for InMemoryMemoryStore
impl Move for InMemoryMemoryStore
impl RefUnwindSafe for InMemoryMemoryStorewhere
Mutex<Inner>: RefUnwindSafe,
impl Send for InMemoryMemoryStore
impl Sync for InMemoryMemoryStore
impl Unpin for InMemoryMemoryStore
impl UnsafeUnpin for InMemoryMemoryStorewhere
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<FactRecord>: UnsafeUnpin,
PhantomData<EpisodeRecord>: UnsafeUnpin,
PhantomData<(String, FactAccess)>: UnsafeUnpin,
impl UnwindSafe for InMemoryMemoryStorewhere
Mutex<Inner>: UnwindSafe,
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> 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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more