tool

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToOpenAITool

func ToOpenAITool(tool Tool) map[string]interface{}

ToOpenAITool converts a Tool to the OpenAI tool format

func ToOpenAITools

func ToOpenAITools(tools []Tool) []map[string]interface{}

ToOpenAITools converts a slice of Tools to the OpenAI tool format

Types

type FunctionTool

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

FunctionTool is a tool implemented as a Go function

func NewFunctionTool

func NewFunctionTool(name, description string, fn interface{}) *FunctionTool

NewFunctionTool creates a new function tool

func (*FunctionTool) Execute

func (t *FunctionTool) Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)

Execute executes the tool with the given parameters

func (*FunctionTool) GetDescription

func (t *FunctionTool) GetDescription() string

GetDescription returns the description of the tool

func (*FunctionTool) GetName

func (t *FunctionTool) GetName() string

GetName returns the name of the tool

func (*FunctionTool) GetParametersSchema

func (t *FunctionTool) GetParametersSchema() map[string]interface{}

GetParametersSchema returns the JSON schema for the tool parameters

func (*FunctionTool) WithDescription

func (t *FunctionTool) WithDescription(description string) *FunctionTool

WithDescription updates the description of the tool

func (*FunctionTool) WithName

func (t *FunctionTool) WithName(name string) *FunctionTool

WithName updates the name of the tool

func (*FunctionTool) WithSchema

func (t *FunctionTool) WithSchema(schema map[string]interface{}) *FunctionTool

WithSchema sets a custom schema for the tool parameters

type Tool

type Tool interface {
	// GetName returns the name of the tool
	GetName() string

	// GetDescription returns the description of the tool
	GetDescription() string

	// GetParametersSchema returns the JSON schema for the tool parameters
	GetParametersSchema() map[string]interface{}

	// Execute executes the tool with the given parameters
	Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)
}

Tool represents a capability that can be used by an agent

func CreateToolFromDefinition

func CreateToolFromDefinition(definition map[string]interface{}, executeFn func(map[string]interface{}) (interface{}, error)) Tool

CreateToolFromDefinition creates a Tool from an OpenAI tool definition

Jump to

Keyboard shortcuts

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