Documentation
¶
Overview ¶
Package tools provides implementations for executing tools as part of MindTrial's function calling capabilities.
Index ¶
- Variables
- type DockerTool
- type DockerToolExecutor
- func (d *DockerToolExecutor) Close() error
- func (d *DockerToolExecutor) ExecuteTool(ctx context.Context, logger logging.Logger, toolName string, ...) (json.RawMessage, error)
- func (d *DockerToolExecutor) GetUsageStats() map[string]ToolUsage
- func (d *DockerToolExecutor) RegisterTool(tool *DockerTool)
- func (d *DockerToolExecutor) ValidateTool(ctx context.Context, cfg config.ToolConfig) error
- type TextOrData
- type ToolUsage
Constants ¶
This section is empty.
Variables ¶
var ( // ErrToolNotAvailable is returned when a requested tool is not available. ErrToolNotAvailable = errors.New("tool not available") // ErrToolExecutionFailed is returned when a tool executes but fails with an error. ErrToolExecutionFailed = errors.New("tool execution failed") // ErrInvalidToolArguments is returned when tool arguments are invalid or don't match the expected schema. ErrInvalidToolArguments = errors.New("invalid tool arguments") // ErrToolInternal is returned for low-level internal errors during tool execution. ErrToolInternal = errors.New("tool internal error") // ErrUnsupportedToolType is returned when an unsupported tool type is encountered. ErrUnsupportedToolType = errors.New("unsupported tool type") // ErrToolMaxCallsExceeded is returned when a tool has exceeded its maximum call limit. ErrToolMaxCallsExceeded = errors.New("tool max calls exceeded") // ErrToolTimeout is returned when a tool execution times out. ErrToolTimeout = errors.New("tool execution timeout") )
Functions ¶
This section is empty.
Types ¶
type DockerTool ¶
type DockerTool struct {
// contains filtered or unexported fields
}
func NewDockerTool ¶
func NewDockerTool(cfg *config.ToolConfig, maxCalls *int, timeout *time.Duration, maxMemoryMB *int, cpuPercent *int) *DockerTool
NewDockerTool creates a new Docker tool.
type DockerToolExecutor ¶
type DockerToolExecutor struct {
// contains filtered or unexported fields
}
DockerToolExecutor executes tools within Docker containers.
func NewDockerToolExecutor ¶
func NewDockerToolExecutor(ctx context.Context) (*DockerToolExecutor, error)
NewDockerToolExecutor creates a new Docker tool executor.
func (*DockerToolExecutor) Close ¶
func (d *DockerToolExecutor) Close() error
Close closes the Docker client connection and cleans up shared directories.
func (*DockerToolExecutor) ExecuteTool ¶
func (d *DockerToolExecutor) ExecuteTool(ctx context.Context, logger logging.Logger, toolName string, args json.RawMessage, data map[string][]byte) (json.RawMessage, error)
ExecuteTool executes a tool by name with the given arguments and auxiliary data files.
func (*DockerToolExecutor) GetUsageStats ¶
func (d *DockerToolExecutor) GetUsageStats() map[string]ToolUsage
GetUsageStats returns usage statistics for all tools.
func (*DockerToolExecutor) RegisterTool ¶
func (d *DockerToolExecutor) RegisterTool(tool *DockerTool)
RegisterTool registers a tool with the executor.
func (*DockerToolExecutor) ValidateTool ¶ added in v0.12.1
func (d *DockerToolExecutor) ValidateTool(ctx context.Context, cfg config.ToolConfig) error
ValidateTool ensures the Docker image referenced by the tool configuration is available locally.
type TextOrData ¶ added in v0.12.0
TextOrData is a constraint for types that can be written to files.