config

package
v0.0.0-...-0714061 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderOpenAI    = "openai"
	ProviderOllama    = "ollama"
	ProviderAnthropic = "anthropic"
	ProviderDeepseek  = "deepseek"
	ProviderYandex    = "yandex"
)

Supported LLM providers

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the path to the config file for display purposes

func GetProviderDisplayName

func GetProviderDisplayName(provider string) string

GetProviderDisplayName returns a user-friendly display name for a provider

func IsValidProvider

func IsValidProvider(provider string) bool

IsValidProvider checks if a provider name is valid

Types

type Config

type Config struct {
	DefaultProvider  string                    `json:"default_provider,omitempty"`   // Last used or preferred provider
	Providers        map[string]ProviderConfig `json:"providers,omitempty"`          // Provider-specific configs
	Preferences      map[string]string         `json:"preferences,omitempty"`        // General preferences
	MaxSavedSessions int                       `json:"max_saved_sessions,omitempty"` // Maximum number of sessions to keep (default: 5)

	// Deprecated fields (kept for backward compatibility)
	OpenAIAPIKey string `json:"openai_api_key,omitempty"`
	LLMProvider  string `json:"llm_provider,omitempty"`
}

Config represents the assistant configuration

func Load

func Load() (*Config, error)

Load loads the configuration from disk

func (*Config) DeleteOpenAIAPIKey

func (c *Config) DeleteOpenAIAPIKey() error

DeleteOpenAIAPIKey deletes the stored OpenAI API key (deprecated, use DeleteProviderConfig)

func (*Config) DeleteProviderConfig

func (c *Config) DeleteProviderConfig(provider string) error

DeleteProviderConfig deletes the configuration for a specific provider

func (*Config) GetDefaultProvider

func (c *Config) GetDefaultProvider() string

GetDefaultProvider returns the default provider

func (*Config) GetOpenAIAPIKey

func (c *Config) GetOpenAIAPIKey() string

GetOpenAIAPIKey gets the OpenAI API key (deprecated, use GetProviderConfig)

func (*Config) GetPreference

func (c *Config) GetPreference(key string) (string, bool)

GetPreference gets a preference value

func (*Config) GetProviderConfig

func (c *Config) GetProviderConfig(provider string) (ProviderConfig, bool)

GetProviderConfig gets the configuration for a specific provider

func (*Config) HasOpenAIAPIKey

func (c *Config) HasOpenAIAPIKey() bool

HasOpenAIAPIKey checks if an OpenAI API key is stored (deprecated, use HasProviderConfig)

func (*Config) HasProviderConfig

func (c *Config) HasProviderConfig(provider string) bool

HasProviderConfig checks if a provider has configuration

func (*Config) ListProviders

func (c *Config) ListProviders() []string

ListProviders returns a list of configured providers

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to disk

func (*Config) SetDefaultProvider

func (c *Config) SetDefaultProvider(provider string) error

SetDefaultProvider sets the default provider

func (*Config) SetOpenAIAPIKey

func (c *Config) SetOpenAIAPIKey(apiKey string) error

Backward compatibility methods SetOpenAIAPIKey sets the OpenAI API key (deprecated, use SetProviderConfig)

func (*Config) SetPreference

func (c *Config) SetPreference(key, value string) error

SetPreference sets a preference value

func (*Config) SetProviderConfig

func (c *Config) SetProviderConfig(provider string, config ProviderConfig) error

SetProviderConfig sets the configuration for a specific provider

type ProviderConfig

type ProviderConfig struct {
	APIKey  string `json:"api_key,omitempty"`
	BaseURL string `json:"base_url,omitempty"` // For Ollama or custom endpoints
	Model   string `json:"model,omitempty"`    // Default model for this provider
}

ProviderConfig represents configuration for a specific LLM provider

Jump to

Keyboard shortcuts

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