mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-19 15:37:44 +08:00
全局统一映射
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"ds2api/internal/prompt"
|
||||
)
|
||||
|
||||
const ClaudeDefaultModel = "claude-sonnet-4-5"
|
||||
const ClaudeDefaultModel = "claude-sonnet-4-6"
|
||||
|
||||
type Message struct {
|
||||
Role string `json:"role"`
|
||||
|
||||
@@ -104,6 +104,18 @@ func TestConvertClaudeToDeepSeek(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertClaudeToDeepSeekUsesGlobalAliasResolution(t *testing.T) {
|
||||
store := config.LoadStore()
|
||||
req := map[string]any{
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"messages": []any{map[string]any{"role": "user", "content": "Hi"}},
|
||||
}
|
||||
out := ConvertClaudeToDeepSeek(req, store)
|
||||
if out["model"] != "deepseek-v4-flash" {
|
||||
t.Fatalf("expected global alias resolution, got model=%q", out["model"])
|
||||
}
|
||||
}
|
||||
|
||||
func contains(s, sub string) bool {
|
||||
return len(s) >= len(sub) && (s == sub || len(sub) == 0 || (len(s) > 0 && (indexOf(s, sub) >= 0)))
|
||||
}
|
||||
|
||||
@@ -348,8 +348,7 @@ func TestConvertClaudeToDeepSeekNoSystem(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertClaudeToDeepSeekOpusUsesSlowMapping(t *testing.T) {
|
||||
t.Setenv("DS2API_CONFIG_JSON", `{"keys":[],"accounts":[],"claude_mapping":{"fast":"deepseek-v4-flash","slow":"deepseek-v4-pro"}}`)
|
||||
func TestConvertClaudeToDeepSeekOpusUsesGlobalAlias(t *testing.T) {
|
||||
store := config.LoadStore()
|
||||
req := map[string]any{
|
||||
"model": "claude-opus-4-6",
|
||||
@@ -357,6 +356,19 @@ func TestConvertClaudeToDeepSeekOpusUsesSlowMapping(t *testing.T) {
|
||||
}
|
||||
out := ConvertClaudeToDeepSeek(req, store)
|
||||
if out["model"] != "deepseek-v4-pro" {
|
||||
t.Fatalf("expected opus to use slow mapping, got %q", out["model"])
|
||||
t.Fatalf("expected opus to use global alias, got %q", out["model"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertClaudeToDeepSeekUsesExplicitModelAlias(t *testing.T) {
|
||||
t.Setenv("DS2API_CONFIG_JSON", `{"keys":[],"accounts":[],"model_aliases":{"claude-sonnet-4-6":"deepseek-v4-pro-search"}}`)
|
||||
store := config.LoadStore()
|
||||
req := map[string]any{
|
||||
"model": "claude-sonnet-4-6",
|
||||
"messages": []any{map[string]any{"role": "user", "content": "Hi"}},
|
||||
}
|
||||
out := ConvertClaudeToDeepSeek(req, store)
|
||||
if out["model"] != "deepseek-v4-pro-search" {
|
||||
t.Fatalf("expected explicit alias override, got %q", out["model"])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user