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

Method search

python/src/memory/client.rs:93–121  ·  view source on GitHub ↗
(
        &self,
        py: Python<'_>,
        query: String,
        user_id: Option<String>,
        agent_id: Option<String>,
        run_id: Option<String>,
        top_k: Option<usize>,
    )

Source from the content-addressed store, hash-verified

91 /// * `top_k` - Maximum number of results (default 10).
92 #[pyo3(signature = (query, user_id=None, agent_id=None, run_id=None, top_k=None))]
93 fn search(
94 &self,
95 py: Python<'_>,
96 query: String,
97 user_id: Option<String>,
98 agent_id: Option<String>,
99 run_id: Option<String>,
100 top_k: Option<usize>,
101 ) -> PyResult<Vec<PyScoredMemory>> {
102 let scope = graphbit_core::memory::MemoryScope {
103 user_id,
104 agent_id,
105 run_id,
106 };
107 let k = top_k.unwrap_or(10);
108
109 let service = Arc::clone(&self.service);
110 let rt = get_runtime();
111
112 py.allow_threads(|| {
113 rt.block_on(async move {
114 let results = service
115 .search(&query, &scope, k)
116 .await
117 .map_err(to_py_runtime_error)?;
118 Ok(results.into_iter().map(PyScoredMemory::from).collect())
119 })
120 })
121 }
122
123 /// Get a single memory by its ID.
124 fn get(&self, py: Python<'_>, memory_id: String) -> PyResult<Option<PyMemory>> {

Callers

nothing calls this directly

Calls 1

get_runtimeFunction · 0.50

Tested by

no test coverage detected