Documentation
¶
Overview ¶
Package config provides configuration utilities for AI provider implementations
Index ¶
- Variables
- func GetModelCacheTTL(providerType types.ProviderType) time.Duration
- type CacheConfig
- type ConfigHelper
- func (h *ConfigHelper) ApplyTopLevelOverrides(config types.ProviderConfig, providerConfig interface{}) error
- func (h *ConfigHelper) ConfigSummary(config types.ProviderConfig) map[string]interface{}
- func (h *ConfigHelper) ExtractAPIKeys(config types.ProviderConfig) []string
- func (h *ConfigHelper) ExtractBaseURL(config types.ProviderConfig) string
- func (h *ConfigHelper) ExtractDefaultModel(config types.ProviderConfig) string
- func (h *ConfigHelper) ExtractDefaultOAuthClientID() string
- func (h *ConfigHelper) ExtractMaxTokens(config types.ProviderConfig) int
- func (h *ConfigHelper) ExtractProviderSpecificConfig(config types.ProviderConfig, target interface{}) error
- func (h *ConfigHelper) ExtractStringField(config types.ProviderConfig, fieldName, fallback string) string
- func (h *ConfigHelper) ExtractStringSliceField(config types.ProviderConfig, fieldName string) []string
- func (h *ConfigHelper) ExtractTimeout(config types.ProviderConfig) time.Duration
- func (h *ConfigHelper) GetProviderCapabilities() (supportsToolCalling, supportsStreaming, supportsResponsesAPI bool)
- func (h *ConfigHelper) MergeWithDefaults(config types.ProviderConfig) types.ProviderConfig
- func (h *ConfigHelper) SanitizeConfigForLogging(config types.ProviderConfig) types.ProviderConfig
- func (h *ConfigHelper) ValidateProviderConfig(config types.ProviderConfig) ValidationResult
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var DefaultCacheConfigs = map[types.ProviderType]CacheConfig{ types.ProviderTypeAnthropic: {ModelCacheTTL: 6 * time.Hour}, types.ProviderTypeOpenAI: {ModelCacheTTL: 24 * time.Hour}, types.ProviderTypeGemini: {ModelCacheTTL: 2 * time.Hour}, types.ProviderTypeCerebras: {ModelCacheTTL: 6 * time.Hour}, types.ProviderTypeQwen: {ModelCacheTTL: 6 * time.Hour}, types.ProviderTypeOpenRouter: {ModelCacheTTL: 12 * time.Hour}, }
DefaultCacheConfigs maps provider types to their default cache configs
Functions ¶
func GetModelCacheTTL ¶
func GetModelCacheTTL(providerType types.ProviderType) time.Duration
GetModelCacheTTL returns the model cache TTL for a provider type. If the provider type is not found in DefaultCacheConfigs, it returns a default fallback of 6 hours.
Types ¶
type CacheConfig ¶
CacheConfig holds cache configuration for providers
type ConfigHelper ¶
type ConfigHelper struct {
// contains filtered or unexported fields
}
ConfigHelper provides standardized configuration validation, extraction, and defaults for all AI providers, eliminating duplicate configuration code.
func NewConfigHelper ¶
func NewConfigHelper(providerName string, providerType types.ProviderType) *ConfigHelper
NewConfigHelper creates a new configuration helper for a specific provider
func (*ConfigHelper) ApplyTopLevelOverrides ¶
func (h *ConfigHelper) ApplyTopLevelOverrides(config types.ProviderConfig, providerConfig interface{}) error
ApplyTopLevelOverrides applies top-level config fields to provider-specific config
func (*ConfigHelper) ConfigSummary ¶
func (h *ConfigHelper) ConfigSummary(config types.ProviderConfig) map[string]interface{}
ConfigSummary provides a human-readable summary of the configuration
func (*ConfigHelper) ExtractAPIKeys ¶
func (h *ConfigHelper) ExtractAPIKeys(config types.ProviderConfig) []string
ExtractAPIKeys extracts and consolidates API keys from various sources
func (*ConfigHelper) ExtractBaseURL ¶
func (h *ConfigHelper) ExtractBaseURL(config types.ProviderConfig) string
ExtractBaseURL extracts base URL with provider-specific defaults
func (*ConfigHelper) ExtractDefaultModel ¶
func (h *ConfigHelper) ExtractDefaultModel(config types.ProviderConfig) string
ExtractDefaultModel extracts default model from config Note: Does not provide fallback defaults - each provider handles its own defaults via GetDefaultModel()
func (*ConfigHelper) ExtractDefaultOAuthClientID ¶
func (h *ConfigHelper) ExtractDefaultOAuthClientID() string
ExtractDefaultOAuthClientID returns provider-specific default OAuth client IDs
func (*ConfigHelper) ExtractMaxTokens ¶
func (h *ConfigHelper) ExtractMaxTokens(config types.ProviderConfig) int
ExtractMaxTokens extracts max tokens with provider-specific defaults
func (*ConfigHelper) ExtractProviderSpecificConfig ¶
func (h *ConfigHelper) ExtractProviderSpecificConfig(config types.ProviderConfig, target interface{}) error
ExtractProviderSpecificConfig extracts provider-specific configuration into a struct
func (*ConfigHelper) ExtractStringField ¶
func (h *ConfigHelper) ExtractStringField(config types.ProviderConfig, fieldName, fallback string) string
ExtractStringField extracts a string field from provider config with fallback
func (*ConfigHelper) ExtractStringSliceField ¶
func (h *ConfigHelper) ExtractStringSliceField(config types.ProviderConfig, fieldName string) []string
ExtractStringSliceField extracts a string slice field from provider config
func (*ConfigHelper) ExtractTimeout ¶
func (h *ConfigHelper) ExtractTimeout(config types.ProviderConfig) time.Duration
ExtractTimeout extracts timeout with sensible defaults
func (*ConfigHelper) GetProviderCapabilities ¶
func (h *ConfigHelper) GetProviderCapabilities() (supportsToolCalling, supportsStreaming, supportsResponsesAPI bool)
GetProviderCapabilities returns the capabilities flags for the provider
func (*ConfigHelper) MergeWithDefaults ¶
func (h *ConfigHelper) MergeWithDefaults(config types.ProviderConfig) types.ProviderConfig
MergeWithDefaults merges the provided config with provider defaults
func (*ConfigHelper) SanitizeConfigForLogging ¶
func (h *ConfigHelper) SanitizeConfigForLogging(config types.ProviderConfig) types.ProviderConfig
SanitizeConfigForLogging returns a configuration copy with sensitive data removed
func (*ConfigHelper) ValidateProviderConfig ¶
func (h *ConfigHelper) ValidateProviderConfig(config types.ProviderConfig) ValidationResult
ValidateProviderConfig performs comprehensive configuration validation
type ValidationResult ¶
ValidationResult contains the result of configuration validation