Skip to main content

objectiveai_sdk/functions/executions/
http.rs

1//! HTTP functions for function executions.
2
3use crate::{HttpClient, HttpError, McpHandler, Notifier};
4use futures::Stream;
5
6/// Creates a function execution (non-streaming).
7pub async fn create_function_execution_unary(
8    client: &HttpClient,
9    mut params: super::request::FunctionExecutionCreateParams,
10) -> Result<super::response::unary::FunctionExecution, HttpError> {
11    params.stream = None;
12    client
13        .send_unary(reqwest::Method::POST, "functions/executions", Some(params))
14        .await
15}
16
17/// Creates a streaming function execution. Returns
18/// `(Stream<Chunk>, Notifier)`; see
19/// [`crate::agent::completions::http::create_agent_completion_streaming`]
20/// for the demux + handler semantics.
21pub async fn create_function_execution_streaming<H: McpHandler>(
22    client: &HttpClient,
23    mut params: super::request::FunctionExecutionCreateParams,
24    handler: H,
25) -> Result<
26    (
27        impl Stream<
28            Item = Result<
29                super::response::streaming::FunctionExecutionChunk,
30                HttpError,
31            >,
32        >
33        + Send
34        + Unpin
35        + 'static
36        + use<H>,
37        Notifier,
38    ),
39    HttpError,
40> {
41    params.stream = Some(true);
42    client
43        .send_streaming_ws(
44            reqwest::Method::POST,
45            "functions/executions",
46            params,
47            handler,
48        )
49        .await
50}