MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / search

Method search

core/src/memory/service.rs:121–143  ·  view source on GitHub ↗

Embed a query and search for the most similar memories within a scope.

(
        &self,
        query: &str,
        scope: &MemoryScope,
        top_k: usize,
    )

Source from the content-addressed store, hash-verified

119
120 /// Embed a query and search for the most similar memories within a scope.
121 pub async fn search(
122 &self,
123 query: &str,
124 scope: &MemoryScope,
125 top_k: usize,
126 ) -> GraphBitResult<Vec<ScoredMemory>> {
127 let query_embedding = self.embedding_service.embed_text(query).await?;
128 let results = self
129 .vector_index
130 .search(&query_embedding, top_k, self.config.similarity_threshold)
131 .await?;
132
133 let mut scored = Vec::new();
134 for (memory_id, score) in results {
135 if let Some(memory) = self.store.get_memory(&memory_id).await? {
136 if matches_scope(&memory.scope, scope) {
137 scored.push(ScoredMemory { memory, score });
138 }
139 }
140 }
141
142 Ok(scored)
143 }
144
145 /// Get a single memory by its ID.
146 pub async fn get(&self, memory_id: &MemoryId) -> GraphBitResult<Option<Memory>> {

Callers

nothing calls this directly

Calls 3

matches_scopeFunction · 0.85
embed_textMethod · 0.80
get_memoryMethod · 0.80

Tested by

no test coverage detected