tools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidName

func IsValidName(s string) bool

func ParseParams

func ParseParams(ps Parameters, data map[string]any) ([]any, error)

ParseParams is a helper function for parsing Parameters from an arbitraryJSON object.

Types

type ArrayParameter

type ArrayParameter struct {
	CommonParameter `yaml:",inline"`
	Items           Parameter `yaml:"items"`
}

ArrayParameter is a parameter representing the "array" type.

func NewArrayParameter

func NewArrayParameter(name, desc string, items Parameter) *ArrayParameter

NewArrayParameter is a convenience function for initializing an ArrayParameter.

func (*ArrayParameter) Parse

func (p *ArrayParameter) Parse(v any) (any, error)

func (*ArrayParameter) UnmarshalYAML

func (p *ArrayParameter) UnmarshalYAML(node *yaml.Node) error

type BooleanParameter

type BooleanParameter struct {
	CommonParameter `yaml:",inline"`
}

BooleanParameter is a parameter representing the "boolean" type.

func NewBooleanParameter

func NewBooleanParameter(name, desc string) *BooleanParameter

NewBooleanParameter is a convenience function for initializing a BooleanParameter.

func (*BooleanParameter) Parse

func (p *BooleanParameter) Parse(v any) (any, error)

type CommonParameter

type CommonParameter struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"`
	Desc string `yaml:"description"`
}

CommonParameter are default fields that are emebdding in most Parameter implementations. Embedding this stuct will give the object Name() and Type() functions.

func (*CommonParameter) GetName

func (p *CommonParameter) GetName() string

GetName returns the name specified for the Parameter.

func (*CommonParameter) GetType

func (p *CommonParameter) GetType() string

GetType returns the type specified for the Parameter.

func (*CommonParameter) Manifest

func (p *CommonParameter) Manifest() ParameterManifest

GetType returns the type specified for the Parameter.

type FloatParameter

type FloatParameter struct {
	CommonParameter `yaml:",inline"`
}

FloatParameter is a parameter representing the "float" type.

func NewFloatParameter

func NewFloatParameter(name, desc string) *FloatParameter

NewFloatParameter is a convenience function for initializing a FloatParameter.

func (*FloatParameter) Parse

func (p *FloatParameter) Parse(v any) (any, error)

type IntParameter

type IntParameter struct {
	CommonParameter `yaml:",inline"`
}

IntParameter is a parameter representing the "int" type.

func NewIntParameter

func NewIntParameter(name, desc string) *IntParameter

NewIntParameter is a convenience function for initializing a IntParameter.

func (*IntParameter) Parse

func (p *IntParameter) Parse(v any) (any, error)

type Manifest added in v0.0.2

type Manifest struct {
	Description string              `json:"description"`
	Parameters  []ParameterManifest `json:"parameters"`
}

Manifest is the representation of tools sent to Client SDKs.

type Parameter

type Parameter interface {
	// Note: It's typically not idiomatic to include "Get" in the function name,
	// but this is done to differentiate it from the fields in CommonParameter.
	GetName() string
	GetType() string
	Parse(any) (any, error)
	Manifest() ParameterManifest
}

type ParameterManifest

type ParameterManifest struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description"`
}

ParameterManifest represents parameters when served as part of a ToolManifest.

type Parameters

type Parameters []Parameter

Parameters is a type used to allow unmarshal a list of parameters

func (Parameters) Manifest added in v0.0.2

func (ps Parameters) Manifest() []ParameterManifest

func (*Parameters) UnmarshalYAML

func (c *Parameters) UnmarshalYAML(node *yaml.Node) error

type ParseTypeError

type ParseTypeError struct {
	Name  string
	Type  string
	Value any
}

ParseTypeError is a custom error for incorrectly typed Parameters.

func (ParseTypeError) Error

func (e ParseTypeError) Error() string

type StringParameter

type StringParameter struct {
	CommonParameter `yaml:",inline"`
}

StringParameter is a parameter representing the "string" type.

func NewStringParameter

func NewStringParameter(name, desc string) *StringParameter

NewStringParameter is a convenience function for initializing a StringParameter.

func (*StringParameter) Parse

func (p *StringParameter) Parse(v any) (any, error)

Parse casts the value "v" as a "string".

type Tool

type Tool interface {
	Invoke([]any) (string, error)
	ParseParams(data map[string]any) ([]any, error)
	Manifest() Manifest
}

type ToolConfig added in v0.0.2

type ToolConfig interface {
	ToolConfigKind() string
	Initialize(map[string]sources.Source) (Tool, error)
}

type Toolset

type Toolset struct {
	Name     string          `yaml:"name"`
	Tools    []*Tool         `yaml:",inline"`
	Manifest ToolsetManifest `yaml:",inline"`
}

type ToolsetConfig

type ToolsetConfig struct {
	Name      string   `yaml:"name"`
	ToolNames []string `yaml:",inline"`
}

func (ToolsetConfig) Initialize

func (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool) (Toolset, error)

type ToolsetManifest

type ToolsetManifest struct {
	ServerVersion string              `json:"serverVersion"`
	ToolsManifest map[string]Manifest `json:"tools"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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