Jido.AI.Actions.OpenaiEx.ToolHelper (Jido AI v0.5.2)
View SourceHelper module for handling tool calling with OpenAiEx. Provides functions to convert Jido.Action to OpenAI tool format and handle tool responses.
Summary
Functions
Handles a tool call response from OpenAI. Executes the appropriate action with the given parameters.
Processes a chat completion response that may contain tool calls. If tool calls are present, executes them and returns the results.
Converts a list of Jido.Action modules to OpenAI tool format. Each action must implement the Jido.Action.Tool protocol.
Functions
Handles a tool call response from OpenAI. Executes the appropriate action with the given parameters.
Parameters
- tool_call: The tool call object from OpenAI response
- available_actions: List of available Jido.Action modules
Returns
{:ok, result}
- where result is the output of the action{:error, reason}
- if the tool call cannot be handled
Processes a chat completion response that may contain tool calls. If tool calls are present, executes them and returns the results.
Parameters
- response: The chat completion response from OpenAI
- available_actions: List of available Jido.Action modules
Returns
{:ok, %{content: content, tool_results: results}}
- where content is the assistant's message{:error, reason}
- if tool calls cannot be processed
Converts a list of Jido.Action modules to OpenAI tool format. Each action must implement the Jido.Action.Tool protocol.
Parameters
- actions: List of Jido.Action modules that implement Jido.Action.Tool
Returns
{:ok, tools}
- where tools is a list of OpenAI tool specifications{:error, reason}
- if any action doesn't implement the protocol