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

Function py_attachment_list_to_rust

sdk/python/src/lib.rs:6405–6425  ·  view source on GitHub ↗
(
    attachments: &Bound<'_, PyList>,
)

Source from the content-addressed store, hash-verified

6403}
6404
6405fn py_attachment_list_to_rust(
6406 attachments: &Bound<'_, PyList>,
6407) -> PyResult<Vec<a3s_code_core::llm::Attachment>> {
6408 attachments
6409 .iter()
6410 .map(|item| {
6411 let dict = item
6412 .downcast::<PyDict>()
6413 .map_err(|_| PyTypeError::new_err("attachments must contain dict items"))?;
6414 let data: Vec<u8> = dict
6415 .get_item("data")?
6416 .ok_or_else(|| PyValueError::new_err("Attachment missing 'data' field"))?
6417 .extract()?;
6418 let media_type: String = dict
6419 .get_item("media_type")?
6420 .ok_or_else(|| PyValueError::new_err("Attachment missing 'media_type' field"))?
6421 .extract()?;
6422 Ok(a3s_code_core::llm::Attachment::new(data, media_type))
6423 })
6424 .collect()
6425}
6426
6427fn py_session_request_to_parts(
6428 request: &Bound<'_, PyDict>,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected