tool

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 6 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

View Source
const (
	// OutputToolName is the well-known name for the structured output tool.
	OutputToolName = "submit_output"

	// OutputToolInstruction is appended to the system prompt when the
	// output tool is active, directing the model to call it with the final answer.
	OutputToolInstruction = "Use available tools to gather information. When ready, only call " + OutputToolName + " with your final answer, do not output any other text."
)

Variables

This section is empty.

Functions

func WithNamespace

func WithNamespace(namespace string, t llm.Tool) llm.Tool

WithNamespace returns t with its name replaced by "namespace.t.Name()".

Types

type Base

type Base struct{}

Base provides default no-op implementations of the optional llm.Tool methods. Embed Base in your tool struct to avoid boilerplate; then only override the methods you need.

func (Base) Meta

func (Base) Meta() llm.ToolMeta

Meta returns a zero-value ToolMeta (no hints set).

func (Base) OutputSchema

func (Base) OutputSchema() *jsonschema.Schema

OutputSchema returns nil, indicating no structured output schema.

type OutputTool

type OutputTool struct {
	Base
	// contains filtered or unexported fields
}

OutputTool wraps a JSON schema as a tool, allowing the model to produce structured output by "calling" this tool with the desired data. This avoids the conflict in providers like Gemini that don't support function calling combined with a response JSON schema.

func NewOutputTool

func NewOutputTool(s *jsonschema.Schema) *OutputTool

NewOutputTool creates a tool whose parameter schema is the given JSON schema. When the model calls this tool, its arguments ARE the structured output.

func (*OutputTool) Description

func (t *OutputTool) Description() string

func (*OutputTool) InputSchema

func (t *OutputTool) InputSchema() *jsonschema.Schema

func (*OutputTool) Name

func (t *OutputTool) Name() string

func (*OutputTool) Run

func (t *OutputTool) Run(_ context.Context, input json.RawMessage) (any, error)

func (*OutputTool) Validate

func (t *OutputTool) Validate(data json.RawMessage) error

Validate checks that the given JSON conforms to the output schema. Returns nil if the data is valid or no schema was provided.

Jump to

Keyboard shortcuts

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