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

View file

@ -75,6 +75,12 @@ func resolveProviderSelection(cfg *config.Config) (providerSelection, error) {
// First, prefer explicit provider configuration.
if 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":
if 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.
if sel.apiKey == "" && sel.apiBase == "" {
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 != "":
sel.apiKey = cfg.Providers.Moonshot.APIKey
sel.apiBase = cfg.Providers.Moonshot.APIBase