Merge PR #368: Add Volcengine (doubao) provider

This commit is contained in:
yinwm 2026-02-17 23:51:40 +08:00
commit 6913edbb5b
5 changed files with 41 additions and 0 deletions

View file

@ -39,6 +39,8 @@ ifeq ($(UNAME_S),Linux)
ARCH=amd64 ARCH=amd64
else ifeq ($(UNAME_M),aarch64) else ifeq ($(UNAME_M),aarch64)
ARCH=arm64 ARCH=arm64
else ifeq ($(UNAME_M),loongarch64)
ARCH=loong64
else ifeq ($(UNAME_M),riscv64) else ifeq ($(UNAME_M),riscv64)
ARCH=riscv64 ARCH=riscv64
else else
@ -84,6 +86,7 @@ build-all: generate
@mkdir -p $(BUILD_DIR) @mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./$(CMD_DIR) GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./$(CMD_DIR)
GOOS=linux GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./$(CMD_DIR) GOOS=linux GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./$(CMD_DIR)
GOOS=linux GOARCH=loong64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-loong64 ./$(CMD_DIR)
GOOS=linux GOARCH=riscv64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-riscv64 ./$(CMD_DIR) GOOS=linux GOARCH=riscv64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-riscv64 ./$(CMD_DIR)
GOOS=darwin GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./$(CMD_DIR) GOOS=darwin GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./$(CMD_DIR)
GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR) GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR)

View file

@ -730,6 +730,11 @@ func statusCmd() {
hasQwen := cfg.Providers.Qwen.APIKey != "" hasQwen := cfg.Providers.Qwen.APIKey != ""
hasGroq := cfg.Providers.Groq.APIKey != "" hasGroq := cfg.Providers.Groq.APIKey != ""
hasVLLM := cfg.Providers.VLLM.APIBase != "" hasVLLM := cfg.Providers.VLLM.APIBase != ""
hasMoonshot := cfg.Providers.Moonshot.APIKey != ""
hasDeepSeek := cfg.Providers.DeepSeek.APIKey != ""
hasVolcEngine := cfg.Providers.VolcEngine.APIKey != ""
hasNvidia := cfg.Providers.Nvidia.APIKey != ""
hasOllama := cfg.Providers.Ollama.APIBase != ""
status := func(enabled bool) string { status := func(enabled bool) string {
if enabled { if enabled {
@ -744,11 +749,20 @@ func statusCmd() {
fmt.Println("Zhipu API:", status(hasZhipu)) fmt.Println("Zhipu API:", status(hasZhipu))
fmt.Println("Qwen API:", status(hasQwen)) fmt.Println("Qwen API:", status(hasQwen))
fmt.Println("Groq API:", status(hasGroq)) fmt.Println("Groq API:", status(hasGroq))
fmt.Println("Moonshot API:", status(hasMoonshot))
fmt.Println("DeepSeek API:", status(hasDeepSeek))
fmt.Println("VolcEngine API:", status(hasVolcEngine))
fmt.Println("Nvidia API:", status(hasNvidia))
if hasVLLM { if hasVLLM {
fmt.Printf("vLLM/Local: ✓ %s\n", cfg.Providers.VLLM.APIBase) fmt.Printf("vLLM/Local: ✓ %s\n", cfg.Providers.VLLM.APIBase)
} else { } else {
fmt.Println("vLLM/Local: not set") fmt.Println("vLLM/Local: not set")
} }
if hasOllama {
fmt.Printf("Ollama: ✓ %s\n", cfg.Providers.Ollama.APIBase)
} else {
fmt.Println("Ollama: not set")
}
store, _ := auth.LoadStore() store, _ := auth.LoadStore()
if store != nil && len(store.Credentials) > 0 { if store != nil && len(store.Credentials) > 0 {

View file

@ -121,6 +121,10 @@
"cerebras": { "cerebras": {
"api_key": "", "api_key": "",
"api_base": "" "api_base": ""
},
"volcengine": {
"api_key": "",
"api_base": ""
} }
}, },
"tools": { "tools": {

View file

@ -180,6 +180,7 @@ type ProvidersConfig struct {
ShengSuanYun ProviderConfig `json:"shengsuanyun"` ShengSuanYun ProviderConfig `json:"shengsuanyun"`
DeepSeek ProviderConfig `json:"deepseek"` DeepSeek ProviderConfig `json:"deepseek"`
Cerebras ProviderConfig `json:"cerebras"` Cerebras ProviderConfig `json:"cerebras"`
VolcEngine ProviderConfig `json:"volcengine"`
GitHubCopilot ProviderConfig `json:"github_copilot"` GitHubCopilot ProviderConfig `json:"github_copilot"`
Qwen ProviderConfig `json:"qwen"` Qwen ProviderConfig `json:"qwen"`
} }
@ -320,6 +321,7 @@ func DefaultConfig() *Config {
Moonshot: ProviderConfig{}, Moonshot: ProviderConfig{},
ShengSuanYun: ProviderConfig{}, ShengSuanYun: ProviderConfig{},
Cerebras: ProviderConfig{}, Cerebras: ProviderConfig{},
VolcEngine: ProviderConfig{},
}, },
Gateway: GatewayConfig{ Gateway: GatewayConfig{
Host: "0.0.0.0", Host: "0.0.0.0",

View file

@ -348,6 +348,15 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
} }
return NewGitHubCopilotProvider(apiBase, cfg.Providers.GitHubCopilot.ConnectMode, model) 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"
}
}
} }
} }
@ -450,6 +459,15 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
apiBase = "http://localhost:11434/v1" apiBase = "http://localhost:11434/v1"
} }
fmt.Println("Ollama apiBase:", apiBase) fmt.Println("Ollama apiBase:", apiBase)
case (strings.Contains(lowerModel, "doubao") || strings.HasPrefix(lowerModel, "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 != "": case cfg.Providers.VLLM.APIBase != "":
apiKey = cfg.Providers.VLLM.APIKey apiKey = cfg.Providers.VLLM.APIKey
apiBase = cfg.Providers.VLLM.APIBase apiBase = cfg.Providers.VLLM.APIBase