Merge 50ef8fd737 into 1d748fb742
This commit is contained in:
commit
02a4be8915
3 changed files with 36 additions and 2 deletions
|
|
@ -91,6 +91,10 @@
|
||||||
"api_key": "YOUR_ZHIPU_API_KEY",
|
"api_key": "YOUR_ZHIPU_API_KEY",
|
||||||
"api_base": ""
|
"api_base": ""
|
||||||
},
|
},
|
||||||
|
"zai": {
|
||||||
|
"api_key": "YOUR_ZAI_API_KEY",
|
||||||
|
"api_base": ""
|
||||||
|
},
|
||||||
"gemini": {
|
"gemini": {
|
||||||
"api_key": "",
|
"api_key": "",
|
||||||
"api_base": ""
|
"api_base": ""
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ type ProvidersConfig struct {
|
||||||
OpenRouter ProviderConfig `json:"openrouter"`
|
OpenRouter ProviderConfig `json:"openrouter"`
|
||||||
Groq ProviderConfig `json:"groq"`
|
Groq ProviderConfig `json:"groq"`
|
||||||
Zhipu ProviderConfig `json:"zhipu"`
|
Zhipu ProviderConfig `json:"zhipu"`
|
||||||
|
ZAI ProviderConfig `json:"zai"`
|
||||||
VLLM ProviderConfig `json:"vllm"`
|
VLLM ProviderConfig `json:"vllm"`
|
||||||
Gemini ProviderConfig `json:"gemini"`
|
Gemini ProviderConfig `json:"gemini"`
|
||||||
Nvidia ProviderConfig `json:"nvidia"`
|
Nvidia ProviderConfig `json:"nvidia"`
|
||||||
|
|
@ -299,6 +300,7 @@ func DefaultConfig() *Config {
|
||||||
OpenRouter: ProviderConfig{},
|
OpenRouter: ProviderConfig{},
|
||||||
Groq: ProviderConfig{},
|
Groq: ProviderConfig{},
|
||||||
Zhipu: ProviderConfig{},
|
Zhipu: ProviderConfig{},
|
||||||
|
ZAI: ProviderConfig{},
|
||||||
VLLM: ProviderConfig{},
|
VLLM: ProviderConfig{},
|
||||||
Gemini: ProviderConfig{},
|
Gemini: ProviderConfig{},
|
||||||
Nvidia: ProviderConfig{},
|
Nvidia: ProviderConfig{},
|
||||||
|
|
@ -396,6 +398,9 @@ func (c *Config) GetAPIKey() string {
|
||||||
if c.Providers.Zhipu.APIKey != "" {
|
if c.Providers.Zhipu.APIKey != "" {
|
||||||
return c.Providers.Zhipu.APIKey
|
return c.Providers.Zhipu.APIKey
|
||||||
}
|
}
|
||||||
|
if c.Providers.ZAI.APIKey != "" {
|
||||||
|
return c.Providers.ZAI.APIKey
|
||||||
|
}
|
||||||
if c.Providers.Groq.APIKey != "" {
|
if c.Providers.Groq.APIKey != "" {
|
||||||
return c.Providers.Groq.APIKey
|
return c.Providers.Groq.APIKey
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ func (p *HTTPProvider) Chat(ctx context.Context, messages []Message, tools []Too
|
||||||
// Strip provider prefix from model name (e.g., moonshot/kimi-k2.5 -> kimi-k2.5)
|
// Strip provider prefix from model name (e.g., moonshot/kimi-k2.5 -> kimi-k2.5)
|
||||||
if idx := strings.Index(model, "/"); idx != -1 {
|
if idx := strings.Index(model, "/"); idx != -1 {
|
||||||
prefix := model[:idx]
|
prefix := model[:idx]
|
||||||
if prefix == "moonshot" || prefix == "nvidia" {
|
if prefix == "moonshot" || prefix == "nvidia" || prefix == "zai" {
|
||||||
model = model[idx+1:]
|
model = model[idx+1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +277,19 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
|
||||||
apiBase = "https://open.bigmodel.cn/api/paas/v4"
|
apiBase = "https://open.bigmodel.cn/api/paas/v4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "zai", "z.ai":
|
||||||
|
if cfg.Providers.ZAI.APIKey != "" {
|
||||||
|
apiKey = cfg.Providers.ZAI.APIKey
|
||||||
|
apiBase = cfg.Providers.ZAI.APIBase
|
||||||
|
proxy = cfg.Providers.ZAI.Proxy
|
||||||
|
if apiBase == "" {
|
||||||
|
if strings.Contains(lowerModel, "coding") {
|
||||||
|
apiBase = "https://api.z.ai/api/coding/paas/v4"
|
||||||
|
} else {
|
||||||
|
apiBase = "https://api.z.ai/api/paas/v4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "gemini", "google":
|
case "gemini", "google":
|
||||||
if cfg.Providers.Gemini.APIKey != "" {
|
if cfg.Providers.Gemini.APIKey != "" {
|
||||||
apiKey = cfg.Providers.Gemini.APIKey
|
apiKey = cfg.Providers.Gemini.APIKey
|
||||||
|
|
@ -377,7 +390,19 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
|
||||||
apiBase = "https://generativelanguage.googleapis.com/v1beta"
|
apiBase = "https://generativelanguage.googleapis.com/v1beta"
|
||||||
}
|
}
|
||||||
|
|
||||||
case (strings.Contains(lowerModel, "glm") || strings.Contains(lowerModel, "zhipu") || strings.Contains(lowerModel, "zai")) && cfg.Providers.Zhipu.APIKey != "":
|
case (strings.Contains(lowerModel, "glm") || strings.Contains(lowerModel, "cogview") || strings.Contains(lowerModel, "cogvideo") || strings.Contains(lowerModel, "autoglm") || strings.Contains(lowerModel, "vidu")) && cfg.Providers.ZAI.APIKey != "":
|
||||||
|
apiKey = cfg.Providers.ZAI.APIKey
|
||||||
|
apiBase = cfg.Providers.ZAI.APIBase
|
||||||
|
proxy = cfg.Providers.ZAI.Proxy
|
||||||
|
if apiBase == "" {
|
||||||
|
if strings.Contains(lowerModel, "coding") {
|
||||||
|
apiBase = "https://api.z.ai/api/coding/paas/v4"
|
||||||
|
} else {
|
||||||
|
apiBase = "https://api.z.ai/api/paas/v4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case (strings.Contains(lowerModel, "glm") || strings.Contains(lowerModel, "zhipu")) && cfg.Providers.Zhipu.APIKey != "":
|
||||||
apiKey = cfg.Providers.Zhipu.APIKey
|
apiKey = cfg.Providers.Zhipu.APIKey
|
||||||
apiBase = cfg.Providers.Zhipu.APIBase
|
apiBase = cfg.Providers.Zhipu.APIBase
|
||||||
proxy = cfg.Providers.Zhipu.Proxy
|
proxy = cfg.Providers.Zhipu.Proxy
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue