core

package
v0.0.0-...-45ad76c Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanGPTJson

func CleanGPTJson[T any](jsonStr string) (T, error)

func Contains

func Contains(slice []string, item string) bool

contains checks if a slice contains a specific element

func CountSelectedRows

func CountSelectedRows(dataset []RowItem, selected map[int]bool) int

func CreateFolderIfNotExists

func CreateFolderIfNotExists(folderPath string) error

func ExtractClasses

func ExtractClasses(dataset []RowItem, targetColumn string) []string

Types

type AI

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

func NewAI

func NewAI() *AI

func (*AI) GenerateObject

func (ai *AI) GenerateObject(prompt string, schema string, opts ...GenerateTextOptions) (any, error)

func (*AI) GenerateText

func (ai *AI) GenerateText(prompt string, opts ...GenerateTextOptions) (string, error)

type Class

type Class = string

type ClassificationResult

type ClassificationResult struct {
	Label          Label       `json:"label"`
	PredictedClass interface{} `json:"predicted_class"` // since numerical classes throw an error when unmarshalling if it's a number
	Probability    float64     `json:"probability"`
}

type ClassifierProfile

type ClassifierProfile struct {
	Label       string   `json:"label"`
	Description []string `json:"description"`
}

type GenerateTextOptions

type GenerateTextOptions struct {
	System      string
	Temperature float64
	Verbose     bool
}

type Label

type Label = string

type LabelDescription

type LabelDescription = string

type RowItem

type RowItem = map[string]string

func ReadCSVFile

func ReadCSVFile(filePath string) ([]RowItem, error)

func SelectRandomRow

func SelectRandomRow(dataset []RowItem) (RowItem, int)

type SaveModelToFileOptions

type SaveModelToFileOptions struct {
	Overwrite bool
}

type SavedTaoModel

type SavedTaoModel struct {
	ModelId          string
	Prompts          map[Label][]LabelDescription
	Temperature      float64
	PromptSampleSize int
	TargetColumn     string
}

type TaoClassifier

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

func NewTaoClassifier

func NewTaoClassifier(opts ...TaoClassifierOptions) *TaoClassifier

func (*TaoClassifier) AddPrompt

func (c *TaoClassifier) AddPrompt(label Label, description LabelDescription) (bool, error)

func (*TaoClassifier) ArePromptsLoaded

func (c *TaoClassifier) ArePromptsLoaded() (bool, error)

func (*TaoClassifier) ClearPrompts

func (c *TaoClassifier) ClearPrompts()

func (*TaoClassifier) GenerateClassifierProfile

func (c *TaoClassifier) GenerateClassifierProfile(label Label, rowItem RowItem, currentClassifierProfile ClassifierProfile) (ClassifierProfile, error)

func (*TaoClassifier) GetAvailableLabels

func (c *TaoClassifier) GetAvailableLabels() ([]Label, error)

func (*TaoClassifier) GetPrompt

func (c *TaoClassifier) GetPrompt(label Label) ([]LabelDescription, error)

func (*TaoClassifier) GetPrompts

func (c *TaoClassifier) GetPrompts() map[Label][]LabelDescription

func (*TaoClassifier) GetSavableModel

func (c *TaoClassifier) GetSavableModel() SavedTaoModel

func (*TaoClassifier) LoadModel

func (c *TaoClassifier) LoadModel(modelId string) (bool, error)

NOTE: this mutates the model ID if the model exists in the config

func (*TaoClassifier) PredictMany

func (c *TaoClassifier) PredictMany(texts []string) ([]ClassificationResult, error)

func (*TaoClassifier) PredictManyObjects

func (c *TaoClassifier) PredictManyObjects(objs []any) ([]ClassificationResult, error)

func (*TaoClassifier) PredictManyRowItems

func (c *TaoClassifier) PredictManyRowItems(rowItems []RowItem) ([]ClassificationResult, error)

func (*TaoClassifier) PredictOne

func (c *TaoClassifier) PredictOne(text string) (ClassificationResult, error)

func (*TaoClassifier) PredictOneObject

func (c *TaoClassifier) PredictOneObject(obj any) (ClassificationResult, error)

func (*TaoClassifier) PredictOneRowItem

func (c *TaoClassifier) PredictOneRowItem(rowItem RowItem) (ClassificationResult, error)

func (*TaoClassifier) PromptTrain

func (c *TaoClassifier) PromptTrain(prompts map[Label][]LabelDescription) (bool, error)

func (*TaoClassifier) RemovePrompt

func (c *TaoClassifier) RemovePrompt(label Label) (bool, error)

func (*TaoClassifier) SaveModel

func (c *TaoClassifier) SaveModel() (bool, error)

func (*TaoClassifier) Train

func (c *TaoClassifier) Train() error

type TaoClassifierOptions

type TaoClassifierOptions struct {
	ModelId             string
	TrainingDatasetPath string
	TargetColumn        string
	Temperature         float64
	PromptSampleSize    int
	Verbose             bool
}

type TaoConfig

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

func GetTaoConfig

func GetTaoConfig() *TaoConfig

GetTaoConfig returns the singleton instance of TaoConfig

func (*TaoConfig) DeleteConfigFolder

func (tc *TaoConfig) DeleteConfigFolder() error

func (*TaoConfig) Init

func (tc *TaoConfig) Init() error

func (*TaoConfig) LoadModelFromFile

func (tc *TaoConfig) LoadModelFromFile(modelId string) (SavedTaoModel, error)

func (*TaoConfig) SaveModelToFile

func (tc *TaoConfig) SaveModelToFile(model SavedTaoModel, opts ...SaveModelToFileOptions) (string, error)

Jump to

Keyboard shortcuts

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