tools

package
v0.14.108 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tools defines the Tool interface for LLM agents, including registration, parameter schema, and MCP integration. Tools enable agents to interact with external systems and APIs in a structured, extensible way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDescriptions

func GetDescriptions(list ...ITool) string

Types

type Callback

type Callback interface {
	OnToolStart(ctx context.Context, tool ITool, assistantName, input string)
	OnToolEnd(ctx context.Context, tool ITool, assistantName, input string, output string)
	OnToolError(ctx context.Context, tool ITool, assistantName, input string, err error)
}

type IMCPTool added in v0.1.9

type IMCPTool interface {
	ITool
	RegisterMCP(registrator McpServerRegistrator) error
}

IMCPTool is an interface that extends ITool to include functionality for registering the tool with an MCP server. The RegisterMCP method allows the tool to be registered with a given MCP Server.

type ITool

type ITool interface {
	// Name returns the name of the Tool.
	Name() string
	// Description returns the description of the tool, to be used in the prompt.
	// Should not exceed LLM model limit.
	Description() string
	// Parameters returns the parameters definition of the function, to be used in the prompt.
	Parameters() *jsonschema.Schema

	// Call executes the tool with the given input and returns the result.
	// If the tool fails to parse the input, it should return ErrFailedUnmarshalInput error.
	Call(context.Context, string) (string, error)
}

ITool is a tool for the llm agent to interact with different applications.

type MCPTool added in v0.1.9

type MCPTool[I any] interface {
	IMCPTool
	RunMCP(context.Context, *I) (*mcp.ToolResponse, error)
}

type McpServerRegistrator added in v0.1.9

type McpServerRegistrator interface {
	RegisterTool(name string, description string, handler any) error
}

type Tool

type Tool[I any, O any] interface {
	ITool
	Run(context.Context, *I) (*O, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL