This commit is contained in:
cuandada 2026-02-19 07:05:43 +00:00 committed by GitHub
commit 02bac74b11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -263,6 +263,7 @@ type ProvidersConfig struct {
ShengSuanYun ProviderConfig `json:"shengsuanyun"` ShengSuanYun ProviderConfig `json:"shengsuanyun"`
DeepSeek ProviderConfig `json:"deepseek"` DeepSeek ProviderConfig `json:"deepseek"`
GitHubCopilot ProviderConfig `json:"github_copilot"` GitHubCopilot ProviderConfig `json:"github_copilot"`
Custom ProviderConfig `json:"custom"`
} }
type ProviderConfig struct { type ProviderConfig struct {
@ -411,6 +412,7 @@ func DefaultConfig() *Config {
Nvidia: ProviderConfig{}, Nvidia: ProviderConfig{},
Moonshot: ProviderConfig{}, Moonshot: ProviderConfig{},
ShengSuanYun: ProviderConfig{}, ShengSuanYun: ProviderConfig{},
Custom: ProviderConfig{},
}, },
Gateway: GatewayConfig{ Gateway: GatewayConfig{
Host: "0.0.0.0", Host: "0.0.0.0",

View file

@ -75,6 +75,12 @@ func resolveProviderSelection(cfg *config.Config) (providerSelection, error) {
// First, prefer explicit provider configuration. // First, prefer explicit provider configuration.
if providerName != "" { if providerName != "" {
switch providerName { switch providerName {
case "custom":
if cfg.Providers.Custom.APIBase != "" {
sel.apiKey = cfg.Providers.Custom.APIKey
sel.apiBase = cfg.Providers.Custom.APIBase
sel.proxy = cfg.Providers.Custom.Proxy
}
case "groq": case "groq":
if cfg.Providers.Groq.APIKey != "" { if cfg.Providers.Groq.APIKey != "" {
sel.apiKey = cfg.Providers.Groq.APIKey sel.apiKey = cfg.Providers.Groq.APIKey
@ -214,6 +220,10 @@ func resolveProviderSelection(cfg *config.Config) (providerSelection, error) {
// Fallback: infer provider from model and configured keys. // Fallback: infer provider from model and configured keys.
if sel.apiKey == "" && sel.apiBase == "" { if sel.apiKey == "" && sel.apiBase == "" {
switch { switch {
case cfg.Providers.Custom.APIBase != "":
sel.apiKey = cfg.Providers.Custom.APIKey
sel.apiBase = cfg.Providers.Custom.APIBase
sel.proxy = cfg.Providers.Custom.Proxy
case (strings.Contains(lowerModel, "kimi") || strings.Contains(lowerModel, "moonshot") || strings.HasPrefix(model, "moonshot/")) && cfg.Providers.Moonshot.APIKey != "": case (strings.Contains(lowerModel, "kimi") || strings.Contains(lowerModel, "moonshot") || strings.HasPrefix(model, "moonshot/")) && cfg.Providers.Moonshot.APIKey != "":
sel.apiKey = cfg.Providers.Moonshot.APIKey sel.apiKey = cfg.Providers.Moonshot.APIKey
sel.apiBase = cfg.Providers.Moonshot.APIBase sel.apiBase = cfg.Providers.Moonshot.APIBase