MCPcopy Index your code
hub / github.com/AI45Lab/Code / py_list_to_messages

Function py_list_to_messages

sdk/python/src/lib.rs:6487–6493  ·  view source on GitHub ↗

Convert a Python list of message dicts to `Vec `. Expected format: `[{"role": "user", "content": [{"type": "text", "text": "Hello"}]}]`

(list: &Bound<'_, PyList>)

Source from the content-addressed store, hash-verified

6485///
6486/// Expected format: `[{"role": "user", "content": [{"type": "text", "text": "Hello"}]}]`
6487fn 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///

Callers 3

send_with_attachmentsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected