(
&self,
py: Python<'_>,
prompt: String,
attachments: Vec<Bound<'_, PyDict>>,
history: Option<&Bound<'_, PyList>>,
)
| 1769 | /// history: Optional conversation history |
| 1770 | #[pyo3(signature = (prompt, attachments, history=None))] |
| 1771 | fn stream_with_attachments( |
| 1772 | &self, |
| 1773 | py: Python<'_>, |
| 1774 | prompt: String, |
| 1775 | attachments: Vec<Bound<'_, PyDict>>, |
| 1776 | history: Option<&Bound<'_, PyList>>, |
| 1777 | ) -> PyResult<PyEventStream> { |
| 1778 | let rust_attachments = py_attachments_to_rust(&attachments)?; |
| 1779 | let rust_history = history.map(|h| py_list_to_messages(h)).transpose()?; |
| 1780 | let session = self.inner.clone(); |
| 1781 | let (rx, _handle) = py |
| 1782 | .allow_threads(move || { |
| 1783 | get_runtime().block_on(session.stream_with_attachments( |
| 1784 | &prompt, |
| 1785 | &rust_attachments, |
| 1786 | rust_history.as_deref(), |
| 1787 | )) |
| 1788 | }) |
| 1789 | .map_err(|e| PyRuntimeError::new_err(format!("Failed to start stream: {e}")))?; |
| 1790 | Ok(PyEventStream { |
| 1791 | rx: Arc::new(Mutex::new(rx)), |
| 1792 | done: Arc::new(AtomicBool::new(false)), |
| 1793 | }) |
| 1794 | } |
| 1795 | |
| 1796 | /// Return the session's conversation history as a list of dicts. |
| 1797 | /// |
no test coverage detected