Send a request using the long-lived object-shaped API. Prefer this for new integrations when the call may need history, attachments, or future request options.
(&self, py: Python<'_>, request: &Bound<'_, PyDict>)
| 1678 | /// Prefer this for new integrations when the call may need history, |
| 1679 | /// attachments, or future request options. |
| 1680 | fn send_request(&self, py: Python<'_>, request: &Bound<'_, PyDict>) -> PyResult<PyAgentResult> { |
| 1681 | let (prompt, rust_history, rust_attachments) = py_session_request_to_parts(request)?; |
| 1682 | let session = self.inner.clone(); |
| 1683 | |
| 1684 | let result = if rust_attachments.is_empty() { |
| 1685 | py.allow_threads(move || { |
| 1686 | get_runtime().block_on(session.send(&prompt, rust_history.as_deref())) |
| 1687 | }) |
| 1688 | } else { |
| 1689 | py.allow_threads(move || { |
| 1690 | get_runtime().block_on(session.send_with_attachments( |
| 1691 | &prompt, |
| 1692 | &rust_attachments, |
| 1693 | rust_history.as_deref(), |
| 1694 | )) |
| 1695 | }) |
| 1696 | } |
| 1697 | .map_err(|e| PyRuntimeError::new_err(format!("Agent execution failed: {e}")))?; |
| 1698 | |
| 1699 | Ok(PyAgentResult::from(result)) |
| 1700 | } |
| 1701 | |
| 1702 | /// Stream a request using the long-lived object-shaped API. |
| 1703 | fn stream_request( |
nothing calls this directly
no test coverage detected