tool

package
v0.0.104 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package tool provides tools that agents can use to perform various operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run added in v0.0.23

func Run(ctx context.Context, t schema.Tool, input *schema.ToolInput, optFns ...func(o *Options)) (string, error)

func ToFunction added in v0.0.26

func ToFunction(t schema.Tool) (*schema.FunctionDefinition, error)

ToFunction formats a tool into a function API

Types

type CurrentPage added in v0.0.24

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

func NewCurrentPage added in v0.0.24

func NewCurrentPage(browser playwright.Browser) *CurrentPage

func (*CurrentPage) ArgsType added in v0.0.29

func (t *CurrentPage) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (*CurrentPage) Callbacks added in v0.0.30

func (t *CurrentPage) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*CurrentPage) Description added in v0.0.24

func (t *CurrentPage) Description() string

Description returns the description of the tool.

func (*CurrentPage) Name added in v0.0.24

func (t *CurrentPage) Name() string

Name returns the name of the tool.

func (*CurrentPage) Run added in v0.0.24

func (t *CurrentPage) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (*CurrentPage) Verbose added in v0.0.30

func (t *CurrentPage) Verbose() bool

Verbose returns the verbosity setting of the tool.

type ExtractText added in v0.0.24

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

func NewExtractText added in v0.0.24

func NewExtractText(browser playwright.Browser) *ExtractText

func (*ExtractText) ArgsType added in v0.0.29

func (t *ExtractText) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (*ExtractText) Callbacks added in v0.0.30

func (t *ExtractText) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*ExtractText) Description added in v0.0.24

func (t *ExtractText) Description() string

Description returns the description of the tool.

func (*ExtractText) Name added in v0.0.24

func (t *ExtractText) Name() string

Name returns the name of the tool.

func (*ExtractText) Run added in v0.0.24

func (t *ExtractText) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (*ExtractText) Verbose added in v0.0.30

func (t *ExtractText) Verbose() bool

Verbose returns the verbosity setting of the tool.

type HuggingFaceInjectionDetector added in v0.0.65

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

HuggingFaceInjectionDetector represents a tool for detecting injection attacks using Hugging Face models.

func NewHuggingFaceInjectionDetector added in v0.0.65

func NewHuggingFaceInjectionDetector(token string, optFns ...func(o *HuggingFaceInjectionDetectorOptions)) *HuggingFaceInjectionDetector

NewHuggingFaceInjectionDetector creates a new instance of the HuggingFaceInjectionDetector tool.

func NewHuggingFaceInjectionDetectorFromClient added in v0.0.66

func NewHuggingFaceInjectionDetectorFromClient(client HuggingFaceInjectionDetectorClient, optFns ...func(o *HuggingFaceInjectionDetectorOptions)) *HuggingFaceInjectionDetector

NewHuggingFaceInjectionDetectorFromClient creates a new instance of the HuggingFaceInjectionDetector tool.

func (*HuggingFaceInjectionDetector) ArgsType added in v0.0.65

ArgsType returns the type of the input argument expected by the tool.

func (*HuggingFaceInjectionDetector) Callbacks added in v0.0.65

func (t *HuggingFaceInjectionDetector) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*HuggingFaceInjectionDetector) Description added in v0.0.65

func (t *HuggingFaceInjectionDetector) Description() string

Description returns the description of the tool.

func (*HuggingFaceInjectionDetector) Name added in v0.0.65

Name returns the name of the tool.

func (*HuggingFaceInjectionDetector) Run added in v0.0.65

Run executes the tool with the given input and returns the output.

func (*HuggingFaceInjectionDetector) Verbose added in v0.0.65

func (t *HuggingFaceInjectionDetector) Verbose() bool

Verbose returns the verbosity setting of the tool.

type HuggingFaceInjectionDetectorClient added in v0.0.65

type HuggingFaceInjectionDetectorClient interface {
	TextClassification(ctx context.Context, req *huggingface.TextClassificationRequest) (huggingface.TextClassificationResponse, error)
}

HuggingFaceInjectionDetectorClient is an interface for interacting with the Hugging Face injection detector.

type HuggingFaceInjectionDetectorOptions added in v0.0.65

type HuggingFaceInjectionDetectorOptions struct {
	// Model to use for injection detection.
	Model string
	// Threshold for injection detection.
	Threshold float32
	// Options represents optional settings for the classification.
	Options huggingface.Options
}

HuggingFaceInjectionDetectorOptions represents configuration options for the Hugging Face injection detector.

type Human added in v0.0.35

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

Human is a tool that allows interaction with a human user.

func NewHuman added in v0.0.35

func NewHuman(optFns ...func(o *HumanOptions)) *Human

NewHuman creates a new instance of the Human tool with the provided options.

func (*Human) ArgsType added in v0.0.35

func (t *Human) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (*Human) Callbacks added in v0.0.35

func (t *Human) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*Human) Description added in v0.0.35

func (t *Human) Description() string

Description returns the description of the tool.

func (*Human) Name added in v0.0.35

func (t *Human) Name() string

Name returns the name of the tool.

func (*Human) Run added in v0.0.35

func (t *Human) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (*Human) Verbose added in v0.0.35

func (t *Human) Verbose() bool

Verbose returns the verbosity setting of the tool.

type HumanOptions added in v0.0.35

type HumanOptions struct {
	// Function for displaying prompts.
	PromptFunc PromptFunc

	// Function for retrieving user input.
	InputFunc InputFunc
}

HumanOptions contains options for configuring the Human tool.

type InputFunc added in v0.0.35

type InputFunc = func() (string, error)

InputFunc is a function type for retrieving user input.

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

func NewNavigateBrowser added in v0.0.24

func NewNavigateBrowser(browser playwright.Browser) *NavigateBrowser
func (t *NavigateBrowser) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (t *NavigateBrowser) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (t *NavigateBrowser) Description() string

Description returns the description of the tool.

func (t *NavigateBrowser) Name() string

Name returns the name of the tool.

func (t *NavigateBrowser) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (t *NavigateBrowser) Verbose() bool

Verbose returns the verbosity setting of the tool.

type Options added in v0.0.23

type Options struct {
	Callbacks   []schema.Callback
	ParentRunID string
}

type PromptFunc added in v0.0.35

type PromptFunc = func(query string)

PromptFunc is a function type for displaying a prompt.

type Retriever added in v0.0.96

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

Retriever is a tool that utilizes a retriever to fetch documents based on a query.

func NewRetriever added in v0.0.96

func NewRetriever(retriever schema.Retriever, name, description string, optFns ...func(o *RetrieverOptions)) *Retriever

NewRetriever creates a new Retriever instance using the provided retriever, name, and description, along with optional configuration options.

func (*Retriever) ArgsType added in v0.0.96

func (t *Retriever) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (*Retriever) Callbacks added in v0.0.96

func (t *Retriever) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*Retriever) Description added in v0.0.96

func (t *Retriever) Description() string

Description returns the description of the tool.

func (*Retriever) Name added in v0.0.96

func (t *Retriever) Name() string

Name returns the name of the tool.

func (*Retriever) Run added in v0.0.96

func (t *Retriever) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (*Retriever) Verbose added in v0.0.96

func (t *Retriever) Verbose() bool

Verbose returns the verbosity setting of the tool.

type RetrieverOptions added in v0.0.96

type RetrieverOptions struct {
	*schema.CallbackOptions
	DocumentSeparator string
}

RetrieverOptions contains options for configuring the Retriever tool.

type Sleep added in v0.0.15

type Sleep struct{}

Sleep is a tool that makes the agent sleep for a specified number of seconds.

func NewSleep added in v0.0.15

func NewSleep() *Sleep

NewSleep creates a new instance of the Sleep tool.

func (*Sleep) ArgsType added in v0.0.29

func (t *Sleep) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (*Sleep) Callbacks added in v0.0.30

func (t *Sleep) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*Sleep) Description added in v0.0.15

func (t *Sleep) Description() string

Description returns the description of the tool.

func (*Sleep) Name added in v0.0.15

func (t *Sleep) Name() string

Name returns the name of the tool.

func (*Sleep) Run added in v0.0.15

func (t *Sleep) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (*Sleep) Verbose added in v0.0.30

func (t *Sleep) Verbose() bool

Verbose returns the verbosity setting of the tool.

type Wikipedia

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

func NewWikipedia

func NewWikipedia(client *integration.Wikipedia) *Wikipedia

func (*Wikipedia) ArgsType added in v0.0.29

func (t *Wikipedia) ArgsType() reflect.Type

ArgsType returns the type of the input argument expected by the tool.

func (*Wikipedia) Callbacks added in v0.0.30

func (t *Wikipedia) Callbacks() []schema.Callback

Callbacks returns the registered callbacks of the tool.

func (*Wikipedia) Description

func (t *Wikipedia) Description() string

Description returns the description of the tool.

func (*Wikipedia) Name

func (t *Wikipedia) Name() string

Name returns the name of the tool.

func (*Wikipedia) Run

func (t *Wikipedia) Run(ctx context.Context, input any) (string, error)

Run executes the tool with the given input and returns the output.

func (*Wikipedia) Verbose added in v0.0.30

func (t *Wikipedia) Verbose() bool

Verbose returns the verbosity setting of the tool.

Jump to

Keyboard shortcuts

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