Pipeline.Tools.Tool behaviour (pipeline v0.0.1)

View Source

Base behavior for pipeline tools that can be called by LLMs.

Tools define functions that can be executed by AI models during conversations. Each tool should implement this behavior to provide consistent interface.

Summary

Callbacks

Executes the tool with the given arguments. Returns {:ok, result} on success or {:error, reason} on failure.

Returns the tool definition including name, description, and parameters schema. This is used by LLM adapters to register the tool with the AI service.

Returns the platforms/configurations this tool supports. Used for tool discovery and validation.

Validates that the tool can run in the current environment. Returns :ok if valid, {:error, reason} if not.

Callbacks

execute(args)

@callback execute(args :: map()) :: {:ok, any()} | {:error, any()}

Executes the tool with the given arguments. Returns {:ok, result} on success or {:error, reason} on failure.

get_definition()

@callback get_definition() :: %{
  name: String.t(),
  description: String.t(),
  parameters: map()
}

Returns the tool definition including name, description, and parameters schema. This is used by LLM adapters to register the tool with the AI service.

supported_platforms()

(optional)
@callback supported_platforms() :: [String.t()]

Returns the platforms/configurations this tool supports. Used for tool discovery and validation.

validate_environment()

(optional)
@callback validate_environment() :: :ok | {:error, String.t()}

Validates that the tool can run in the current environment. Returns :ok if valid, {:error, reason} if not.