View Source Jido.Workflow.Tool (Jido v1.0.0)
Provides functionality to convert Jido Workflows into tool representations.
This module allows Jido Workflows to be easily integrated with AI systems like LangChain or Instructor by converting them into a standardized tool format.
Summary
Functions
Builds a parameters schema for the tool based on the workflow's schema.
Executes an workflow and formats the result for tool output.
Converts a NimbleOptions type to a JSON Schema type.
Converts a NimbleOptions parameter definition to a JSON Schema representation.
Converts a Jido Workflow into a tool representation.
Types
Functions
Builds a parameters schema for the tool based on the workflow's schema.
Arguments
schema
- The NimbleOptions schema from the workflow.
Returns
A map representing the parameters schema in a format compatible with LangChain.
Executes an workflow and formats the result for tool output.
This function is typically used as the function value in the tool representation.
Converts a NimbleOptions type to a JSON Schema type.
Arguments
type
- The NimbleOptions type.
Returns
A string representing the equivalent JSON Schema type.
Converts a NimbleOptions parameter definition to a JSON Schema representation.
Arguments
opts
- The options for a single parameter from the NimbleOptions schema.
Returns
A map representing the parameter in JSON Schema format.
Converts a Jido Workflow into a tool representation.
Arguments
workflow
- The module implementing the Jido.Action behavior.
Returns
A map representing the workflow as a tool, compatible with systems like LangChain.
Examples
iex> tool = Jido.Workflow.Tool.to_tool(MyWorkflow)
%{
name: "my_workflow",
description: "Performs a specific task",
function: #Function<...>,
parameters_schema: %{...}
}