tools

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 4 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"},
	},
}

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 {
	Name   string `json:"name"`
	Inputs Input  `json:"inputs"`
}

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 UserFunction added in v1.2.7

type UserFunction struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Inputs      InputSchema `json:"input_schema"`
}

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

Jump to

Keyboard shortcuts

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