options

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	FlagDatastoreType     = "datastore.type"
	FlagDatastoreUrl      = "datastore.url"
	FlagDatastorePath     = "datastore.path"
	FlagDatastoreUsername = "datastore.username"
	FlagDatastorePassword = "datastore.password"
)
View Source
const (
	FlagDefaultSystemPrompt = "system-prompt"
	FlagAiModel             = "model"
	FlagAiToken             = "token"
	FlagAiApiBase           = "api-base"
	FlagAiTemperature       = "temperature"
	FlagAiTopP              = "top-p"
	FlagAiMaxTokens         = "max-tokens"
	FlagOutputFormat        = "output-format"
	FlagMultiContentEnabled = "multi-content-enabled"
)
View Source
const (
	FlagLogFlushFrequency = "log-flush-frequency"
)
View Source
const (
	// RecommendedEnvPrefix defines the ENV prefix used by all iam service.
	RecommendedEnvPrefix = "AI_"
)

Variables

This section is empty.

Functions

func AddBasicFlags

func AddBasicFlags(flags *pflag.FlagSet, cfg *Config)

AddBasicFlags binds client configuration flags to a given flagset.

func NewCmdOptions

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

NewCmdOptions implements the options command.

func WriteConfigFile

func WriteConfigFile(path string) error

Types

type API

type API struct {
	Name      string
	APIKey    string           `yaml:"api-key"`
	APIKeyEnv string           `yaml:"api-key-env"`
	APIKeyCmd string           `yaml:"api-key-cmd"`
	Version   string           `yaml:"version"`
	BaseURL   string           `yaml:"base-url"`
	Models    map[string]Model `yaml:"models"`
	User      string           `yaml:"user"`
}

API represents an API endpoint and its models.

type APIs

type APIs []API

APIs is a type alias to allow custom YAML decoding.

func (*APIs) UnmarshalYAML

func (apis *APIs) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements sorted API YAML decoding.

type Ai deprecated

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

Deprecated: Use Model instead.

type AutoCoder added in v0.12.0

type AutoCoder struct {
	PromptPrefix string `yaml:"prompt-prefix" env:"PROMPT_PREFIX"`
	EditFormat   string `yaml:"edit-format" env:"EDIT_FORMAT"`
	CommitPrefix string `yaml:"commit-prefix" env:"COMMIT_PREFIX"`
}

AutoCoder is the configuration for the auto coder.

type Config

type Config struct {
	Model         string     `yaml:"default-model" env:"MODEL"`
	API           string     `yaml:"default-api" env:"API"`
	Raw           bool       `yaml:"raw" env:"RAW"`
	Quiet         bool       `yaml:"quiet" env:"QUIET"`
	MaxTokens     int        `yaml:"max-tokens" env:"MAX_TOKENS"`
	MaxInputChars int        `yaml:"max-input-chars" env:"MAX_INPUT_CHARS"`
	Temperature   float64    `yaml:"temp" env:"TEMP"`
	Stop          []string   `yaml:"stop" env:"STOP"`
	TopP          float64    `yaml:"topp" env:"TOPP"`
	TopK          int        `yaml:"topk" env:"TOPK"`
	NoLimit       bool       `yaml:"no-limit" env:"NO_LIMIT"`
	NoCache       bool       `yaml:"no-cache" env:"NO_CACHE"`
	MaxRetries    int        `yaml:"max-retries" env:"MAX_RETRIES"`
	WordWrap      int        `yaml:"word-wrap" env:"WORD_WRAP"`
	Fanciness     uint       `yaml:"fanciness" env:"FANCINESS"`
	LoadingText   string     `yaml:"loading-text" env:"LOADING_TEXT"`
	FormatText    FormatText `yaml:"format-text"`
	FormatAs      string     `yaml:"format-as" env:"FORMAT_AS"`
	APIs          APIs       `yaml:"apis"`
	DataStore     DataStore  `yaml:"datastore"`
	AutoCoder     AutoCoder  `yaml:"auto-coder"`

	DefaultPromptMode string `yaml:"default-prompt-mode,omitempty"`
	ChatID            string `yaml:"chat-id,omitempty"`
	Ai                Ai     `yaml:"ai"`

	Models       map[string]Model
	SettingsPath string
	System       *system.Analysis
	Interactive  bool
	PromptFile   string
}

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

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config struct with the default values.

func EnsureConfig

func EnsureConfig() (Config, error)

func NewConfig

func NewConfig() *Config

NewConfig returns a Config struct with the default values.

type DataStore

type DataStore struct {
	Type      string `yaml:"type,omitempty" env:"DATASTORE_TYPE"`
	CachePath string `yaml:"cache-path" env:"CACHE_PATH"`
	Url       string `yaml:"url,omitempty"`
	Username  string `yaml:"username,omitempty"`
	Password  string `yaml:"password,omitempty"`
}

type DataStoreFlags

type DataStoreFlags struct {
	Type     *string
	Url      *string
	Path     *string
	Username *string
	Password *string
}

func NewDatastoreFlags

func NewDatastoreFlags(dsType string) *DataStoreFlags

NewDatastoreFlags returns DataStoreFlags with default values set.

func (*DataStoreFlags) AddFlags

func (d *DataStoreFlags) AddFlags(flags *pflag.FlagSet)

AddFlags binds client configuration flags to a given cmd.

func (*DataStoreFlags) Validate

func (d *DataStoreFlags) Validate() error

type FormatText

type FormatText map[string]string

FormatText is a map[format]formatting_text.

func (*FormatText) UnmarshalYAML

func (ft *FormatText) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML conforms with yaml.Unmarshaler.

type Model

type Model struct {
	Name     string
	API      string
	MaxChars int      `yaml:"max-input-chars"`
	Aliases  []string `yaml:"aliases"`
	Fallback string   `yaml:"fallback"`
}

Model represents the LLM model used in the API call.

type ModelFlags

type ModelFlags struct {
	Token               *string
	Model               *string
	ApiBase             *string
	Temperature         *float64
	TopP                *float64
	MaxTokens           *int
	Proxy               *string
	OutputFormat        *string
	MultiContentEnabled *bool
}

func NewModelFlags

func NewModelFlags() *ModelFlags

NewModelFlags returns ModelFlags with default values set.

func (*ModelFlags) AddFlags

func (m *ModelFlags) AddFlags(flags *pflag.FlagSet)

AddFlags binds client configuration flags to a given flagset.

func (*ModelFlags) Validate

func (m *ModelFlags) Validate() error

type OutputFormat

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

Jump to

Keyboard shortcuts

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