options

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package options print a list of global command-line options (applies to all commands).

Index

Constants

View Source
const (
	// RecommendedHomeDir defines the default directory used to place all iam service configurations.
	RecommendedHomeDir = ".wecoding"

	// RecommendedEnvPrefix defines the ENV prefix used by all iam service.
	RecommendedEnvPrefix = "AI"
)
View Source
const (
	FlagAIConfig            = "config"
	FlagDefaultSystemPrompt = "system-prompt"
	FlagAiModel             = "model"
	FlagAiToken             = "token"
	FlagAiApiBase           = "api-base"
	FlagAiTemperature       = "temperature"
	FlagAiTopP              = "top-p"
	FlagAiMaxTokens         = "max-tokens"
	FlagOutputFormat        = "output-format"

	FlagLogFlushFrequency = "log-flush-frequency"
)

Defines flag for ai cli.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfg string, defaultName string)

LoadConfig reads in config file and ENV variables if set.

func NewCmdOptions

func NewCmdOptions(out io.Writer) *cobra.Command

NewCmdOptions implements the options command.

Types

type AiConfig

type AiConfig struct {
	SystemPrompt string       `yaml:"system-prompt,omitempty" mapstructure:"system-prompt,omitempty"`
	Token        string       `yaml:"token,omitempty" mapstructure:"token,omitempty"`
	Model        string       `yaml:"model,omitempty" mapstructure:"model,omitempty"`
	ApiBase      string       `yaml:"api-base,omitempty" mapstructure:"api-base,omitempty"`
	Temperature  float64      `yaml:"temperature,omitempty" mapstructure:"temperature,omitempty"`
	TopP         float64      `yaml:"top-p,omitempty" mapstructure:"top-p,omitempty"`
	MaxTokens    int          `yaml:"max-tokens,omitempty" mapstructure:"max-tokens,omitempty"`
	Proxy        string       `yaml:"proxy,omitempty" mapstructure:"proxy,omitempty"`
	OutputFormat OutputFormat `yaml:"output-format,omitempty" mapstructure:"output-format,omitempty"`
}

type Config

type Config struct {
	DefaultPromptMode string   `yaml:"default-prompt-mode,omitempty" mapstructure:"default-prompt-mode,omitempty"`
	Ai                AiConfig `yaml:"inline" mapstructure:"inline" json:"inline"`

	System *system.Analysis
}

Config is a structure used to configure a AI. Its members are sorted roughly in order of importance for composers.

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns a Config struct with the default values.

func WriteConfig

func WriteConfig(model, apiBase, apiToken string, write bool) (*Config, error)

type ConfigFlags

type ConfigFlags struct {
	Config *string
	// contains filtered or unexported fields
}

ConfigFlags composes the set of values necessary for obtaining a REST client config.

func NewConfigFlags

func NewConfigFlags(usePersistentConfig bool) *ConfigFlags

NewConfigFlags returns ConfigFlags with default values set.

func (*ConfigFlags) AddFlags

func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet)

AddFlags binds client configuration flags to a given flagset.

func (*ConfigFlags) ToRESTConfig

func (f *ConfigFlags) ToRESTConfig() (*rest.Config, error)

ToRESTConfig implements RESTClientGetter. Returns a REST client configuration based on a provided path to a .aiconfig file, loading rules, and config flag overrides. Expects the AddFlags method to have been called.

func (*ConfigFlags) ToRawAIConfigLoader

func (f *ConfigFlags) ToRawAIConfigLoader() clientcmd.ClientConfig

ToRawAIConfigLoader binds config flag values to config overrides Returns an interactive clientConfig if the password flag is enabled, or a non-interactive clientConfig otherwise.

type ModelOptions

type ModelOptions struct {
	Token        *string
	Model        *string
	ApiBase      *string
	Temperature  *float64
	TopP         *float64
	MaxTokens    *int
	Proxy        *string
	OutputFormat *string
	// contains filtered or unexported fields
}

func NewLLMFlags

func NewLLMFlags(usePersistentConfig bool) *ModelOptions

NewLLMFlags returns ModelOptions with default values set.

func (*ModelOptions) AddFlags

func (m *ModelOptions) AddFlags(flags *flag.FlagSet)

AddFlags binds client configuration flags to a given flagset.

func (*ModelOptions) Validate

func (m *ModelOptions) Validate() error

type OutputFormat

type OutputFormat string
const (
	RawOutputFormat      OutputFormat = "raw"
	MarkdownOutputFormat OutputFormat = "markdown"
)

type RESTClientGetter

type RESTClientGetter interface {
	// ToRESTConfig returns restconfig
	ToRESTConfig() (*rest.Config, error)
	// ToRawAIConfigLoader return aiconfig loader as-is
	ToRawAIConfigLoader() clientcmd.ClientConfig
}

RESTClientGetter is an interface that the ConfigFlags describe to provide an easier way to mock for commands and eliminate the direct coupling to a struct type. Users may wish to duplicate this type in their own packages as per the golang type overlapping.

Jump to

Keyboard shortcuts

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