tool

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig config
View Source
var NilTool = &Tool{
	Name:        "nil",
	Description: "nil tool",
	Kind:        "code",
	Invokex: func(ctx context.Context, args map[string]any) (string, error) {
		return "", fmt.Errorf("not implement")
	},
}

Functions

func Register

func Register(t *Tool)

Register 注册工具

func WithConfig

func WithConfig(c map[string]any) error

func WithRepo

func WithRepo(repo Repo)

WithRepo ...

Types

type Event

type Event struct {
	Name string
	Type string
	Data any
}

Event 事件

type Factory

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

Factory 工具工厂

func NewFactory

func NewFactory(repo Repo) *Factory

NewFactory ...

func (*Factory) Spawn

func (f *Factory) Spawn(name string) *Tool

Spawn ...

type Option added in v0.0.9

type Option func(*Tool)

func WithDescription added in v0.0.9

func WithDescription(description string) Option

func WithFunction added in v0.0.9

func WithFunction(function func(ctx context.Context, args map[string]any) (string, error)) Option

func WithKind added in v0.0.9

func WithKind(kind string) Option

func WithName added in v0.0.9

func WithName(name string) Option

func WithParameters added in v0.0.9

func WithParameters(parameters []Parameter) Option

type Parameter

type Parameter struct {
	Name             string
	Label            string
	HumanDescription string
	Placeholder      string
	Type             ParameterType
	LLMDescrition    string
	Required         bool
	Default          any
	Min              float64
	Max              float64
	Options          []string
}

Parameter 用于描述API参数的结构体

type ParameterType

type ParameterType string

ParameterType 枚举类型

const (
	Array       ParameterType = "array"
	String      ParameterType = "string"
	Number      ParameterType = "number"
	Boolean     ParameterType = "boolean"
	Select      ParameterType = "select"
	SecretInput ParameterType = "secret-input"
	File        ParameterType = "file"
)

type Repo

type Repo interface {
}

Repo 工具仓库

type Tool

type Tool struct {
	ID          int64  // 引用的工具ID
	Kind        string // 引用的工具类型
	Name        string
	Description string
	Parameters  []Parameter `json:"parameters,omitempty"` // 参数,可选

	AuthenticationType  string
	AuthenticationValue string
	ServerURL           string `json:"server_url"` // 服务器URL
	Method              string `json:"method"`     // 方法
	Body                string `json:"body"`       // body

	Invokex func(context.Context, map[string]any) (string, error)
}

func New added in v0.0.9

func New(opts ...Option) *Tool

func Spawn

func Spawn(name string) *Tool

Spawn ...

func (*Tool) Invoke

func (t *Tool) Invoke(ctx context.Context, params map[string]any) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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