From 3a30c152c9c68c02d2a40ad02fd3a0ea88e731eb Mon Sep 17 00:00:00 2001 From: cointem Date: Wed, 18 Feb 2026 01:01:13 +0800 Subject: [PATCH] feat: add Bailian provider configuration and integration --- config/config.example.json | 4 ++++ pkg/config/config.go | 7 ++++--- pkg/providers/http_provider.go | 9 ++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/config.example.json b/config/config.example.json index 7cd0ab8c6..3a395718f 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -93,6 +93,10 @@ "api_key": "YOUR_ZHIPU_API_KEY", "api_base": "" }, + "bailian": { + "api_key": "YOUR_BAILIAN_API_KEY", + "api_base": "" + }, "gemini": { "api_key": "", "api_base": "" diff --git a/pkg/config/config.go b/pkg/config/config.go index 1d34f56f3..987df8b7f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -172,6 +172,7 @@ type ProvidersConfig struct { OpenRouter ProviderConfig `json:"openrouter"` Groq ProviderConfig `json:"groq"` Zhipu ProviderConfig `json:"zhipu"` + Bailian ProviderConfig `json:"bailian"` VLLM ProviderConfig `json:"vllm"` Gemini ProviderConfig `json:"gemini"` Nvidia ProviderConfig `json:"nvidia"` @@ -187,7 +188,7 @@ type ProviderConfig struct { APIBase string `json:"api_base" env:"PICOCLAW_PROVIDERS_{{.Name}}_API_BASE"` Proxy string `json:"proxy,omitempty" env:"PICOCLAW_PROVIDERS_{{.Name}}_PROXY"` AuthMethod string `json:"auth_method,omitempty" env:"PICOCLAW_PROVIDERS_{{.Name}}_AUTH_METHOD"` - ConnectMode string `json:"connect_mode,omitempty" env:"PICOCLAW_PROVIDERS_{{.Name}}_CONNECT_MODE"` //only for Github Copilot, `stdio` or `grpc` + ConnectMode string `json:"connect_mode,omitempty" env:"PICOCLAW_PROVIDERS_{{.Name}}_CONNECT_MODE"` // only for Github Copilot, `stdio` or `grpc` } type GatewayConfig struct { @@ -386,11 +387,11 @@ func SaveConfig(path string, cfg *Config) error { } dir := filepath.Dir(path) - if err := os.MkdirAll(dir, 0755); err != nil { + if err := os.MkdirAll(dir, 0o755); err != nil { return err } - return os.WriteFile(path, data, 0600) + return os.WriteFile(path, data, 0o600) } func (c *Config) WorkspacePath() string { diff --git a/pkg/providers/http_provider.go b/pkg/providers/http_provider.go index 4cf2c6db2..6ba0006ee 100644 --- a/pkg/providers/http_provider.go +++ b/pkg/providers/http_provider.go @@ -280,6 +280,14 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) { apiBase = "https://open.bigmodel.cn/api/paas/v4" } } + case "bailian", "dashscope", "aliyun": + if cfg.Providers.Bailian.APIKey != "" { + apiKey = cfg.Providers.Bailian.APIKey + apiBase = cfg.Providers.Bailian.APIBase + if apiBase == "" { + apiBase = "https://dashscope.aliyuncs.com/compatible-mode/v1" + } + } case "gemini", "google": if cfg.Providers.Gemini.APIKey != "" { apiKey = cfg.Providers.Gemini.APIKey @@ -333,7 +341,6 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) { return NewGitHubCopilotProvider(apiBase, cfg.Providers.GitHubCopilot.ConnectMode, model) } - } // Fallback: detect provider from model name