Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalConfig(config *Config) ([]byte, error)
- func ValidateApiKey(apiKey string) error
- func ValidateModel(model string) error
- func ValidateTemperature(temperature float32) error
- type AskConfigsCli
- type AskToChangeModelCli
- type Chat
- type ChatCommand
- type Config
- type ConfigRepo
- type ResetConfigCommand
- type System
- type UpdateConfigCommand
- type VerifyConfigCommand
Constants ¶
const ( GPT3Dot5Turbo16k = "gpt-3.5-turbo-16k" GPT3Dot5Turbo = "gpt-3.5-turbo" GPT4 = "gpt-4" GPT432K = "gpt-4-32k" )
Variables ¶
var AllowedModels = []string{ GPT3Dot5Turbo, GPT3Dot5Turbo16k, GPT4, GPT432K, }
Functions ¶
func MarshalConfig ¶
MarshalConfig marshals a Config into a byte slice.
func ValidateApiKey ¶
ValidateApiKey validates the API key for the OpenAI API. It does so by making a request to the models endpoint - if it fails, the API key is invalid.
func ValidateModel ¶
ValidateModel validates the model for the OpenAI API by checking if the model is in the list of allowed models.
func ValidateTemperature ¶
ValidateTemperature validates the temperature for the OpenAI API.
Types ¶
type AskConfigsCli ¶
AskConfigsCli is a command line interface that asks the user for the configuration.
func MakeAskConfigsCli ¶
func MakeAskConfigsCli() AskConfigsCli
func NewAskConfigsCli ¶
func NewAskConfigsCli() AskConfigsCli
NewAskConfigsCli creates a new instance of AskConfigsCli.
type AskToChangeModelCli ¶ added in v1.4.2
func MakeAskToChangeModelCli ¶ added in v1.4.2
func MakeAskToChangeModelCli() AskToChangeModelCli
func NewAskToChangeModelCli ¶ added in v1.4.2
func NewAskToChangeModelCli() AskToChangeModelCli
type Chat ¶
type Chat interface { // Response returns the response from the AI. Response(config *Config, system *System, input string) (string, error) }
Chat is the interface that wraps the Response method.
type ChatCommand ¶
type ChatCommand interface { // Execute returns the response from the AI. Execute(config *Config, system *System, input string) (string, error) }
ChatCommand is the interface that wraps the basic Execute method.
func MakeChatCommand ¶ added in v1.4.3
func MakeChatCommand() ChatCommand
func NewChatCommand ¶
func NewChatCommand(chat Chat) ChatCommand
NewChatCommand creates a new instance of ChatCommand.
type Config ¶
type Config struct { ApiKey string `json:"openai_api_key"` Temperature float32 `json:"openai_temperature"` Model string `json:"openai_model"` }
Config is the configuration for the OpenAI API.
func UnmarshalConfig ¶
UnmarshalConfig unmarshals a Config from a byte slice.
type ConfigRepo ¶ added in v1.5.0
type ConfigRepo interface { // SaveConfig saves the config file. SaveConfig(config *Config) error // GetConfig returns the config file. GetConfig() (*Config, error) // DeleteConfig deletes the config file. DeleteConfig() error // UpdateConfig updates the config file. UpdateConfig(config *Config) error // Exists returns true if the config file exists. Exists() bool }
ConfigRepo is the interface that wraps the basic operations with the config file.
func MakeConfigRepo ¶
func MakeConfigRepo() ConfigRepo
func NewConfigRepo ¶ added in v1.5.0
func NewConfigRepo(storage *storage.Storage) ConfigRepo
NewConfigRepo creates a new instance of Repo.
type ResetConfigCommand ¶
type ResetConfigCommand interface { // Execute will reset the configs. Execute() error }
ResetConfigCommand is the interface that wraps the basic Execute method.
func MakeResetConfigCommand ¶
func MakeResetConfigCommand() ResetConfigCommand
func NewResetConfigCommand ¶
func NewResetConfigCommand(repo ConfigRepo) ResetConfigCommand
NewResetConfigCommand creates a new instance of ResetConfigCommand.
type UpdateConfigCommand ¶
type UpdateConfigCommand interface { // Execute will update the configs. Execute(config *Config) error }
UpdateConfigCommand is the interface that wraps the basic Execute method.
func MakeUpdateConfigCommand ¶
func MakeUpdateConfigCommand() UpdateConfigCommand
func NewUpdateConfigCommand ¶
func NewUpdateConfigCommand(repo ConfigRepo) UpdateConfigCommand
NewUpdateConfigCommand creates a new instance of UpdateConfigCommand.
type VerifyConfigCommand ¶
type VerifyConfigCommand interface { // Execute will verify if the configs were initialized and if not, it will initialize them. Execute(getConfigsFn func() (*Config, error)) (*Config, error) }
VerifyConfigCommand is the interface that wraps the basic Execute method.
func MakeVerifyConfigCommand ¶
func MakeVerifyConfigCommand() VerifyConfigCommand
func NewVerifyConfigCommand ¶
func NewVerifyConfigCommand(repo ConfigRepo) VerifyConfigCommand
NewVerifyConfigCommand creates a new instance of VerifyConfigCommand.