1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # blazen-memory
//!
//! Memory and vector store for Blazen with ELID integration.
//!
//! This crate provides a memory store that can operate in two modes:
//!
//! - **Full mode**: Uses an [`EmbeddingModel`](blazen_llm::EmbeddingModel) to
//! generate embeddings, encodes them with [ELID](elid) into compact sortable
//! identifiers, and uses LSH (Locality-Sensitive Hashing) bands for efficient
//! approximate nearest-neighbor retrieval.
//!
//! - **Local mode**: Uses string-level `SimHash` for lightweight similarity search
//! without requiring an embedding model.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use blazen_memory::{Memory, MemoryStore, MemoryEntry, InMemoryBackend};
//! use std::sync::Arc;
//!
//! # async fn example(embedder: Arc<dyn blazen_llm::EmbeddingModel>) -> blazen_memory::error::Result<()> {
//! let memory = Memory::new(embedder, InMemoryBackend::new());
//!
//! memory.add(vec![
//! MemoryEntry::new("The cat sat on the mat"),
//! MemoryEntry::new("The dog played in the park"),
//! ]).await?;
//!
//! let results = memory.search("animals sitting", 5, None).await?;
//! for r in results {
//! println!("{:.3} — {}", r.score, r.text);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Local-only mode
//!
//! ```rust,no_run
//! use blazen_memory::{Memory, MemoryStore, MemoryEntry, InMemoryBackend};
//!
//! # async fn example() -> blazen_memory::error::Result<()> {
//! let memory = Memory::local(InMemoryBackend::new());
//!
//! memory.add(vec![MemoryEntry::new("hello world")]).await?;
//!
//! // Use search_local instead of search — no embedding model needed.
//! let results = memory.search_local("hello", 5, None).await?;
//! # Ok(())
//! # }
//! ```
// Re-exports for ergonomic imports.
pub use InMemoryBackend;
pub use JsonlBackend;
pub use MemoryError;
pub use Memory;
pub use ;
pub use ;