config

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OutputLanguageMap = map[string]string{
	"en":    "English",
	"zh-cn": "Simplified Chinese",
	"zh-tw": "Traditional Chinese",
	"fr":    "French",
	"vi":    "Vietnamese",
	"ja":    "Japanese",
	"ko":    "Korean",
	"ru":    "Russian",
	"tr":    "Turkish",
	"id":    "Indonesian",
	"th":    "Thai",
	"de":    "German",
	"es":    "Spanish",
	"pt":    "Portuguese",
	"it":    "Italian",
	"ar":    "Arabic",
	"hi":    "Hindi",
	"el":    "Greek",
	"pl":    "Polish",
	"nl":    "Dutch",
	"sv":    "Swedish",
	"fi":    "Finnish",
	"hu":    "Hungarian",
	"cs":    "Czech",
	"ro":    "Romanian",
	"bg":    "Bulgarian",
	"uk":    "Ukrainian",
	"he":    "Hebrew",
	"lt":    "Lithuanian",
	"la":    "Latin",
	"ca":    "Catalan",
	"sr":    "Serbian",
	"sl":    "Slovenian",
	"mk":    "Macedonian",
	"lv":    "Latvian",
	"bn":    "Bengali",
	"ta":    "Tamil",
	"te":    "Telugu",
	"ml":    "Malayalam",
	"si":    "Sinhala",
	"fa":    "Persian",
	"ur":    "Urdu",
	"pa":    "Punjabi",
	"mr":    "Marathi",
}

OutputLanguageMap maps language codes to their names

Functions

func IsValidLanguage

func IsValidLanguage(lang string) bool

IsValidLanguage checks if a language code is valid

func MaskAPIKey

func MaskAPIKey(apiKey string, showFirst int) string

MaskAPIKey masks an API key by showing only the first few characters and replacing the rest with asterisks

func MaskConfigAPIKeys

func MaskConfigAPIKeys(data map[string]interface{})

MaskConfigAPIKeys recursively masks all API keys in a map

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles configuration management

func New

func New(configPath string) (*Manager, error)

New creates a new configuration manager

func (*Manager) Append

func (m *Manager) Append(key string, value interface{}) error

Append appends a value to a list configuration

func (*Manager) Get

func (m *Manager) Get(key string) (interface{}, bool)

Get retrieves a configuration value

func (*Manager) GetClientConfig

func (m *Manager) GetClientConfig() (*types.ClientConfig, error)

GetClientConfig retrieves the client configuration

func (*Manager) GetFileIgnore

func (m *Manager) GetFileIgnore() []string

GetFileIgnore returns the file ignore patterns

func (*Manager) GetPath

func (m *Manager) GetPath() string

GetPath returns the configuration file path

func (*Manager) GetPrompt

func (m *Manager) GetPrompt(isRich bool) string

GetPrompt retrieves the prompt configuration

func (*Manager) GetSupportedKeys

func (m *Manager) GetSupportedKeys() []string

GetSupportedKeys returns a list of supported configuration keys

func (*Manager) GetTranslationPrompt

func (m *Manager) GetTranslationPrompt() string

GetTranslationPrompt retrieves the translation prompt

func (*Manager) List

func (m *Manager) List() (string, error)

List returns the configuration as a string with masked API keys

func (*Manager) ListWithoutPrompt

func (m *Manager) ListWithoutPrompt() map[string]interface{}

ListWithoutPrompt returns all configuration as a map without the prompt section

func (*Manager) Remove

func (m *Manager) Remove(key string, value string) error

Remove removes a configuration value or a value from a list

func (*Manager) Reset

func (m *Manager) Reset(promptOnly bool) error

Reset resets the configuration to default values If promptOnly is true, only reset the prompt section

func (*Manager) Set

func (m *Manager) Set(key string, value interface{}) error

Set sets a configuration value

func (*Manager) SetProvider

func (m *Manager) SetProvider(provider, apiKey, apiBase, model string) error

SetProvider sets the provider configuration

func (*Manager) UpdateProviderConfig

func (m *Manager) UpdateProviderConfig(provider string, configs map[string]string) error

UpdateProviderConfig updates the configuration for a specific provider

Jump to

Keyboard shortcuts

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