tool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithToolkit added in v0.1.0

func WithToolkit(toolkit *Toolkit) opt.Opt

WithToolkit sets a toolkit for generation options. The toolkit is stored under opt.ToolkitKey and can be retrieved with opts.Get(opt.ToolkitKey) and type-asserted to *Toolkit.

Types

type Tool added in v0.1.0

type Tool interface {
	// Return the name of the tool
	Name() string

	// Return the description of the tool
	Description() string

	// Return the JSON schema for the tool input
	Schema() (*jsonschema.Schema, error)

	// Run the tool with the given input as JSON (may be nil)
	Run(ctx context.Context, input json.RawMessage) (any, error)
}

Tool is an interface for a tool with a name, description and JSON schema

type Toolkit added in v0.1.0

type Toolkit struct {
	// contains filtered or unexported fields
}

Toolkit is a collection of tools with unique names

func NewToolkit added in v0.1.0

func NewToolkit(tools ...Tool) (*Toolkit, error)

NewToolkit creates a new toolkit with the given tools. Returns an error if any tool has an invalid or duplicate name.

func (*Toolkit) Feedback added in v0.1.0

func (tk *Toolkit) Feedback(call schema.ToolCall) string

Feedback returns a human-readable description of a tool call, including the tool name and its description when available.

func (*Toolkit) Lookup added in v0.1.0

func (tk *Toolkit) Lookup(name string) Tool

Lookup returns a tool by name, or nil if not found

func (*Toolkit) Register added in v0.1.0

func (tk *Toolkit) Register(tools ...Tool) error

Register adds one or more tools to the toolkit. Returns an error if any tool has an invalid or duplicate name.

func (*Toolkit) Run added in v0.1.0

func (tk *Toolkit) Run(ctx context.Context, name string, input any) (any, error)

Run executes a tool by name with the given input. The input should be json.RawMessage or nil. Returns an error if the tool is not found, the input does not match the schema, or the tool execution fails.

func (*Toolkit) String added in v0.1.0

func (tk *Toolkit) String() string

func (*Toolkit) Tools added in v0.1.0

func (tk *Toolkit) Tools() []Tool

Tools returns all tools in the toolkit

Jump to

Keyboard shortcuts

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