tools

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AskDesc = "" /* 339-byte string literal not displayed */

Variables

This section is empty.

Functions

func Asking

func Asking[I any, O any](f func(input I, reply common.Answer[O]) api.ChatAsk) func(ctx context.Context, input I) (O, error)

func Attach

func Attach(ctx context.Context, source context.Context) context.Context

func FromAgent

func FromAgent(ctx context.Context) bool

func FromJS

func FromJS(ctx context.Context) bool

func NewRawTool

func NewRawTool(
	name string,
	desc string,
	inputSchema schema.Schema[any],
	outputSchema schema.Schema[any],
	f func(ctx context.Context, input json.RawMessage) (any, error),
) (tool, error)

func NewTool

func NewTool[I any, O any](name string, desc string, f func(ctx context.Context, input I) (O, error)) (common.Tool, error)

Types

type Module

type Module = *module

func NewModule

func NewModule(name string, desc string) Module

func (Module) Add

func (m Module) Add[I any, O any](name string, desc string, f func(ctx context.Context, input I) (O, error)) (ToolID, error)

func (Module) AddRaw

func (m Module) AddRaw(
	name string,
	desc string,
	input schema.Schema[any],
	output schema.Schema[any],
	f func(ctx context.Context, input json.RawMessage) (any, error),
) (ToolID, error)

func (Module) AddTool

func (m Module) AddTool(tool common.Tool) ToolID

func (Module) Ask

func (m Module) Ask[I any, O any](name string, desc string, f func(input I, reply common.Answer[O]) api.ChatAsk) (ToolID, error)

func (Module) Desc

func (m Module) Desc() string

func (Module) Get

func (m Module) Get(name string) (common.Tool, bool)

func (Module) List

func (m Module) List() []common.Tool

func (Module) Name

func (m Module) Name() string

func (Module) Remove

func (m Module) Remove(id ToolID)

type ToolID

type ToolID int

ToolID identifies a tool within its own module, for Remove. A module numbers the tools it is given from 1, so an ID is only meaningful against the module that issued it.

Jump to

Keyboard shortcuts

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