refactor(antigravity): 简化模型映射逻辑,支持前缀匹配
- 删除精确映射表 antigravityModelMapping,统一使用前缀映射 - 前缀映射支持模型版本号变化(如 -20251111, -thinking, -preview) - 简化 IsModelSupported 函数,所有 claude-/gemini- 前缀模型都支持 - 添加跨协议测试用例:Claude 端点调用 Gemini 模型、Gemini 端点调用 Claude 模型
This commit is contained in:
@@ -57,6 +57,7 @@ var geminiModels = []string{
|
||||
"gemini-2.5-flash-lite",
|
||||
"gemini-3-flash",
|
||||
"gemini-3-pro-low",
|
||||
"gemini-3-pro-high",
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -641,6 +642,37 @@ func testClaudeThinkingWithToolHistory(t *testing.T, model string) {
|
||||
t.Logf("✅ thinking 模式工具调用测试通过, id=%v", result["id"])
|
||||
}
|
||||
|
||||
// TestClaudeMessagesWithGeminiModel 测试在 Claude 端点使用 Gemini 模型
|
||||
// 验证:通过 /v1/messages 端点传入 gemini 模型名的场景(含前缀映射)
|
||||
// 仅在 Antigravity 模式下运行(ENDPOINT_PREFIX="/antigravity")
|
||||
func TestClaudeMessagesWithGeminiModel(t *testing.T) {
|
||||
if endpointPrefix != "/antigravity" {
|
||||
t.Skip("仅在 Antigravity 模式下运行")
|
||||
}
|
||||
|
||||
// 测试通过 Claude 端点调用 Gemini 模型
|
||||
geminiViaClaude := []string{
|
||||
"gemini-3-flash", // 直接支持
|
||||
"gemini-3-pro-low", // 直接支持
|
||||
"gemini-3-pro-high", // 直接支持
|
||||
"gemini-3-pro", // 前缀映射 -> gemini-3-pro-high
|
||||
"gemini-3-pro-preview", // 前缀映射 -> gemini-3-pro-high
|
||||
}
|
||||
|
||||
for i, model := range geminiViaClaude {
|
||||
if i > 0 {
|
||||
time.Sleep(testInterval)
|
||||
}
|
||||
t.Run(model+"_通过Claude端点", func(t *testing.T) {
|
||||
testClaudeMessage(t, model, false)
|
||||
})
|
||||
time.Sleep(testInterval)
|
||||
t.Run(model+"_通过Claude端点_流式", func(t *testing.T) {
|
||||
testClaudeMessage(t, model, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestClaudeMessagesWithNoSignature 测试历史 thinking block 不带 signature 的场景
|
||||
// 验证:Gemini 模型接受没有 signature 的 thinking block
|
||||
func TestClaudeMessagesWithNoSignature(t *testing.T) {
|
||||
@@ -738,3 +770,30 @@ func testClaudeWithNoSignature(t *testing.T, model string) {
|
||||
}
|
||||
t.Logf("✅ 无 signature thinking 处理测试通过, id=%v", result["id"])
|
||||
}
|
||||
|
||||
// TestGeminiEndpointWithClaudeModel 测试通过 Gemini 端点调用 Claude 模型
|
||||
// 仅在 Antigravity 模式下运行(ENDPOINT_PREFIX="/antigravity")
|
||||
func TestGeminiEndpointWithClaudeModel(t *testing.T) {
|
||||
if endpointPrefix != "/antigravity" {
|
||||
t.Skip("仅在 Antigravity 模式下运行")
|
||||
}
|
||||
|
||||
// 测试通过 Gemini 端点调用 Claude 模型
|
||||
claudeViaGemini := []string{
|
||||
"claude-sonnet-4-5",
|
||||
"claude-opus-4-5-thinking",
|
||||
}
|
||||
|
||||
for i, model := range claudeViaGemini {
|
||||
if i > 0 {
|
||||
time.Sleep(testInterval)
|
||||
}
|
||||
t.Run(model+"_通过Gemini端点", func(t *testing.T) {
|
||||
testGeminiGenerate(t, model, false)
|
||||
})
|
||||
time.Sleep(testInterval)
|
||||
t.Run(model+"_通过Gemini端点_流式", func(t *testing.T) {
|
||||
testGeminiGenerate(t, model, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user