Get current short-term memory items. Short-term memory contains items stored during this session. Returns: List of memory item dicts in short-term memory for this session.
(&self, py: Python<'py>)
| 3203 | /// Returns: |
| 3204 | /// List of memory item dicts in short-term memory for this session. |
| 3205 | fn get_short_term<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyList>> { |
| 3206 | let memory = self |
| 3207 | .inner |
| 3208 | .memory() |
| 3209 | .ok_or_else(|| PyRuntimeError::new_err("Memory not configured for this session"))? |
| 3210 | .clone(); |
| 3211 | let items = py.allow_threads(move || get_runtime().block_on(memory.get_short_term())); |
| 3212 | let json_str = serde_json::to_string(&items) |
| 3213 | .map_err(|e| PyRuntimeError::new_err(format!("Serialization error: {e}")))?; |
| 3214 | let json_mod = py.import("json")?; |
| 3215 | let py_obj = json_mod.call_method1("loads", (json_str,))?; |
| 3216 | py_obj |
| 3217 | .downcast::<PyList>() |
| 3218 | .cloned() |
| 3219 | .map_err(|e| PyRuntimeError::new_err(format!("Unexpected result: {e}"))) |
| 3220 | } |
| 3221 | |
| 3222 | /// Clear short-term memory for this session. |
| 3223 | /// |
nothing calls this directly
no test coverage detected