functions

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StaticFunctionMap = make(map[string]ToolFunc)

Functions

func IsImplementationAvailable

func IsImplementationAvailable(implKey string) bool

IsImplementationAvailable checks if a function implementation exists

func RegisterFunction

func RegisterFunction(implKey string, fn ToolFunc)

RegisterFunction allows runtime registration of functions (optional feature)

func WithWriteMode added in v0.6.0

func WithWriteMode(ctx context.Context, mode WriteMode) context.Context

WithWriteMode returns a context in which content functions use mode.

Types

type FunctionDefinition

type FunctionDefinition struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Parameters  any    `json:"parameters"`
}

FunctionDefinition defines a function that can be called by the LLM

type Info added in v0.5.0

type Info struct {
	ImplKey     string         `json:"impl_key"`
	Description string         `json:"description"`
	Parameters  models.JSONMap `json:"parameters"`
	// Scoped: the function accepts a "collections" scope.
	Scoped bool `json:"scoped"`
}

Info describes a built-in function for people configuring agents: what it does and the JSON schema of its arguments, ready to use as a function's "parameters".

func Catalog added in v0.5.0

func Catalog() []Info

Catalog lists the built-in functions that can be used as impl_key, sorted. Functions registered without catalog entry are listed with an empty argument schema.

type Registry

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

Registry maps a tool's name to its executable function.

func NewRegistry

func NewRegistry(agentFuncs agentModels.FunctionSpecs) *Registry

NewRegistry creates a new tool registry from a list of agent function specs.

func (*Registry) Get

func (r *Registry) Get(name string) (ToolFunc, bool)

Get returns the executable function for a given tool name.

func (*Registry) ImplKey added in v0.5.0

func (r *Registry) ImplKey(name string) string

ImplKey returns the implementation key of a registered tool.

func (*Registry) ListFunctions

func (r *Registry) ListFunctions() []string

ListFunctions returns a list of registered function names (for debugging)

func (*Registry) ToLangchainTools

func (r *Registry) ToLangchainTools() []llms.Tool

ToLangchainTools converts the registry to langchain-compatible []llms.Tool

type RegistryTool

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

RegistryTool implements langchain's tools.Tool interface

func (*RegistryTool) Call

func (t *RegistryTool) Call(ctx context.Context, input string) (string, error)

Call executes the tool function (implements tools.Tool interface)

func (*RegistryTool) Description

func (t *RegistryTool) Description() string

Description returns the tool description (implements tools.Tool interface)

func (*RegistryTool) Name

func (t *RegistryTool) Name() string

Name returns the tool name (implements tools.Tool interface)

type ToolFunc

type ToolFunc func(ctx context.Context, args any) (string, error)

ToolFunc is a function that executes a tool.

type ToolSpec

type ToolSpec struct {
	Type     string              `json:"type"`
	Function *FunctionDefinition `json:"function"`
}

ToolSpec represents a function specification for the LLM

type WriteMode added in v0.6.0

type WriteMode int

WriteMode is how content functions handle writes in a run.

const (
	// WriteLive applies writes.
	WriteLive WriteMode = iota
	// WriteDryRun validates writes and reports what they would do, without
	// writing anything (test runs).
	WriteDryRun
	// WritePropose validates writes and stores them as proposals an editor
	// approves (agents with require_approval).
	WritePropose
)

Jump to

Keyboard shortcuts

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