tools

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cat = CatTool{
	Name:        "cat",
	Description: "Display the contents of a file. Uses the linux command 'cat'.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"file": {
				Type:        "string",
				Description: "The file to display the contents of.",
			},
			"number": {
				Type:        "boolean",
				Description: "Number all output lines.",
			},
			"showEnds": {
				Type:        "boolean",
				Description: "Display $ at end of each line.",
			},
			"squeezeBlank": {
				Type:        "boolean",
				Description: "Suppress repeated empty output lines.",
			},
		},
		Required: []string{"file"},
	},
}
View Source
var FileTree = FileTreeTool{
	Name:        "file_tree",
	Description: "List the filetree of some directory. Uses linux command 'tree'.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"directory": {
				Type:        "string",
				Description: "The directory to list the filetree of.",
			},
			"level": {
				Type:        "integer",
				Description: "The depth of the tree to display.",
			},
		},
		Required: []string{"directory"},
	},
}
View Source
var FileType = FileTypeTool{
	Name:        "file_type",
	Description: "Determine the file type of a given file. Uses the linux command 'file'.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"file_path": {
				Type:        "string",
				Description: "The path to the file to analyze.",
			},
			"mime_type": {
				Type:        "boolean",
				Description: "Whether to display the MIME type of the file.",
			},
		},
		Required: []string{"file_path"},
	},
}
View Source
var Find = FindTool{
	Name:        "find",
	Description: "Search for files in a directory hierarchy. Uses linux command 'find'.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"directory": {
				Type:        "string",
				Description: "The directory to start the search from.",
			},
			"name": {
				Type:        "string",
				Description: "The name pattern to search for.",
			},
			"type": {
				Type:        "string",
				Description: "The file type to search for (f: regular file, d: directory).",
			},
			"maxdepth": {
				Type:        "integer",
				Description: "The maximum depth of directories to search.",
			},
		},
		Required: []string{"directory"},
	},
}
View Source
var LS = LsTool{
	Name:        "ls",
	Description: "List the files in a directory. Uses the Linux command 'ls'.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"directory": {
				Type:        "string",
				Description: "The directory to list the files of.",
			},
			"all": {
				Type:        "boolean",
				Description: "Show all files, including hidden files.",
			},
			"long": {
				Type:        "boolean",
				Description: "Use a long listing format.",
			},
		},
		Required: []string{"directory"},
	},
}
View Source
var RipGrep = RipGrepTool{
	Name:        "rg",
	Description: "Search for a pattern in files using ripgrep.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"pattern": {
				Type:        "string",
				Description: "The pattern to search for.",
			},
			"path": {
				Type:        "string",
				Description: "The path to search in.",
			},
			"case_sensitive": {
				Type:        "boolean",
				Description: "Whether the search should be case sensitive.",
			},
			"line_number": {
				Type:        "boolean",
				Description: "Whether to show line numbers.",
			},
			"hidden": {
				Type:        "boolean",
				Description: "Whether to search hidden files and directories.",
			},
		},
		Required: []string{"pattern"},
	},
}
View Source
var WebsiteText = WebsiteTextTool{
	Name:        "website_text",
	Description: "Get the text content of a website by stripping all non-text tags and trimming whitespace.",
	Inputs: &InputSchema{
		Type: "object",
		Properties: map[string]ParameterObject{
			"url": {
				Type:        "string",
				Description: "The URL of the website to retrieve the text content from.",
			},
		},
		Required: []string{"url"},
	},
}

Functions

func Invoke added in v1.2.7

func Invoke(call Call) string

Invoke the call, and gather both error and output in the same string

func NewValidationError added in v1.2.7

func NewValidationError(fieldsMissing []string) error

Types

type AiTool added in v1.2.7

type AiTool interface {
	// Call the AI tool with the given Input. Returns output from the tool or an error
	// if the call returned an error-like. An error-like is either exit code non-zero or
	// restful response non 2xx.
	Call(Input) (string, error)

	// Return the UserFunction, later on used
	// by text queriers to send to their respective
	// models
	UserFunction() UserFunction
}

type Call added in v1.2.7

type Call struct {
	ID       string       `json:"id,omitempty"`
	Name     string       `json:"name,omitempty"`
	Type     string       `json:"type,omitempty"`
	Inputs   Input        `json:"inputs,omitempty"`
	Function UserFunction `json:"function,omitempty"`
}

func (Call) Json added in v1.2.7

func (c Call) Json() string

type CatTool added in v1.2.10

type CatTool UserFunction

func (CatTool) Call added in v1.2.10

func (c CatTool) Call(input Input) (string, error)

func (CatTool) UserFunction added in v1.2.10

func (c CatTool) UserFunction() UserFunction

type FileTreeTool added in v1.2.7

type FileTreeTool UserFunction

func (FileTreeTool) Call added in v1.2.7

func (f FileTreeTool) Call(input Input) (string, error)

func (FileTreeTool) UserFunction added in v1.2.7

func (f FileTreeTool) UserFunction() UserFunction

type FileTypeTool added in v1.2.10

type FileTypeTool UserFunction

func (FileTypeTool) Call added in v1.2.10

func (f FileTypeTool) Call(input Input) (string, error)

func (FileTypeTool) UserFunction added in v1.2.10

func (f FileTypeTool) UserFunction() UserFunction

type FindTool added in v1.2.10

type FindTool UserFunction

func (FindTool) Call added in v1.2.10

func (f FindTool) Call(input Input) (string, error)

func (FindTool) UserFunction added in v1.2.10

func (f FindTool) UserFunction() UserFunction

type Input added in v1.2.7

type Input map[string]any

type InputSchema added in v1.2.7

type InputSchema struct {
	Type       string                     `json:"type"`
	Required   []string                   `json:"required"`
	Properties map[string]ParameterObject `json:"properties"`
}

type LsTool added in v1.2.10

type LsTool UserFunction

func (LsTool) Call added in v1.2.10

func (f LsTool) Call(input Input) (string, error)

func (LsTool) UserFunction added in v1.2.10

func (f LsTool) UserFunction() UserFunction

type ParameterObject added in v1.2.7

type ParameterObject struct {
	Type        string   `json:"type"`
	Description string   `json:"description"`
	Enum        []string `json:"enum,omitempty"`
}

type RipGrepTool added in v1.3.7

type RipGrepTool UserFunction

func (RipGrepTool) Call added in v1.3.7

func (r RipGrepTool) Call(input Input) (string, error)

func (RipGrepTool) UserFunction added in v1.3.7

func (r RipGrepTool) UserFunction() UserFunction

type UserFunction added in v1.2.7

type UserFunction struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	// Format is the same, but name of the field different. So this way, each
	// vendor can set their own field name
	Inputs *InputSchema `json:"input_schema,omitempty"`
	// Chatgpt wants this
	Arguments string `json:"arguments,omitempty"`
}

func UserFunctionFromName added in v1.3.0

func UserFunctionFromName(name string) UserFunction

type ValidationError added in v1.2.7

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

func (ValidationError) Error added in v1.2.7

func (v ValidationError) Error() string

type WebsiteTextTool added in v1.3.1

type WebsiteTextTool UserFunction

func (WebsiteTextTool) Call added in v1.3.1

func (w WebsiteTextTool) Call(input Input) (string, error)

func (WebsiteTextTool) UserFunction added in v1.3.1

func (w WebsiteTextTool) UserFunction() UserFunction

Jump to

Keyboard shortcuts

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