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

Method stream_with_attachments

sdk/python/src/lib.rs:1771–1794  ·  view source on GitHub ↗
(
        &self,
        py: Python<'_>,
        prompt: String,
        attachments: Vec<Bound<'_, PyDict>>,
        history: Option<&Bound<'_, PyList>>,
    )

Source from the content-addressed store, hash-verified

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 ///

Callers 2

streamMethod · 0.45
stream_requestMethod · 0.45

Calls 5

py_attachments_to_rustFunction · 0.85
py_list_to_messagesFunction · 0.85
block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected