toolkit

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatResult

func FormatResult(result interface{}) (string, error)

FormatResult formats a tool execution result as JSON string

func ParseArguments

func ParseArguments(argsJSON string) (map[string]interface{}, error)

ParseArguments parses JSON arguments string into a map

func ToModelToolDefinitions

func ToModelToolDefinitions(toolkits []Toolkit) []models.ToolDefinition

ToModelToolDefinitions converts toolkit functions to model tool definitions

Types

type BaseToolkit

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

BaseToolkit provides common functionality for toolkit implementations

func NewBaseToolkit

func NewBaseToolkit(name string) *BaseToolkit

NewBaseToolkit creates a new base toolkit

func (*BaseToolkit) Execute

func (t *BaseToolkit) Execute(ctx context.Context, fnName string, args map[string]interface{}) (interface{}, error)

Execute calls a function by name with the given arguments

func (*BaseToolkit) Functions

func (t *BaseToolkit) Functions() map[string]*Function

Functions returns all functions

func (*BaseToolkit) Name

func (t *BaseToolkit) Name() string

Name returns the toolkit name

func (*BaseToolkit) RegisterFunction

func (t *BaseToolkit) RegisterFunction(fn *Function)

RegisterFunction registers a new function to the toolkit

type Function

type Function struct {
	Name        string
	Description string
	Parameters  map[string]Parameter
	Handler     HandlerFunc
}

Function represents a callable tool function

type HandlerFunc

type HandlerFunc func(ctx context.Context, args map[string]interface{}) (interface{}, error)

HandlerFunc is the function signature for tool handlers

type Parameter

type Parameter struct {
	Type        string      `json:"type"`
	Description string      `json:"description,omitempty"`
	Required    bool        `json:"required,omitempty"`
	Enum        []string    `json:"enum,omitempty"`
	Default     interface{} `json:"default,omitempty"`
	Items       *Parameter  `json:"items,omitempty"` // For array types: defines the type of array elements
}

Parameter defines a function parameter

type Toolkit

type Toolkit interface {
	// Name returns the toolkit name
	Name() string

	// Functions returns all available functions in this toolkit
	Functions() map[string]*Function
}

Toolkit defines the interface for a collection of tools

Jump to

Keyboard shortcuts

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