tools

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReflectTool

type ReflectTool struct {
	*ToolImpl
	// contains filtered or unexported fields
}

ReflectTool is a Tool implementation that uses reflection to create a tool from a Go function

func NewReflectTool

func NewReflectTool(name string, description string, fn interface{}) (*ReflectTool, error)

NewReflectTool creates a new ReflectTool from a function

func (*ReflectTool) Call

func (t *ReflectTool) Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)

Call implements the Tool interface by using reflection to call the underlying function

type Tool

type Tool interface {
	GetName() string
	GetDescription() string
	GetInputSchema() json.RawMessage
	GetToolDefinition() protocol.Tool
	Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)
}

Tool represents a tool that can be invoked

type ToolImpl

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

ToolImpl is a basic implementation of the Tool interface

func NewToolImpl

func NewToolImpl(name, description string, inputSchema interface{}) (*ToolImpl, error)

NewToolImpl creates a new ToolImpl with the given parameters

func (*ToolImpl) Call

func (t *ToolImpl) Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)

Call implements the Tool interface but panics as it should be overridden

func (*ToolImpl) GetDescription

func (t *ToolImpl) GetDescription() string

GetDescription returns the tool's description

func (*ToolImpl) GetInputSchema

func (t *ToolImpl) GetInputSchema() json.RawMessage

GetInputSchema returns the tool's input schema

func (*ToolImpl) GetName

func (t *ToolImpl) GetName() string

GetName returns the tool's name

func (*ToolImpl) GetToolDefinition

func (t *ToolImpl) GetToolDefinition() protocol.Tool

GetToolDefinition returns the tool's definition

func (*ToolImpl) MarshalJSON

func (t *ToolImpl) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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