MCPcopy Create free account
hub / github.com/AI45Lab/Code / recall_similar

Method recall_similar

sdk/python/src/lib.rs:3056–3078  ·  view source on GitHub ↗
(
        &self,
        py: Python<'py>,
        query: String,
        limit: usize,
    )

Source from the content-addressed store, hash-verified

3054 /// List of dicts with task, tools, result/error, outcome, timestamp.
3055 #[pyo3(signature = (query, limit=5))]
3056 fn recall_similar<'py>(
3057 &self,
3058 py: Python<'py>,
3059 query: String,
3060 limit: usize,
3061 ) -> PyResult<Bound<'py, PyList>> {
3062 let memory = self
3063 .inner
3064 .memory()
3065 .ok_or_else(|| PyRuntimeError::new_err("Memory not configured for this session"))?
3066 .clone();
3067 let items = py
3068 .allow_threads(move || get_runtime().block_on(memory.recall_similar(&query, limit)))
3069 .map_err(|e| PyRuntimeError::new_err(format!("Recall failed: {e}")))?;
3070 let json_str = serde_json::to_string(&items)
3071 .map_err(|e| PyRuntimeError::new_err(format!("Serialization error: {e}")))?;
3072 let json_mod = py.import("json")?;
3073 let py_obj = json_mod.call_method1("loads", (json_str,))?;
3074 py_obj
3075 .downcast::<PyList>()
3076 .cloned()
3077 .map_err(|e| PyRuntimeError::new_err(format!("Unexpected result: {e}")))
3078 }
3079
3080 /// Recall memories by tags.
3081 ///

Callers

nothing calls this directly

Calls 4

block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45
memoryMethod · 0.45

Tested by

no test coverage detected