config

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug indicates whether debug logging is enabled

View Source
var Verbose bool

Verbose indicates whether verbose logging is enabled

Functions

func DebugLog

func DebugLog(format string, args ...interface{})

DebugLog prints debug information if debug mode is enabled

func DecryptConfig

func DecryptConfig(data []byte, password string) ([]byte, error)

DecryptConfig decrypts the configuration data

func EncryptConfig

func EncryptConfig(path string, password string) error

EncryptConfig encrypts the configuration file

func GenerateBearerToken

func GenerateBearerToken() (string, error)

GenerateBearerToken generates a secure random bearer token

func GetEnvPath

func GetEnvPath() string

GetEnvPath returns the environment file path from COMANDA_ENV or the default

func IsEncrypted

func IsEncrypted(data []byte) bool

IsEncrypted checks if the file content is encrypted

func PromptPassword

func PromptPassword(prompt string) (string, error)

PromptPassword prompts the user for a password securely

func SaveEnvConfig

func SaveEnvConfig(path string, config *EnvConfig) error

SaveEnvConfig saves the environment configuration to .env file

func ValidateModelMode

func ValidateModelMode(mode ModelMode) bool

ValidateModelMode checks if a mode is valid

func VerboseLog

func VerboseLog(format string, args ...interface{})

VerboseLog prints verbose information if verbose mode is enabled

Types

type DatabaseConfig

type DatabaseConfig struct {
	Type     DatabaseType `yaml:"type"`
	Host     string       `yaml:"host"`
	Port     int          `yaml:"port"`
	User     string       `yaml:"user"`
	Password string       `yaml:"password"`
	Database string       `yaml:"database"`
}

DatabaseConfig represents a database connection configuration

func (*DatabaseConfig) GetConnectionString

func (c *DatabaseConfig) GetConnectionString() string

GetConnectionString returns a connection string for the specified database

type DatabaseType

type DatabaseType string

DatabaseType represents supported database types

const (
	PostgreSQL DatabaseType = "postgres"
)

type EnvConfig

type EnvConfig struct {
	Providers map[string]*Provider      `yaml:"providers"` // Changed to store pointers to Provider
	Server    *ServerConfig             `yaml:"server,omitempty"`
	Databases map[string]DatabaseConfig `yaml:"databases,omitempty"` // Added database configurations
}

EnvConfig represents the complete environment configuration

func LoadEncryptedEnvConfig

func LoadEncryptedEnvConfig(path string, password string) (*EnvConfig, error)

LoadEncryptedEnvConfig loads an encrypted environment configuration

func LoadEnvConfig

func LoadEnvConfig(path string) (*EnvConfig, error)

LoadEnvConfig loads the environment configuration from .env file

func LoadEnvConfigWithPassword

func LoadEnvConfigWithPassword(path string) (*EnvConfig, error)

LoadEnvConfigWithPassword attempts to load the config, prompting for password if encrypted

func (*EnvConfig) AddDatabase

func (c *EnvConfig) AddDatabase(name string, config DatabaseConfig)

AddDatabase adds or updates a database configuration

func (*EnvConfig) AddModelToProvider

func (c *EnvConfig) AddModelToProvider(providerName string, model Model) error

AddModelToProvider adds a model to a specific provider

func (*EnvConfig) AddProvider

func (c *EnvConfig) AddProvider(name string, provider Provider)

AddProvider adds or updates a provider configuration

func (*EnvConfig) GetDatabaseConfig

func (c *EnvConfig) GetDatabaseConfig(name string) (*DatabaseConfig, error)

GetDatabaseConfig retrieves configuration for a specific database

func (*EnvConfig) GetModelConfig

func (c *EnvConfig) GetModelConfig(providerName, modelName string) (*Model, error)

GetModelConfig retrieves configuration for a specific model

func (*EnvConfig) GetProviderConfig

func (c *EnvConfig) GetProviderConfig(providerName string) (*Provider, error)

GetProviderConfig retrieves configuration for a specific provider

func (*EnvConfig) GetServerConfig

func (c *EnvConfig) GetServerConfig() *ServerConfig

GetServerConfig retrieves the server configuration

func (*EnvConfig) UpdateAPIKey

func (c *EnvConfig) UpdateAPIKey(providerName, apiKey string) error

UpdateAPIKey updates the API key for a specific provider

func (*EnvConfig) UpdateModelModes

func (c *EnvConfig) UpdateModelModes(providerName, modelName string, modes []ModelMode) error

UpdateModelModes updates the modes for a specific model

func (*EnvConfig) UpdateServerConfig

func (c *EnvConfig) UpdateServerConfig(config ServerConfig)

UpdateServerConfig updates the server configuration

type Model

type Model struct {
	Name  string      `yaml:"name"`
	Type  string      `yaml:"type"`
	Modes []ModelMode `yaml:"modes"`
}

Model represents a single model configuration

func (*Model) HasMode

func (m *Model) HasMode(mode ModelMode) bool

HasMode checks if a model supports a specific mode

type ModelMode

type ModelMode string

ModelMode represents the supported modes for a model

const (
	TextMode   ModelMode = "text"
	VisionMode ModelMode = "vision"
	MultiMode  ModelMode = "multi"
	FileMode   ModelMode = "file" // Added for file handling support
)

func GetSupportedModes

func GetSupportedModes() []ModelMode

GetSupportedModes returns all supported model modes

type Provider

type Provider struct {
	APIKey string  `yaml:"api_key"`
	Models []Model `yaml:"models"`
}

Provider represents a provider's configuration

type ServerConfig

type ServerConfig struct {
	Port        int    `yaml:"port"`
	BearerToken string `yaml:"bearer_token,omitempty"`
	Enabled     bool   `yaml:"enabled"`
	DataDir     string `yaml:"data_dir"`
}

ServerConfig represents the server configuration

Jump to

Keyboard shortcuts

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