Documentation
¶
Overview ¶
Package config provides shared configuration structures and utilities for AI Provider Kit example programs. It handles parsing the standard config.yaml format and converting it to types.ProviderConfig structures.
Index ¶
- func BuildProviderConfig(name string, entry *ProviderConfigEntry) types.ProviderConfig
- func ConvertOAuthCredentials(entries []OAuthCredentialEntry) []*types.OAuthCredentialSet
- func DetermineProviderType(name string, entry *ProviderConfigEntry) types.ProviderType
- func MaskAPIKey(key string) string
- type AsyncConfig
- type DemoConfig
- type MetricsConfig
- type OAuthCredentialEntry
- type ProviderConfigEntry
- type ProvidersConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildProviderConfig ¶
func BuildProviderConfig(name string, entry *ProviderConfigEntry) types.ProviderConfig
BuildProviderConfig constructs a types.ProviderConfig from a ProviderConfigEntry This converts the config file format into the structure required by the ai-provider-kit module.
func ConvertOAuthCredentials ¶
func ConvertOAuthCredentials(entries []OAuthCredentialEntry) []*types.OAuthCredentialSet
ConvertOAuthCredentials converts []OAuthCredentialEntry to []*types.OAuthCredentialSet
func DetermineProviderType ¶
func DetermineProviderType(name string, entry *ProviderConfigEntry) types.ProviderType
DetermineProviderType determines the types.ProviderType based on name and config
func MaskAPIKey ¶
MaskAPIKey masks an API key for display purposes
Types ¶
type AsyncConfig ¶
type AsyncConfig struct {
Enabled bool `yaml:"enabled"`
}
AsyncConfig represents async configuration
type DemoConfig ¶
type DemoConfig struct {
Providers ProvidersConfig `yaml:"providers"`
Metrics MetricsConfig `yaml:"metrics,omitempty"`
Async AsyncConfig `yaml:"async,omitempty"`
}
DemoConfig represents the complete configuration structure
func LoadConfig ¶
func LoadConfig(filename string) (*DemoConfig, error)
LoadConfig loads and parses a YAML configuration file
type MetricsConfig ¶
MetricsConfig represents metrics configuration
type OAuthCredentialEntry ¶
type OAuthCredentialEntry struct {
// Unique identifier for this credential set
ID string `yaml:"id"`
// OAuth client credentials
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
// OAuth tokens
AccessToken string `yaml:"access_token"`
RefreshToken string `yaml:"refresh_token"`
// Token expiration
ExpiresAt string `yaml:"expires_at"`
// OAuth scopes
Scopes []string `yaml:"scopes"`
}
OAuthCredentialEntry represents a single set of OAuth credentials
type ProviderConfigEntry ¶
type ProviderConfigEntry struct {
// Provider type (e.g., "openai", "anthropic", "gemini")
// For custom providers, this specifies which provider API to use
Type string `yaml:"type"`
// Default model to use for this provider
DefaultModel string `yaml:"default_model"`
// Base URL for the provider API (optional, uses provider default if not set)
BaseURL string `yaml:"base_url"`
// Single API key (used if only one key is needed)
APIKey string `yaml:"api_key"`
// Multiple API keys for load balancing or failover
APIKeys []string `yaml:"api_keys"`
// Project ID (used by some providers like Gemini)
ProjectID string `yaml:"project_id"`
// Maximum tokens for completions
MaxTokens int `yaml:"max_tokens"`
// Temperature for response generation
Temperature float64 `yaml:"temperature"`
// OAuth credentials (can have multiple sets for failover)
OAuthCredentials []OAuthCredentialEntry `yaml:"oauth_credentials"`
// Custom provider-specific models list
Models interface{} `yaml:"models,omitempty"`
}
ProviderConfigEntry represents a single provider's configuration
func GetProviderEntry ¶
func GetProviderEntry(config *DemoConfig, name string) *ProviderConfigEntry
GetProviderEntry retrieves the provider config entry for a given provider name
type ProvidersConfig ¶
type ProvidersConfig struct {
// List of enabled providers
Enabled []string `yaml:"enabled"`
// Preferred order for provider selection
PreferredOrder []string `yaml:"preferred_order"`
// Built-in provider configurations
Anthropic *ProviderConfigEntry `yaml:"anthropic,omitempty"`
OpenAI *ProviderConfigEntry `yaml:"openai,omitempty"`
Cerebras *ProviderConfigEntry `yaml:"cerebras,omitempty"`
Gemini *ProviderConfigEntry `yaml:"gemini,omitempty"`
Qwen *ProviderConfigEntry `yaml:"qwen,omitempty"`
OpenRouter *ProviderConfigEntry `yaml:"openrouter,omitempty"`
// Custom providers (map of provider name to config)
Custom map[string]ProviderConfigEntry `yaml:"custom,omitempty"`
}
ProvidersConfig contains all provider configurations