add Vivgrid config
This commit is contained in:
parent
42fc589a75
commit
ea0b634b3b
10 changed files with 79 additions and 9 deletions
|
|
@ -397,6 +397,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"`
|
||||||
|
Vivgrid ProviderConfig `json:"vivgrid"`
|
||||||
VolcEngine ProviderConfig `json:"volcengine"`
|
VolcEngine ProviderConfig `json:"volcengine"`
|
||||||
GitHubCopilot ProviderConfig `json:"github_copilot"`
|
GitHubCopilot ProviderConfig `json:"github_copilot"`
|
||||||
Antigravity ProviderConfig `json:"antigravity"`
|
Antigravity ProviderConfig `json:"antigravity"`
|
||||||
|
|
@ -420,6 +421,7 @@ func (p ProvidersConfig) IsEmpty() bool {
|
||||||
p.ShengSuanYun.APIKey == "" && p.ShengSuanYun.APIBase == "" &&
|
p.ShengSuanYun.APIKey == "" && p.ShengSuanYun.APIBase == "" &&
|
||||||
p.DeepSeek.APIKey == "" && p.DeepSeek.APIBase == "" &&
|
p.DeepSeek.APIKey == "" && p.DeepSeek.APIBase == "" &&
|
||||||
p.Cerebras.APIKey == "" && p.Cerebras.APIBase == "" &&
|
p.Cerebras.APIKey == "" && p.Cerebras.APIBase == "" &&
|
||||||
|
p.Vivgrid.APIKey == "" && p.Vivgrid.APIBase == "" &&
|
||||||
p.VolcEngine.APIKey == "" && p.VolcEngine.APIBase == "" &&
|
p.VolcEngine.APIKey == "" && p.VolcEngine.APIBase == "" &&
|
||||||
p.GitHubCopilot.APIKey == "" && p.GitHubCopilot.APIBase == "" &&
|
p.GitHubCopilot.APIKey == "" && p.GitHubCopilot.APIBase == "" &&
|
||||||
p.Antigravity.APIKey == "" && p.Antigravity.APIBase == "" &&
|
p.Antigravity.APIKey == "" && p.Antigravity.APIBase == "" &&
|
||||||
|
|
@ -761,6 +763,7 @@ func (c *Config) HasProvidersConfig() bool {
|
||||||
v.ShengSuanYun.APIKey != "" || v.ShengSuanYun.APIBase != "" ||
|
v.ShengSuanYun.APIKey != "" || v.ShengSuanYun.APIBase != "" ||
|
||||||
v.DeepSeek.APIKey != "" || v.DeepSeek.APIBase != "" ||
|
v.DeepSeek.APIKey != "" || v.DeepSeek.APIBase != "" ||
|
||||||
v.Cerebras.APIKey != "" || v.Cerebras.APIBase != "" ||
|
v.Cerebras.APIKey != "" || v.Cerebras.APIBase != "" ||
|
||||||
|
v.Vivgrid.APIKey != "" || v.Vivgrid.APIBase != "" ||
|
||||||
v.VolcEngine.APIKey != "" || v.VolcEngine.APIBase != "" ||
|
v.VolcEngine.APIKey != "" || v.VolcEngine.APIBase != "" ||
|
||||||
v.GitHubCopilot.APIKey != "" || v.GitHubCopilot.APIBase != "" ||
|
v.GitHubCopilot.APIKey != "" || v.GitHubCopilot.APIBase != "" ||
|
||||||
v.Antigravity.APIKey != "" || v.Antigravity.APIBase != "" ||
|
v.Antigravity.APIKey != "" || v.Antigravity.APIBase != "" ||
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,14 @@ func DefaultConfig() *Config {
|
||||||
APIKey: "",
|
APIKey: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Vivgrid - https://vivgrid.com
|
||||||
|
{
|
||||||
|
ModelName: "vivgrid-auto",
|
||||||
|
Model: "vivgrid/auto",
|
||||||
|
APIBase: "https://api.vivgrid.com/v1",
|
||||||
|
APIKey: "",
|
||||||
|
},
|
||||||
|
|
||||||
// Volcengine (火山引擎) - https://console.volcengine.com/ark
|
// Volcengine (火山引擎) - https://console.volcengine.com/ark
|
||||||
{
|
{
|
||||||
ModelName: "doubao-pro",
|
ModelName: "doubao-pro",
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,23 @@ func ConvertProvidersToModelList(cfg *Config) []ModelConfig {
|
||||||
}, true
|
}, true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
providerNames: []string{"vivgrid"},
|
||||||
|
protocol: "vivgrid",
|
||||||
|
buildConfig: func(p ProvidersConfig) (ModelConfig, bool) {
|
||||||
|
if p.Vivgrid.APIKey == "" && p.Vivgrid.APIBase == "" {
|
||||||
|
return ModelConfig{}, false
|
||||||
|
}
|
||||||
|
return ModelConfig{
|
||||||
|
ModelName: "vivgrid",
|
||||||
|
Model: "vivgrid/auto",
|
||||||
|
APIKey: p.Vivgrid.APIKey,
|
||||||
|
APIBase: p.Vivgrid.APIBase,
|
||||||
|
Proxy: p.Vivgrid.Proxy,
|
||||||
|
RequestTimeout: p.Vivgrid.RequestTimeout,
|
||||||
|
}, true
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
providerNames: []string{"volcengine", "doubao"},
|
providerNames: []string{"volcengine", "doubao"},
|
||||||
protocol: "volcengine",
|
protocol: "volcengine",
|
||||||
|
|
|
||||||
|
|
@ -127,19 +127,20 @@ func TestConvertProvidersToModelList_AllProviders(t *testing.T) {
|
||||||
ShengSuanYun: ProviderConfig{APIKey: "key11"},
|
ShengSuanYun: ProviderConfig{APIKey: "key11"},
|
||||||
DeepSeek: ProviderConfig{APIKey: "key12"},
|
DeepSeek: ProviderConfig{APIKey: "key12"},
|
||||||
Cerebras: ProviderConfig{APIKey: "key13"},
|
Cerebras: ProviderConfig{APIKey: "key13"},
|
||||||
VolcEngine: ProviderConfig{APIKey: "key14"},
|
Vivgrid: ProviderConfig{APIKey: "key14"},
|
||||||
|
VolcEngine: ProviderConfig{APIKey: "key15"},
|
||||||
GitHubCopilot: ProviderConfig{ConnectMode: "grpc"},
|
GitHubCopilot: ProviderConfig{ConnectMode: "grpc"},
|
||||||
Antigravity: ProviderConfig{AuthMethod: "oauth"},
|
Antigravity: ProviderConfig{AuthMethod: "oauth"},
|
||||||
Qwen: ProviderConfig{APIKey: "key17"},
|
Qwen: ProviderConfig{APIKey: "key18"},
|
||||||
Mistral: ProviderConfig{APIKey: "key18"},
|
Mistral: ProviderConfig{APIKey: "key19"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
result := ConvertProvidersToModelList(cfg)
|
result := ConvertProvidersToModelList(cfg)
|
||||||
|
|
||||||
// All 18 providers should be converted
|
// All 19 providers should be converted
|
||||||
if len(result) != 18 {
|
if len(result) != 19 {
|
||||||
t.Errorf("len(result) = %d, want 18", len(result))
|
t.Errorf("len(result) = %d, want 19", len(result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,15 @@ func resolveProviderSelection(cfg *config.Config) (providerSelection, error) {
|
||||||
sel.apiBase = "https://integrate.api.nvidia.com/v1"
|
sel.apiBase = "https://integrate.api.nvidia.com/v1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "vivgrid":
|
||||||
|
if cfg.Providers.Vivgrid.APIKey != "" {
|
||||||
|
sel.apiKey = cfg.Providers.Vivgrid.APIKey
|
||||||
|
sel.apiBase = cfg.Providers.Vivgrid.APIBase
|
||||||
|
sel.proxy = cfg.Providers.Vivgrid.Proxy
|
||||||
|
if sel.apiBase == "" {
|
||||||
|
sel.apiBase = "https://api.vivgrid.com/v1"
|
||||||
|
}
|
||||||
|
}
|
||||||
case "claude-cli", "claude-code", "claudecode":
|
case "claude-cli", "claude-code", "claudecode":
|
||||||
workspace := cfg.WorkspacePath()
|
workspace := cfg.WorkspacePath()
|
||||||
if workspace == "" {
|
if workspace == "" {
|
||||||
|
|
@ -277,6 +286,13 @@ func resolveProviderSelection(cfg *config.Config) (providerSelection, error) {
|
||||||
if sel.apiBase == "" {
|
if sel.apiBase == "" {
|
||||||
sel.apiBase = "https://integrate.api.nvidia.com/v1"
|
sel.apiBase = "https://integrate.api.nvidia.com/v1"
|
||||||
}
|
}
|
||||||
|
case (strings.Contains(lowerModel, "vivgrid") || strings.HasPrefix(model, "vivgrid/")) && cfg.Providers.Vivgrid.APIKey != "":
|
||||||
|
sel.apiKey = cfg.Providers.Vivgrid.APIKey
|
||||||
|
sel.apiBase = cfg.Providers.Vivgrid.APIBase
|
||||||
|
sel.proxy = cfg.Providers.Vivgrid.Proxy
|
||||||
|
if sel.apiBase == "" {
|
||||||
|
sel.apiBase = "https://api.vivgrid.com/v1"
|
||||||
|
}
|
||||||
case (strings.Contains(lowerModel, "ollama") || strings.HasPrefix(model, "ollama/")) && cfg.Providers.Ollama.APIKey != "":
|
case (strings.Contains(lowerModel, "ollama") || strings.HasPrefix(model, "ollama/")) && cfg.Providers.Ollama.APIKey != "":
|
||||||
sel.apiKey = cfg.Providers.Ollama.APIKey
|
sel.apiKey = cfg.Providers.Ollama.APIKey
|
||||||
sel.apiBase = cfg.Providers.Ollama.APIBase
|
sel.apiBase = cfg.Providers.Ollama.APIBase
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err
|
||||||
|
|
||||||
case "openrouter", "groq", "zhipu", "gemini", "nvidia",
|
case "openrouter", "groq", "zhipu", "gemini", "nvidia",
|
||||||
"ollama", "moonshot", "shengsuanyun", "deepseek", "cerebras",
|
"ollama", "moonshot", "shengsuanyun", "deepseek", "cerebras",
|
||||||
"volcengine", "vllm", "qwen", "mistral":
|
"vivgrid", "volcengine", "vllm", "qwen", "mistral":
|
||||||
// All other OpenAI-compatible HTTP providers
|
// All other OpenAI-compatible HTTP providers
|
||||||
if cfg.APIKey == "" && cfg.APIBase == "" {
|
if cfg.APIKey == "" && cfg.APIBase == "" {
|
||||||
return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol)
|
return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol)
|
||||||
|
|
@ -198,6 +198,8 @@ func getDefaultAPIBase(protocol string) string {
|
||||||
return "https://api.deepseek.com/v1"
|
return "https://api.deepseek.com/v1"
|
||||||
case "cerebras":
|
case "cerebras":
|
||||||
return "https://api.cerebras.ai/v1"
|
return "https://api.cerebras.ai/v1"
|
||||||
|
case "vivgrid":
|
||||||
|
return "https://api.vivgrid.com/v1"
|
||||||
case "volcengine":
|
case "volcengine":
|
||||||
return "https://ark.cn-beijing.volces.com/api/v3"
|
return "https://ark.cn-beijing.volces.com/api/v3"
|
||||||
case "qwen":
|
case "qwen":
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ func TestCreateProviderFromConfig_DefaultAPIBase(t *testing.T) {
|
||||||
{"groq", "groq"},
|
{"groq", "groq"},
|
||||||
{"openrouter", "openrouter"},
|
{"openrouter", "openrouter"},
|
||||||
{"cerebras", "cerebras"},
|
{"cerebras", "cerebras"},
|
||||||
|
{"vivgrid", "vivgrid"},
|
||||||
{"qwen", "qwen"},
|
{"qwen", "qwen"},
|
||||||
{"vllm", "vllm"},
|
{"vllm", "vllm"},
|
||||||
{"deepseek", "deepseek"},
|
{"deepseek", "deepseek"},
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,17 @@ func TestResolveProviderSelection(t *testing.T) {
|
||||||
wantAPIBase: "https://integrate.api.nvidia.com/v1",
|
wantAPIBase: "https://integrate.api.nvidia.com/v1",
|
||||||
wantProxy: "http://127.0.0.1:7890",
|
wantProxy: "http://127.0.0.1:7890",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "explicit vivgrid provider uses defaults",
|
||||||
|
setup: func(cfg *config.Config) {
|
||||||
|
cfg.Agents.Defaults.Provider = "vivgrid"
|
||||||
|
cfg.Providers.Vivgrid.APIKey = "vivgrid-key"
|
||||||
|
cfg.Providers.Vivgrid.Proxy = "http://127.0.0.1:7890"
|
||||||
|
},
|
||||||
|
wantType: providerTypeHTTPCompat,
|
||||||
|
wantAPIBase: "https://api.vivgrid.com/v1",
|
||||||
|
wantProxy: "http://127.0.0.1:7890",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "openrouter model uses openrouter defaults",
|
name: "openrouter model uses openrouter defaults",
|
||||||
setup: func(cfg *config.Config) {
|
setup: func(cfg *config.Config) {
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,7 @@ func normalizeModel(model, apiBase string) string {
|
||||||
|
|
||||||
prefix := strings.ToLower(before)
|
prefix := strings.ToLower(before)
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "moonshot", "nvidia", "groq", "ollama", "deepseek", "google", "openrouter", "zhipu", "mistral":
|
case "moonshot", "nvidia", "groq", "ollama", "deepseek", "google", "openrouter", "zhipu", "mistral", "vivgrid":
|
||||||
return after
|
return after
|
||||||
default:
|
default:
|
||||||
return model
|
return model
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ func TestProviderChat_StripsMoonshotPrefixAndNormalizesKimiTemperature(t *testin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProviderChat_StripsGroqAndOllamaPrefixes(t *testing.T) {
|
func TestProviderChat_StripsGroqOllamaDeepseekVivgridPrefixes(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
|
|
@ -221,6 +221,11 @@ func TestProviderChat_StripsGroqAndOllamaPrefixes(t *testing.T) {
|
||||||
input: "deepseek/deepseek-chat",
|
input: "deepseek/deepseek-chat",
|
||||||
wantModel: "deepseek-chat",
|
wantModel: "deepseek-chat",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "strips vivgrid prefix",
|
||||||
|
input: "vivgrid/auto",
|
||||||
|
wantModel: "auto",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
@ -325,6 +330,12 @@ func TestNormalizeModel_UsesAPIBase(t *testing.T) {
|
||||||
if got := normalizeModel("openrouter/auto", "https://openrouter.ai/api/v1"); got != "openrouter/auto" {
|
if got := normalizeModel("openrouter/auto", "https://openrouter.ai/api/v1"); got != "openrouter/auto" {
|
||||||
t.Fatalf("normalizeModel(openrouter) = %q, want %q", got, "openrouter/auto")
|
t.Fatalf("normalizeModel(openrouter) = %q, want %q", got, "openrouter/auto")
|
||||||
}
|
}
|
||||||
|
if got := normalizeModel("vivgrid/managed", "https://api.vivgrid.com/v1"); got != "managed" {
|
||||||
|
t.Fatalf("normalizeModel(vivgrid) = %q, want %q", got, "managed")
|
||||||
|
}
|
||||||
|
if got := normalizeModel("vivgrid/auto", "https://api.vivgrid.com/v1"); got != "auto" {
|
||||||
|
t.Fatalf("normalizeModel(vivgrid auto) = %q, want %q", got, "auto")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProvider_RequestTimeoutDefault(t *testing.T) {
|
func TestProvider_RequestTimeoutDefault(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue