Convert Python attachment dicts to Rust Attachment vec.
(
attachments: &[Bound<'_, PyDict>],
)
| 6384 | |
| 6385 | /// Convert Python attachment dicts to Rust Attachment vec. |
| 6386 | fn py_attachments_to_rust( |
| 6387 | attachments: &[Bound<'_, PyDict>], |
| 6388 | ) -> PyResult<Vec<a3s_code_core::llm::Attachment>> { |
| 6389 | attachments |
| 6390 | .iter() |
| 6391 | .map(|dict| { |
| 6392 | let data: Vec<u8> = dict |
| 6393 | .get_item("data")? |
| 6394 | .ok_or_else(|| PyValueError::new_err("Attachment missing 'data' field"))? |
| 6395 | .extract()?; |
| 6396 | let media_type: String = dict |
| 6397 | .get_item("media_type")? |
| 6398 | .ok_or_else(|| PyValueError::new_err("Attachment missing 'media_type' field"))? |
| 6399 | .extract()?; |
| 6400 | Ok(a3s_code_core::llm::Attachment::new(data, media_type)) |
| 6401 | }) |
| 6402 | .collect() |
| 6403 | } |
| 6404 | |
| 6405 | fn py_attachment_list_to_rust( |
| 6406 | attachments: &Bound<'_, PyList>, |
no outgoing calls
no test coverage detected