MCPcopy Create free account
hub / github.com/AI45Lab/Code / send_request

Method send_request

sdk/python/src/lib.rs:1680–1700  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 7

block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45
is_emptyMethod · 0.45
sendMethod · 0.45
send_with_attachmentsMethod · 0.45

Tested by

no test coverage detected