toolbot

package
v0.0.0-...-d0bbb43 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVExporter

type CSVExporter struct {

	// StrictInputColumnKeys ensures that all input datapoints have this shape.
	// This helps detect typos in the examples.
	StrictInputColumnKeys sets.Set[string]
	// contains filtered or unexported fields
}

CSVExporter is an exporter that writes CSV files for each tool.

func NewCSVExporter

func NewCSVExporter(extractor Extractor, enhancers ...Enhancer) (*CSVExporter, error)

NewCSVExporter creates a new CSVExporter.

func (*CSVExporter) BuildDataPoints

func (x *CSVExporter) BuildDataPoints(ctx context.Context, description string, src []byte) ([]*DataPoint, error)

BuildDataPoints extracts data points from a byte slice representing a Go file.

func (*CSVExporter) EnhanceDataPoint

func (x *CSVExporter) EnhanceDataPoint(ctx context.Context, d *DataPoint) error

EnhanceDataPoint enhances a data point by running all the registered enhancers.

func (*CSVExporter) InferOutput_WithChat

func (x *CSVExporter) InferOutput_WithChat(ctx context.Context, input *DataPoint, out io.Writer) error

InferOutput_WithChat tries to infer an output value, using the Chat LLM APIs.

func (*CSVExporter) InferOutput_WithCompletion

func (x *CSVExporter) InferOutput_WithCompletion(ctx context.Context, model string, input *DataPoint, out io.Writer) error

InferOutput_WithCompletion tries to infer an output value, using the Completion LLM APIs.

func (*CSVExporter) VisitCodeDir

func (x *CSVExporter) VisitCodeDir(ctx context.Context, srcDir string) error

VisitCodeDir visits a directory and extracts data points from all Go files in the directory tree.

func (*CSVExporter) WriteCSVForAllTools

func (x *CSVExporter) WriteCSVForAllTools(ctx context.Context, outputDir string) error

WriteCSVForAllTools writes CSV files for all tools.

type DataPoint

type DataPoint struct {
	Description string
	Type        string
	Input       map[string]string
	Output      string
}

DataPoint holds the input and output for a tool.

func (*DataPoint) AddCSVColumns

func (p *DataPoint) AddCSVColumns(columnSet sets.Set[string])

AddCSVColumns adds the columns for the data point to the columnSet.

func (*DataPoint) InputColumnKeys

func (p *DataPoint) InputColumnKeys() sets.Set[string]

InputColumnKeys returns a set of the input column names

func (*DataPoint) SetInput

func (p *DataPoint) SetInput(k, v string)

SetInput sets an input value for the data point.

func (*DataPoint) ToGenAIFormat

func (p *DataPoint) ToGenAIFormat() string

ToGenAIFormat converts the data point to the input format for Gemini (or other LLMs).

func (*DataPoint) WriteCSV

func (p *DataPoint) WriteCSV(csvWriter *csv.Writer, columns []string) error

WriteCSV writes the data point to the CSV writer.

type EnhanceWithGoStruct

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

EnhanceWithGoStruct is an enhancer that finds Go structs with matching proto message annotation "// +kcc:proto=..."

func NewEnhanceWithGoStruct

func NewEnhanceWithGoStruct(srcDirectory string) (*EnhanceWithGoStruct, error)

NewEnhanceWithGoStruct creates a new EnhanceWithGoStruct

func (*EnhanceWithGoStruct) EnhanceDataPoint

func (x *EnhanceWithGoStruct) EnhanceDataPoint(ctx context.Context, p *DataPoint) error

EnhanceDataPoint enhances the data point by adding matching Go struct definitions

type EnhanceWithMappers

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

EnhanceWithMappers is an enhancer that finds Go mapper functions in a directory

func NewEnhanceWithMappers

func NewEnhanceWithMappers(srcDirectory string) (*EnhanceWithMappers, error)

NewEnhanceWithMappers creates a new EnhanceWithMappers

func (*EnhanceWithMappers) EnhanceDataPoint

func (x *EnhanceWithMappers) EnhanceDataPoint(ctx context.Context, p *DataPoint) error

EnhanceDataPoint enhances the data point by adding mapper function definitions

type EnhanceWithProtoDefinition

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

EnhanceWithProtoDefinition is an enhancer that adds the definition of a proto message or service to the data point.

func NewEnhanceWithProtoDefinition

func NewEnhanceWithProtoDefinition(protoDirectory string) (*EnhanceWithProtoDefinition, error)

NewEnhanceWithProtoDefinition creates a new EnhanceWithProtoDefinition.

func (*EnhanceWithProtoDefinition) EnhanceDataPoint

func (x *EnhanceWithProtoDefinition) EnhanceDataPoint(ctx context.Context, p *DataPoint) error

EnhanceDataPoint enhances the data point by adding the definition of the proto message or service.

type Enhancer

type Enhancer interface {
	EnhanceDataPoint(ctx context.Context, d *DataPoint) error
}

Enhancer is an interface for enhancing a data point. For example, it might add a computed field to the data point, such as the definition of a proto message, given the name of the proto message.

type ExtractToolMarkers

type ExtractToolMarkers struct {
}

ExtractToolMarkers extracts tool markers from source code.

func (*ExtractToolMarkers) Extract

func (x *ExtractToolMarkers) Extract(ctx context.Context, description string, src []byte) ([]*DataPoint, error)

Extract extracts tool markers from source code.

type Extractor

type Extractor interface {
	Extract(ctx context.Context, description string, b []byte) ([]*DataPoint, error)
}

Extractor is an interface for extracting data points from source code.

Jump to

Keyboard shortcuts

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