pub struct MemoryItem {
pub key: String,
pub text: String,
pub importance: f64,
pub metadata: HashMap<String, String>,
}Expand description
A storable unit of knowledge.
importance is clamped into [0, 1] by the stores; key must be stable within a
namespace (re-putting the same key updates the entry).
Fields§
§key: StringStable identifier within the namespace.
text: StringThe memory text, matched by semantic search.
importance: f64Importance in [0, 1] (higher resists decay and promotes sooner).
metadata: HashMap<String, String>Arbitrary structured annotations (user id, source turn, …).
Implementations§
Source§impl MemoryItem
impl MemoryItem
Sourcepub fn new(key: impl Into<String>, text: impl Into<String>) -> Self
pub fn new(key: impl Into<String>, text: impl Into<String>) -> Self
Creates a memory with default importance 0.5 and no metadata.
Sourcepub fn with_importance(self, importance: f64) -> Self
pub fn with_importance(self, importance: f64) -> Self
Sets the importance (clamped to [0, 1] at write time anyway).
Sourcepub fn metadata(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn metadata(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds one metadata annotation.
Sourcepub fn with_metadata(self, metadata: HashMap<String, String>) -> Self
pub fn with_metadata(self, metadata: HashMap<String, String>) -> Self
Replaces the whole metadata map.
Trait Implementations§
Source§impl Clone for MemoryItem
impl Clone for MemoryItem
Source§fn clone(&self) -> MemoryItem
fn clone(&self) -> MemoryItem
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 MemoryItem
impl Debug for MemoryItem
Source§impl PartialEq for MemoryItem
impl PartialEq for MemoryItem
impl StructuralPartialEq for MemoryItem
Auto Trait Implementations§
impl Freeze for MemoryItem
impl RefUnwindSafe for MemoryItem
impl Send for MemoryItem
impl Sync for MemoryItem
impl Unpin for MemoryItem
impl UnsafeUnpin for MemoryItem
impl UnwindSafe for MemoryItem
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