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

Function py_session_input_to_parts

sdk/python/src/lib.rs:6462–6482  ·  view source on GitHub ↗
(
    input: &Bound<'_, PyAny>,
    history: Option<&Bound<'_, PyList>>,
)

Source from the content-addressed store, hash-verified

6460}
6461
6462fn py_session_input_to_parts(
6463 input: &Bound<'_, PyAny>,
6464 history: Option<&Bound<'_, PyList>>,
6465) -> PyResult<(
6466 String,
6467 Option<Vec<RustMessage>>,
6468 Vec<a3s_code_core::llm::Attachment>,
6469)> {
6470 if let Ok(prompt) = input.extract::<String>() {
6471 let rust_history = history.map(py_list_to_messages).transpose()?;
6472 return Ok((prompt, rust_history, Vec::new()));
6473 }
6474
6475 if let Ok(request) = input.downcast::<PyDict>() {
6476 return py_session_request_to_parts(request);
6477 }
6478
6479 Err(PyTypeError::new_err(
6480 "session input must be a prompt string or request dict",
6481 ))
6482}
6483
6484/// Convert a Python list of message dicts to `Vec<RustMessage>`.
6485///

Callers 2

sendMethod · 0.85
streamMethod · 0.85

Calls 1

Tested by

no test coverage detected