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

Method stream_with_attachments

sdk/node/src/lib.rs:3496–3518  ·  view source on GitHub ↗
(
        &self,
        prompt: String,
        attachments: Vec<AttachmentObject>,
        history: Option<Vec<MessageObject>>,
    )

Source from the content-addressed store, hash-verified

3494 /// @param history - Optional conversation history
3495 #[napi]
3496 pub async fn stream_with_attachments(
3497 &self,
3498 prompt: String,
3499 attachments: Vec<AttachmentObject>,
3500 history: Option<Vec<MessageObject>>,
3501 ) -> napi::Result<EventStream> {
3502 let rust_attachments = js_attachments_to_rust(&attachments);
3503 let rust_history = history.map(|h| js_messages_to_rust(&h)).transpose()?;
3504 let session = self.inner.clone();
3505 let (rx, _handle) = get_runtime()
3506 .spawn(async move {
3507 session
3508 .stream_with_attachments(&prompt, &rust_attachments, rust_history.as_deref())
3509 .await
3510 })
3511 .await
3512 .map_err(|e| napi::Error::from_reason(format!("Task join error: {e}")))?
3513 .map_err(|e| napi::Error::from_reason(format!("Failed to start stream: {e}")))?;
3514 Ok(EventStream {
3515 rx: Arc::new(tokio::sync::Mutex::new(rx)),
3516 done: Arc::new(AtomicBool::new(false)),
3517 })
3518 }
3519
3520 /// Return the session's conversation history.
3521 #[napi]

Callers 1

stream_session_requestFunction · 0.45

Calls 5

js_attachments_to_rustFunction · 0.85
js_messages_to_rustFunction · 0.85
get_runtimeFunction · 0.70
cloneMethod · 0.45
spawnMethod · 0.45

Tested by

no test coverage detected