Skip to main content

GraphStore

Trait GraphStore 

Source
pub trait GraphStore: Send + Sync {
Show 13 methods // Required methods fn add_node<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, id: &'life1 str, memory: &'life2 str, metadata: &'life3 HashMap<String, Value>, user_name: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait; fn add_nodes_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, nodes: &'life1 [MemoryNode], user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn add_edges_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, edges: &'life1 [MemoryEdge], user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_node<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, include_embedding: bool, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_nodes<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [String], include_embedding: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_neighbors<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, id: &'life1 str, relation: Option<&'life2 str>, direction: GraphDirection, limit: usize, include_embedding: bool, user_name: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNeighbor>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn shortest_path<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, source_id: &'life1 str, target_id: &'life2 str, relation: Option<&'life3 str>, direction: GraphDirection, max_depth: usize, include_deleted: bool, user_name: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<GraphPath>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait; fn find_paths<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, source_id: &'life1 str, target_id: &'life2 str, relation: Option<&'life3 str>, direction: GraphDirection, max_depth: usize, top_k: usize, include_deleted: bool, user_name: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GraphPath>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait; fn search_by_embedding<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, vector: &'life1 [f32], top_k: usize, user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VecSearchHit>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_all_memory_items<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, user_name: &'life2 str, include_embedding: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn update_node<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, id: &'life1 str, fields: &'life2 HashMap<String, Value>, user_name: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn delete_node<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 str, user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn delete_edges_by_node<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 str, user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<usize, GraphStoreError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait;
}
Expand description

Graph store abstraction (subset of MemOS BaseGraphDB).

Required Methods§

Source

fn add_node<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, id: &'life1 str, memory: &'life2 str, metadata: &'life3 HashMap<String, Value>, user_name: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Add a single memory node.

Source

fn add_nodes_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, nodes: &'life1 [MemoryNode], user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Add multiple nodes in batch.

Source

fn add_edges_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, edges: &'life1 [MemoryEdge], user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Add multiple edges in batch.

Source

fn get_node<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, include_embedding: bool, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get one node by id.

Source

fn get_nodes<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [String], include_embedding: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get multiple nodes by ids.

Source

fn get_neighbors<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, id: &'life1 str, relation: Option<&'life2 str>, direction: GraphDirection, limit: usize, include_embedding: bool, user_name: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNeighbor>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Get neighbors of one node, optionally filtered by relation and direction.

Source

fn shortest_path<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, source_id: &'life1 str, target_id: &'life2 str, relation: Option<&'life3 str>, direction: GraphDirection, max_depth: usize, include_deleted: bool, user_name: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<GraphPath>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Shortest path query between source and target by BFS hops.

Source

fn find_paths<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, source_id: &'life1 str, target_id: &'life2 str, relation: Option<&'life3 str>, direction: GraphDirection, max_depth: usize, top_k: usize, include_deleted: bool, user_name: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GraphPath>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Enumerate top-k shortest simple paths by BFS hops.

Source

fn search_by_embedding<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, vector: &'life1 [f32], top_k: usize, user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VecSearchHit>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search by embedding vector (returns node ids + scores).

Source

fn get_all_memory_items<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, user_name: &'life2 str, include_embedding: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get all memory items for a scope and user.

Source

fn update_node<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, id: &'life1 str, fields: &'life2 HashMap<String, Value>, user_name: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Update fields of an existing node (memory and/or metadata).

Source

fn delete_node<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 str, user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete a node (hard delete). If user_name is Some, implementation must verify the node belongs to that user/cube (e.g. via metadata) before deleting; return error if not owner.

Source

fn delete_edges_by_node<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 str, user_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<usize, GraphStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete all edges connected to a node. Returns number of deleted edges.

Implementors§