Skip to main content

run_tools_loop

Function run_tools_loop 

Source
pub async fn run_tools_loop(
    client: &Client,
    url: &str,
    provider: &str,
    api_key: &str,
    req: &CloudAiRequest,
    tools: &[ToolSpec],
    dispatcher: &dyn ToolDispatcher,
    max_iters: usize,
) -> Result<CloudAiResponse, CloudAiError>
Expand description

Run the OpenAI-compatible tool-use loop: expose tools, and on each turn, if the model requests tool calls, run them through dispatcher, append the results, and re-call - until the model answers without tool calls (returned as the CloudAiResponse) or max_iters is exhausted. api_key empty means no bearer header (local servers). Non-streaming: tool-call deltas don’t reassemble cleanly over SSE.