Skip to main content

execute_function_calls_with_callback

Macro execute_function_calls_with_callback 

Source
execute_function_calls_with_callback!() { /* proc-macro */ }
Expand description

Macro to execute function calls requested by Gemini and update the session history, with a custom callback for results.

§Usage

execute_function_calls_with_callback!(session, callback, function1, function2, ...)

The callback should be a closure or function that takes (String, Result<serde_json::Value, String>) and returns serde_json::Value. (function_name, result) is passed to it

§Returns

A Vec<Option<Result<serde_json::Value, String>>> containing the results of each function call.

  • Some(Ok(value)) if the function was called and succeeded.
  • Some(Err(err)) if the function was called but failed.
  • None if the function was not called.

§Note

The session is automatically updated with the FunctionResponse. The callback is invoked with the result of the function execution (whether Ok or Err) and its return value is used to update the session.