tools

package
v0.17.134 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 7 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

This section is empty.

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 Description added in v0.17.134

type Description struct {
	Name        string `json:"Name" yaml:"Name"`
	Description string `json:"Description" yaml:"Description"`
}

type Descriptions added in v0.17.134

type Descriptions []Description

func GetDescriptions

func GetDescriptions(list ...ITool) Descriptions

func (Descriptions) Render added in v0.17.134

func (d Descriptions) Render(format llmutils.RenderFormat) string

func (Descriptions) ToMarkdown added in v0.17.134

func (d Descriptions) ToMarkdown() string

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