mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-29 05:47:37 +08:00
Add multi-service provider mode
This commit is contained in:
@@ -2,28 +2,20 @@ package agent
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestApplyRuntimeModelConfig_Model(t *testing.T) {
|
||||
al := &AgentLoop{model: "old-model"}
|
||||
al.applyRuntimeModelConfig("agents.defaults.model", "new-model")
|
||||
if al.model != "new-model" {
|
||||
t.Fatalf("expected runtime model updated, got %q", al.model)
|
||||
func TestApplyRuntimeModelConfig_ProxyFallbacks(t *testing.T) {
|
||||
al := &AgentLoop{proxyFallbacks: []string{"old-proxy"}}
|
||||
al.applyRuntimeModelConfig("agents.defaults.proxy_fallbacks", []interface{}{"backup-a", "", "backup-b"})
|
||||
if len(al.proxyFallbacks) != 2 {
|
||||
t.Fatalf("expected 2 fallbacks, got %d: %v", len(al.proxyFallbacks), al.proxyFallbacks)
|
||||
}
|
||||
if al.proxyFallbacks[0] != "backup-a" || al.proxyFallbacks[1] != "backup-b" {
|
||||
t.Fatalf("unexpected fallbacks: %v", al.proxyFallbacks)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyRuntimeModelConfig_ModelFallbacks(t *testing.T) {
|
||||
al := &AgentLoop{modelFallbacks: []string{"old-fallback"}}
|
||||
al.applyRuntimeModelConfig("agents.defaults.model_fallbacks", []interface{}{"gpt-4o-mini", "", "claude-3-5-sonnet"})
|
||||
if len(al.modelFallbacks) != 2 {
|
||||
t.Fatalf("expected 2 fallbacks, got %d: %v", len(al.modelFallbacks), al.modelFallbacks)
|
||||
}
|
||||
if al.modelFallbacks[0] != "gpt-4o-mini" || al.modelFallbacks[1] != "claude-3-5-sonnet" {
|
||||
t.Fatalf("unexpected fallbacks: %v", al.modelFallbacks)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseModelFallbacks_StringValue(t *testing.T) {
|
||||
fallbacks := parseModelFallbacks("gpt-4o-mini")
|
||||
if len(fallbacks) != 1 || fallbacks[0] != "gpt-4o-mini" {
|
||||
t.Fatalf("unexpected parse result: %v", fallbacks)
|
||||
func TestParseStringList_StringValue(t *testing.T) {
|
||||
out := parseStringList("backup-a")
|
||||
if len(out) != 1 || out[0] != "backup-a" {
|
||||
t.Fatalf("unexpected parse result: %v", out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user