Documentation
¶
Index ¶
- func GetServerTimeout() time.Duration
- func RegisterConfigComponent(name string, component ConfigComponent)
- func RegisterLLMServiceConfig(name string, config ConfigLLMService)
- func RegisterLogger(name string, component ConfigComponent)
- func Reset()
- func UpdateStructFromConfig(toStruct any, fromConfig map[string]interface{}) error
- type Config
- type ConfigComponent
- type ConfigLLM
- type ConfigLLMService
- type ConfigLogging
- type ConfigServer
- type ConfigUpstream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetServerTimeout ¶
func RegisterConfigComponent ¶
func RegisterConfigComponent(name string, component ConfigComponent)
RegisterConfigComponent registers a component that implements ConfigLoader The name can be dot-separated (e.g., "benchmarks.llm.coding.humaneval") to create a nested structure
func RegisterLLMServiceConfig ¶
func RegisterLLMServiceConfig(name string, config ConfigLLMService)
func RegisterLogger ¶
func RegisterLogger(name string, component ConfigComponent)
RegisterLogger registers a component that implements ConfigLogging
func UpdateStructFromConfig ¶
UpdateStructFromConfig updates the *toStruct* fields from a config map represented as *fromConfig*. The function returns an error with a list of problematic fields in case of failure. The field name is taken from the mapstructure tag if available, otherwise from the struct field name.
UpdateStructFromConfig ensures that the *fromConfig* doesn't have a field that is not present in *toStruct*, and also validates the field types match. All the nested fields are examined recursively as well.
This function is primarily designed for configuration structs that use mapstructure tags for field mapping. It performs detailed validation before attempting to update the destination struct.
Types ¶
type Config ¶
type Config struct {
Server ConfigServer `mapstructure:"server"`
LLM ConfigLLM `mapstructure:"llm"`
}
Config represents the global configuration
func GetDefault ¶
func GetDefault() *Config
type ConfigComponent ¶
type ConfigComponent interface {
// Load loads and validates the configuration
Load(name string, config map[string]interface{}) error
// GetDefault returns the default configuration
GetDefault() interface{}
}
ConfigComponent is an interface that configuration components must implement
type ConfigLLM ¶
type ConfigLLM struct {
DefaultService string `mapstructure:"default_service"`
Temperature float64 `mapstructure:"temperature"`
MaxTokens int `mapstructure:"max_tokens"`
LLMServices map[string]ConfigLLMService `mapstructure:"services"`
}
type ConfigLLMService ¶
type ConfigLLMService struct {
APIFormat string `mapstructure:"api_format"` // e.g., "openai", "ollama", etc.
APIKeyEnvVar string `mapstructure:"api_key_env_var" doc:"Environment variable containing the API key for the LLM service"`
APIKey string `mapstructure:"api_key" doc:"API key for the LLM service"`
URLs []string `mapstructure:"urls"`
Model string `mapstructure:"model"` // Default model for this service, FIXME: not supported for now
Upstream ConfigUpstream `mapstructure:"upstream"`
}
ServiceConfig holds configuration for a specific LLM service type
type ConfigLogging ¶
type ConfigLogging struct {
ConsoleLevel string `mapstructure:"console_level" default:"info"`
FileLevel string `mapstructure:"file_level" default:"debug"`
File string `mapstructure:"file" default:"logs/main.log"`
MaxSizeMB int `mapstructure:"max_size_mb" default:"1000"`
MaxBackups int `mapstructure:"max_backups" default:"3"`
MaxAgeDays int `mapstructure:"max_age_days" default:"7"`
}
type ConfigServer ¶
type ConfigUpstream ¶
type ConfigUpstream struct {
ShortTimeoutSec int `mapstructure:"short_timeout_sec" default:"5"` // can be used for LLM operations requests
LongTimeoutSec int `mapstructure:"long_timeout_sec" default:"180"` // can be used for LLM chat requests
VerifyCert bool `mapstructure:"verify_cert"`
EnableDiscovery bool `mapstructure:"enable_discovery"`
}
ConfigUpstream holds configuration for upstream requests to LLM services.