| 1430 | /// `[{"role": "user", "content": [{"type": "text", "text": "..."}]}]` |
| 1431 | #[pyo3(signature = (prompt, history=None))] |
| 1432 | fn send( |
| 1433 | &self, |
| 1434 | py: Python<'_>, |
| 1435 | prompt: &Bound<'_, PyAny>, |
| 1436 | history: Option<&Bound<'_, PyList>>, |
| 1437 | ) -> PyResult<PyAgentResult> { |
| 1438 | let (prompt, rust_history, rust_attachments) = py_session_input_to_parts(prompt, history)?; |
| 1439 | let session = self.inner.clone(); |
| 1440 | let result = if rust_attachments.is_empty() { |
| 1441 | py.allow_threads(move || { |
| 1442 | get_runtime().block_on(session.send(&prompt, rust_history.as_deref())) |
| 1443 | }) |
| 1444 | } else { |
| 1445 | py.allow_threads(move || { |
| 1446 | get_runtime().block_on(session.send_with_attachments( |
| 1447 | &prompt, |
| 1448 | &rust_attachments, |
| 1449 | rust_history.as_deref(), |
| 1450 | )) |
| 1451 | }) |
| 1452 | } |
| 1453 | .map_err(|e| PyRuntimeError::new_err(format!("Agent execution failed: {e}")))?; |
| 1454 | Ok(PyAgentResult::from(result)) |
| 1455 | } |
| 1456 | |
| 1457 | /// Alias for ``send(...)`` with a name that matches run/replay terminology. |
| 1458 | #[pyo3(signature = (prompt, history=None))] |