tools

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineProviders added in v0.0.9

func CombineProviders(providers ...pkg.ToolProvider) pkg.ToolProvider

CombineProviders creates a new provider that combines multiple providers

Types

type CombinedProvider added in v0.0.9

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

CombinedProvider implements the ToolProvider interface by combining multiple providers

func (*CombinedProvider) CallTool added in v0.0.9

func (cp *CombinedProvider) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)

CallTool implements the ToolProvider interface by trying each provider in order

func (*CombinedProvider) ListTools added in v0.0.9

func (cp *CombinedProvider) ListTools(ctx context.Context, cursor string) ([]protocol.Tool, string, error)

ListTools implements the ToolProvider interface by combining results from all providers

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