tool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Description = opts.ForName[Definition, string]("Description")

Description returns a function that sets the description of an agent function. It takes a string parameter 'description' and returns a function that modifies the 'Description' field of the provided 'agentFunctionOptions' struct.

View Source
var Name = opts.ForName[Definition, string]("Name")

Name returns a function that sets the Name field of agentFunctionOptions to the provided name. This can be used to configure an agent function with a specific name.

Parameters:

  • name: A string representing the name to be assigned.

Returns:

  • A function that takes a pointer to agentFunctionOptions and sets its Name field.

Functions

func Parameters

func Parameters(parameters ...string) opts.Option[Definition]

Parameters returns a function that sets the Parameters field of agentFunctionOptions to a map where each parameter is assigned a key in the format "paramN", where N is the index of the parameter in the input slice.

Parameters:

parameters - a variadic string slice containing the parameters to be set.

Returns:

A function that takes a pointer to agentFunctionOptions and sets its Parameters field.

Types

type Definition

type Definition struct {
	Name        string
	Description string
	Parameters  map[string]string
	Function    any
}

Definition represents the definition of an agent function. It includes the function's name, description, parameters, and the function itself.

func Must

func Must(f any, options ...Option) Definition

Must wraps the AgentTool call and ensures that any error returned by AgentTool is handled by panicking. It takes a function `f` and a variadic number of AgentToolOption `options` as arguments, and returns an AgentToolDefinition. If AgentTool returns an error, Must will panic.

Parameters:

  • f: The function to be wrapped.
  • options: A variadic number of options to configure the agent tool.

Returns:

  • ToolDefinition: The definition of the agent tool.

func New

func New(f any, options ...Option) (Definition, error)

New creates an AgentToolDefinition from the provided function and options. The function is assigned to the Function field of the resulting AgentToolDefinition.

Parameters:

  • f: The function to be assigned to the AgentToolDefinition.
  • options: A variadic list of AgentToolOption to configure the AgentToolDefinition.

Returns:

A ToolDefinition with the provided function and applied options.

func (Definition) ToNameAndSchema

func (td Definition) ToNameAndSchema() (string, *jsonschema.Schema)

type Option

type Option = opts.Option[Definition]

Option is a type alias for a function that modifies the configuration options of an agent tool. It allows for flexible and customizable configuration of agent tools by applying various options.

Jump to

Keyboard shortcuts

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