functions

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 13 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)

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 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) 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

Jump to

Keyboard shortcuts

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