View Source LlmComposer.FunctionExecutor (llm_composer v0.13.0)

Provides manual execution of function calls from LLM responses.

This module allows users to explicitly execute individual function calls returned by the LLM, without automatic execution. It's designed for manual control over function invocation and result handling.

Usage

After receiving a response with function calls, use execute/2 to manually execute each function call with its arguments parsed and validated before invocation.

Summary

Functions

Executes a single function call and returns the updated FunctionCall with result.

Functions

Link to this function

execute(function_call, functions)

View Source
@spec execute(LlmComposer.FunctionCall.t(), [LlmComposer.Function.t()]) ::
  {:ok, LlmComposer.FunctionCall.t()} | {:error, term()}

Executes a single function call and returns the updated FunctionCall with result.

Parameters

  • function_call: The FunctionCall struct to execute
  • functions: List of Function definitions available for execution

Returns

  • {:ok, executed_call}: FunctionCall with result populated
  • {:error, reason}: Error tuple if execution fails

Possible Errors

  • {:error, :function_not_found}: Named function not in definitions
  • {:error, {:invalid_arguments, reason}}: Failed to parse JSON arguments
  • {:error, {:execution_failed, reason}}: Exception during function execution