Documentation
¶
Index ¶
- func LoadEnvFiles(envFiles []string)
- type Config
- func (c *Config) GetModelCapabilitiesFromEndpoint(endpoint string) []models.ModelCapability
- func (c *Config) GetNormalizedLogLevel() string
- func (c *Config) GetProviderAPIKey(provider, endpoint string) string
- func (c *Config) GetProviderConfig(provider, endpoint string) (models.ProviderConfig, bool)
- func (c *Config) GetProviders(endpoint string) map[string]models.ProviderConfig
- func (c *Config) IsProduction() bool
- func (c *Config) MergeFallbackConfig(override *models.FallbackConfig) *models.FallbackConfig
- func (c *Config) MergeModelRouterConfig(override *models.ModelRouterConfig, endpoint string) *models.ModelRouterConfig
- func (c *Config) MergeProviderConfig(providerName string, override *models.ProviderConfig, endpoint string) (models.ProviderConfig, error)
- func (c *Config) MergeProviderConfigs(overrides map[string]*models.ProviderConfig, endpoint string) (map[string]models.ProviderConfig, error)
- func (c *Config) ResolveConfig(req *models.ChatCompletionRequest, providerConfigSvc interface{ ... }) (*Config, error)
- func (c *Config) ResolveConfigFromAnthropicRequest(req *models.AnthropicMessageRequest, providerConfigSvc interface{ ... }) (*Config, error)
- func (c *Config) ResolveConfigFromGeminiCountTokensRequest(req *models.GeminiGenerateRequest) (*Config, error)
- func (c *Config) ResolveConfigFromGeminiRequest(req *models.GeminiGenerateRequest, providerConfigSvc interface{ ... }) (*Config, error)
- func (c *Config) Validate() error
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadEnvFiles ¶
func LoadEnvFiles(envFiles []string)
LoadEnvFiles loads environment variables from .env files in order of precedence Loads files in the order provided (first has highest priority)
Types ¶
type Config ¶
type Config struct {
Server models.ServerConfig `yaml:"server"`
Endpoints models.EndpointsConfig `yaml:"endpoints"`
Fallback models.FallbackConfig `yaml:"fallback"`
ModelRouter *models.ModelRouterConfig `yaml:"model_router,omitempty"`
Database *models.DatabaseConfig `yaml:"database,omitempty"`
Auth *models.AuthConfig `yaml:"auth,omitempty"`
Billing *models.StripeConfig `yaml:"billing,omitempty"`
APIKey *models.APIKeyConfig `yaml:"api_key,omitempty"`
CustomProviders map[string]map[string]bool `yaml:"-"`
}
Config represents the complete application configuration
func LoadFromFile ¶
LoadFromFile loads configuration from a YAML file with environment variable substitution
func (*Config) GetModelCapabilitiesFromEndpoint ¶
func (c *Config) GetModelCapabilitiesFromEndpoint(endpoint string) []models.ModelCapability
GetModelCapabilitiesFromEndpoint converts endpoint providers to ModelCapability list This allows constraining model router to only available providers for the endpoint
func (*Config) GetNormalizedLogLevel ¶
GetNormalizedLogLevel returns the log level in lowercase for consistent comparison
func (*Config) GetProviderAPIKey ¶
GetProviderAPIKey returns the API key for a specific provider from the specified endpoint
func (*Config) GetProviderConfig ¶
func (c *Config) GetProviderConfig(provider, endpoint string) (models.ProviderConfig, bool)
GetProviderConfig returns the configuration for a specific provider from the specified endpoint
func (*Config) GetProviders ¶
func (c *Config) GetProviders(endpoint string) map[string]models.ProviderConfig
GetProviders returns a map of all configured providers from the specified endpoint. If a provider is present in the config, it is considered enabled.
func (*Config) IsProduction ¶
IsProduction returns true if the environment is production
func (*Config) MergeFallbackConfig ¶
func (c *Config) MergeFallbackConfig(override *models.FallbackConfig) *models.FallbackConfig
MergeFallbackConfig merges YAML fallback config with request override. The request override takes precedence over YAML config. Fallback is disabled by default (empty mode), enabled when mode is set.
func (*Config) MergeModelRouterConfig ¶
func (c *Config) MergeModelRouterConfig(override *models.ModelRouterConfig, endpoint string) *models.ModelRouterConfig
MergeModelRouterConfig merges YAML model router config with request override. The request override takes precedence over YAML config for non-empty/non-nil values. If no models are specified, it populates them from the endpoint providers. Returns nil if ModelRouter is not configured.
func (*Config) MergeProviderConfig ¶
func (c *Config) MergeProviderConfig(providerName string, override *models.ProviderConfig, endpoint string) (models.ProviderConfig, error)
MergeProviderConfig merges YAML provider config with request override config. The request override takes precedence over YAML config for non-empty values.
func (*Config) MergeProviderConfigs ¶
func (c *Config) MergeProviderConfigs(overrides map[string]*models.ProviderConfig, endpoint string) (map[string]models.ProviderConfig, error)
MergeProviderConfigs merges YAML provider configs with a map of request override configs. Returns a map with all providers from YAML, with overrides applied where provided.
func (*Config) ResolveConfig ¶
func (c *Config) ResolveConfig(req *models.ChatCompletionRequest, providerConfigSvc interface { PopulateCustomProviders(ctx context.Context, projectID *uint, providers map[string]models.ProviderConfig, endpoint string) (map[string]map[string]bool, error) }, ) (*Config, error)
ResolveConfig creates a resolved config by merging YAML config with all request overrides. Returns a new Config struct with all merged values as single source of truth.
func (*Config) ResolveConfigFromAnthropicRequest ¶
func (c *Config) ResolveConfigFromAnthropicRequest(req *models.AnthropicMessageRequest, providerConfigSvc interface { PopulateCustomProviders(ctx context.Context, projectID *uint, providers map[string]models.ProviderConfig, endpoint string) (map[string]map[string]bool, error) }, ) (*Config, error)
ResolveConfigFromAnthropicRequest creates a resolved config by merging YAML config with Anthropic request overrides. Returns a new Config struct with all merged values as single source of truth.
func (*Config) ResolveConfigFromGeminiCountTokensRequest ¶
func (c *Config) ResolveConfigFromGeminiCountTokensRequest(req *models.GeminiGenerateRequest) (*Config, error)
ResolveConfigFromGeminiCountTokensRequest creates a resolved config for count_tokens endpoint
func (*Config) ResolveConfigFromGeminiRequest ¶
func (c *Config) ResolveConfigFromGeminiRequest(req *models.GeminiGenerateRequest, providerConfigSvc interface { PopulateCustomProviders(ctx context.Context, projectID *uint, providers map[string]models.ProviderConfig, endpoint string) (map[string]map[string]bool, error) }, ) (*Config, error)
ResolveConfigFromGeminiRequest creates a resolved config by merging YAML config with Gemini request overrides. Returns a new Config struct with all merged values as single source of truth.
type ValidationError ¶
type ValidationError struct {
MissingFields []string
}
ValidationError represents configuration validation errors
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string