From 2f24be6c59cb6fe1edb32e86b05a44947bdc0158 Mon Sep 17 00:00:00 2001 From: likeaturtle Date: Tue, 17 Feb 2026 22:31:19 +0800 Subject: [PATCH] add Volcengine LLM (doubao) support --- config/config.example.json | 4 ++++ pkg/config/config.go | 2 ++ pkg/providers/http_provider.go | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/config/config.example.json b/config/config.example.json index 7cd0ab8c6..0a3af40f3 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -113,6 +113,10 @@ "ollama": { "api_key": "", "api_base": "http://localhost:11434/v1" + }, + "volcengine": { + "api_key": "", + "api_base": "" } }, "tools": { diff --git a/pkg/config/config.go b/pkg/config/config.go index 1d34f56f3..82a9a82a3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -179,6 +179,7 @@ type ProvidersConfig struct { Moonshot ProviderConfig `json:"moonshot"` ShengSuanYun ProviderConfig `json:"shengsuanyun"` DeepSeek ProviderConfig `json:"deepseek"` + VolcEngine ProviderConfig `json:"volcengine"` GitHubCopilot ProviderConfig `json:"github_copilot"` } @@ -317,6 +318,7 @@ func DefaultConfig() *Config { Nvidia: ProviderConfig{}, Moonshot: ProviderConfig{}, ShengSuanYun: ProviderConfig{}, + VolcEngine: ProviderConfig{}, }, Gateway: GatewayConfig{ Host: "0.0.0.0", diff --git a/pkg/providers/http_provider.go b/pkg/providers/http_provider.go index 4cf2c6db2..72e7b05cf 100644 --- a/pkg/providers/http_provider.go +++ b/pkg/providers/http_provider.go @@ -332,6 +332,15 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) { } return NewGitHubCopilotProvider(apiBase, cfg.Providers.GitHubCopilot.ConnectMode, model) + case "volcengine", "doubao": + if cfg.Providers.VolcEngine.APIKey != "" { + apiKey = cfg.Providers.VolcEngine.APIKey + apiBase = cfg.Providers.VolcEngine.APIBase + if apiBase == "" { + apiBase = "https://ark.cn-beijing.volces.com/api/v3" + } + } + } } @@ -418,6 +427,15 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) { apiBase = "http://localhost:11434/v1" } fmt.Println("Ollama apiBase:", apiBase) + + case (strings.Contains(lowerModel, "doubao") || strings.HasPrefix(model, "doubao") || strings.Contains(lowerModel, "volcengine")) && cfg.Providers.VolcEngine.APIKey != "": + apiKey = cfg.Providers.VolcEngine.APIKey + apiBase = cfg.Providers.VolcEngine.APIBase + proxy = cfg.Providers.VolcEngine.Proxy + if apiBase == "" { + apiBase = "https://ark.cn-beijing.volces.com/api/v3" + } + case cfg.Providers.VLLM.APIBase != "": apiKey = cfg.Providers.VLLM.APIKey apiBase = cfg.Providers.VLLM.APIBase