tools

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tools defines a standard interface for tools to be used by agents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculator

type Calculator struct {
	CallbacksHandler callbacks.Handler
}

Calculator is a tool that can do math.

func (Calculator) Call

func (c Calculator) Call(ctx context.Context, input string) (string, error)

Call evaluates the input using a starlak evaluator and returns the result as a string. If the evaluator errors the error is given in the result to give the agent the ability to retry.

func (Calculator) Description

func (c Calculator) Description() string

Description returns a string describing the calculator tool.

func (Calculator) Name

func (c Calculator) Name() string

Name returns the name of the tool.

type InjectedToolArg added in v1.5.3

type InjectedToolArg struct {
	Value any
}

InjectedToolArg is a marker type for tool arguments that are injected at runtime rather than supplied by the model. It mirrors langchain_core.tools.InjectedToolArg. Declaring a parameter of this type in a tool's schema tells the model to ignore it, and the runtime fills it in.

type InjectedToolCallID added in v1.5.3

type InjectedToolCallID struct {
	Value string
}

InjectedToolCallID is a marker type for the ID of the tool call being executed, injected at runtime. It mirrors langchain_core.tools.InjectedToolCallId.

type Tool

type Tool interface {
	Name() string
	Description() string
	Call(ctx context.Context, input string) (string, error)
}

Tool is a tool for the llm agent to interact with different applications.

func InjectArgs added in v1.5.3

func InjectArgs(tool Tool, args map[string]any) Tool

InjectArgs wraps a tool so that the provided arguments are injected into its JSON input before execution.

func InjectID added in v1.5.3

func InjectID(tool Tool, getID func() string) Tool

InjectID wraps a tool so that the invoking tool call ID is injected into its input. The input is expected to be JSON; the "tool_call_id" field is set (or replaced) with the given ID.

type ToolCallContext added in v1.5.3

type ToolCallContext struct {
	// CallID is the ID of the tool call that is being executed.
	CallID string
	// Args holds injected arguments keyed by name.
	Args map[string]any
}

ToolCallContext carries the runtime-injected values available to a tool call.

func (ToolCallContext) GetInjectedArg added in v1.5.3

func (c ToolCallContext) GetInjectedArg(name string) (any, bool)

GetInjectedArg returns the injected argument for name, if present.

Directories

Path Synopsis
Package duckduckgo contains an implementation of the tool interface with the duckduckgo api client.
Package duckduckgo contains an implementation of the tool interface with the duckduckgo api client.
// Package metaphor contains an implementation of the tool interface with the metaphor search api client.
// Package metaphor contains an implementation of the tool interface with the metaphor search api client.
Package perplexity provides integration with Perplexity AI's API for AI agents.
Package perplexity provides integration with Perplexity AI's API for AI agents.
Package scraper contains an implementation of the tool interface for a web scraping tool.
Package scraper contains an implementation of the tool interface for a web scraping tool.
Package serpapi contains an implementation of the tool interface with the serapi.
Package serpapi contains an implementation of the tool interface with the serapi.
Package wikipedia contains an implementation of the tool interface with the wikipedia api.
Package wikipedia contains an implementation of the tool interface with the wikipedia api.
Package zapier contains an implementation of the tool interface with the zapier NLA api client.
Package zapier contains an implementation of the tool interface with the zapier NLA api client.

Jump to

Keyboard shortcuts

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