(&self, py: Python<'py>, limit: usize)
| 3119 | /// List of memory item dicts. |
| 3120 | #[pyo3(signature = (limit=10))] |
| 3121 | fn memory_recent<'py>(&self, py: Python<'py>, limit: usize) -> PyResult<Bound<'py, PyList>> { |
| 3122 | let memory = self |
| 3123 | .inner |
| 3124 | .memory() |
| 3125 | .ok_or_else(|| PyRuntimeError::new_err("Memory not configured for this session"))? |
| 3126 | .clone(); |
| 3127 | let items = py |
| 3128 | .allow_threads(move || get_runtime().block_on(memory.get_recent(limit))) |
| 3129 | .map_err(|e| PyRuntimeError::new_err(format!("Recall failed: {e}")))?; |
| 3130 | let json_str = serde_json::to_string(&items) |
| 3131 | .map_err(|e| PyRuntimeError::new_err(format!("Serialization error: {e}")))?; |
| 3132 | let json_mod = py.import("json")?; |
| 3133 | let py_obj = json_mod.call_method1("loads", (json_str,))?; |
| 3134 | py_obj |
| 3135 | .downcast::<PyList>() |
| 3136 | .cloned() |
| 3137 | .map_err(|e| PyRuntimeError::new_err(format!("Unexpected result: {e}"))) |
| 3138 | } |
| 3139 | |
| 3140 | /// Get memory statistics. |
| 3141 | /// |
nothing calls this directly
no test coverage detected