Convert a Python list of message dicts to `Vec `. Expected format: `[{"role": "user", "content": [{"type": "text", "text": "Hello"}]}]`
(list: &Bound<'_, PyList>)
| 6485 | /// |
| 6486 | /// Expected format: `[{"role": "user", "content": [{"type": "text", "text": "Hello"}]}]` |
| 6487 | fn py_list_to_messages(list: &Bound<'_, PyList>) -> PyResult<Vec<RustMessage>> { |
| 6488 | let py = list.py(); |
| 6489 | let json_mod = py.import("json")?; |
| 6490 | let json_str: String = json_mod.call_method1("dumps", (list,))?.extract()?; |
| 6491 | serde_json::from_str::<Vec<RustMessage>>(&json_str) |
| 6492 | .map_err(|e| PyTypeError::new_err(format!("Invalid history format: {e}"))) |
| 6493 | } |
| 6494 | |
| 6495 | /// Convert a Python list of verification command dicts to Rust commands. |
| 6496 | /// |
no outgoing calls
no test coverage detected