Help us shape the future of Go! Take the 2026 Go Developer Survey

options

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 19 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

View Source
var Help = map[string]string{
	"api":                 "OpenAI compatible REST API (openai, localai, deepseek).",
	"apis":                "Aliases and endpoints for OpenAI compatible REST API.",
	"http-proxy":          "HTTP proxy to use for API requests.",
	"model":               "Default model (gpt-3.5-turbo, gpt-4, ggml-gpt4all-j...).",
	"ask-model":           "Ask which model to use with an interactive prompt.",
	"max-input-chars":     "Default character limit on input to model.",
	"format":              "Ask for the response to be formatted as markdown unless otherwise set.",
	"format-text":         "Text to append when using the -f flag.",
	"role":                "System role to use.",
	"roles":               "List of predefined system messages that can be used as roles.",
	"list-roles":          "List the roles defined in your configuration file",
	"prompt":              "Include the prompt from the arguments and stdin, truncate stdin to specified number of lines.",
	"prompt-args":         "Include the prompt from the arguments in the response.",
	"raw":                 "Render output as raw text when connected to a TTY.",
	"quiet":               "Quiet mode (hide the spinner while loading and stderr messages for success).",
	"help":                "Show help and exit.",
	"version":             "Show version and exit.",
	"max-retries":         "Maximum number of times to retry API calls.",
	"no-limit":            "Turn off the client-side limit on the size of the input into the model.",
	"word-wrap":           "Wrap formatted output at specific width (default is 80)",
	"max-tokens":          "Maximum number of tokens in response.",
	"temp":                "Temperature (randomness) of results, from 0.0 to 2.0.",
	"stop":                "Up to 4 sequences where the API will stop generating further tokens.",
	"topp":                "TopP, an alternative to temperature that narrows response, from 0.0 to 1.0.",
	"topk":                "TopK, only sample from the top K options for each subsequent token.",
	"fanciness":           "Your desired level of fanciness.",
	"loading-text":        "Text to show while generating.",
	"settings":            "Open settings in your $EDITOR.",
	"dirs":                "Print the directories in which mods store its data.",
	"reset-settings":      "Backup your old settings file and reset everything to the defaults.",
	"continue":            "Continue from the last response or a given save title.",
	"continue-last":       "Continue from the last response.",
	"no-cache":            "Disables caching of the prompt/response.",
	"title":               "Saves the current conversation with the given title.",
	"ls-convo":            "Lists saved conversations.",
	"rm-convo":            "Deletes a saved conversation with the given title or ID.",
	"rm-convo-older-than": "Deletes all saved conversations older than the specified duration. Valid units are: " + strings.EnglishJoin(duration.ValidUnits(), true) + ".",
	"rm-all-convo":        "Deletes all saved conversations.",
	"show-convo":          "Show a saved conversation with the given title or ID.",
	"theme":               "Theme to use in the forms. Valid units are: 'charm', 'catppuccin', 'dracula', and 'base16'",
	"show-last":           "Show the last saved conversation.",
	"datastore":           "Configure the datastore to use.",
	"auto-coder":          "Configure the auto coder to use.",
	"auto-commit":         "Automatically commit code changes after generation.",
	"verbose":             "Verbose mode. 0: no verbose, 1: debug verbose",
}

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"`
	AutoCommit   bool   `yaml:"auto-commit" env:"AUTO_COMMIT" default:"true"`
}

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"`
	Verbose       int        `yaml:"verbose" env:"VERBOSE"`
	APIs          APIs       `yaml:"apis"`
	DataStore     DataStore  `yaml:"datastore"`
	AutoCoder     AutoCoder  `yaml:"auto-coder"`

	DefaultPromptMode string `yaml:"default-prompt-mode,omitempty"`
	ConversationID    string `yaml:"convo-id,omitempty"`
	Ai                Ai     `yaml:"ai"`

	Models       map[string]Model
	SettingsPath string
	System       *system.Analysis
	Interactive  bool
	PromptFile   string
	ContinueLast bool
	Continue     string
	Title        string
	Show         string
	ShowLast     bool

	CacheReadFromID, CacheWriteToID, CacheWriteToTitle 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