mem0_rust/lib.rs
1//! # mem0-rust
2//!
3//! A Rust implementation of mem0 - Universal memory layer for AI Agents.
4//!
5//! This library provides a flexible memory system with support for multiple:
6//! - Embedding providers (OpenAI, Ollama, HuggingFace)
7//! - Vector stores (In-memory, Qdrant, PostgreSQL, Redis)
8//! - LLM providers (OpenAI, Ollama, Anthropic)
9//!
10//! ## Quick Start
11//!
12//! ```rust,no_run
13//! use mem0_rust::{Memory, MemoryConfig};
14//!
15//! #[tokio::main]
16//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
17//! let config = MemoryConfig::default();
18//! let memory = Memory::new(config).await?;
19//!
20//! // Add a memory
21//! let result = memory.add("User prefers dark mode", Default::default()).await?;
22//!
23//! // Search memories
24//! let results = memory.search("user preferences", Default::default()).await?;
25//!
26//! Ok(())
27//! }
28//! ```
29
30pub mod config;
31pub mod embeddings;
32pub mod errors;
33pub mod history;
34pub mod llms;
35pub mod memory;
36pub mod models;
37pub mod rerankers;
38pub mod utils;
39pub mod vector_stores;
40
41// Re-export main types for convenience
42// Re-export main types for convenience
43pub use config::{
44 EmbedderConfig, HuggingFaceEmbedderConfig, LLMConfig, MemoryConfig, MockEmbedderConfig,
45 RerankerConfig, CohereRerankerConfig, VectorStoreConfig,
46};
47pub use errors::MemoryError;
48pub use memory::Memory;
49pub use models::{
50 AddOptions, AddResult, Filters, GetAllOptions, HistoryEntry, MemoryRecord, Message, Role, SearchOptions,
51 SearchResult,
52};
53
54/// Prelude module for convenient imports
55pub mod prelude {
56 pub use crate::config::*;
57 pub use crate::errors::*;
58 pub use crate::memory::Memory;
59 pub use crate::models::*;
60}
61
62#[cfg(test)]
63mod tests {
64 use super::*;
65
66 #[tokio::test]
67 async fn test_memory_creation() {
68 let config = MemoryConfig::default();
69 let memory = Memory::new(config).await;
70 assert!(memory.is_ok());
71 }
72}