fix(antigravity): 修复非流式 Claude To Antigravity 响应内容为空的问题#358
Merged
Wei-Shaw merged 2 commits intoWei-Shaw:mainfrom Jan 22, 2026
Merged
fix(antigravity): 修复非流式 Claude To Antigravity 响应内容为空的问题#358Wei-Shaw merged 2 commits intoWei-Shaw:mainfrom
Wei-Shaw merged 2 commits intoWei-Shaw:mainfrom
Conversation
- 修复 TransformGeminiToClaude 的 JSON 解析逻辑,当 V1InternalResponse 解析成功但 candidates 为空时,尝试直接解析为 GeminiResponse 格式 - 修复 handleClaudeStreamToNonStreaming 收集流式响应的逻辑,累积所有 chunks 的内容而不是只保留最后一个(最后一个 chunk 通常 text 为空) - 新增 mergeCollectedPartsToResponse 函数,合并所有类型的 parts (text、thinking、functionCall、inlineData),保持原始顺序 - 连续的普通 text parts 合并为一个,thinking/functionCall/inlineData 保持原样
|
就等这个合进去了 |
xuebkgithub
pushed a commit
to xuebkgithub/sub2api
that referenced
this pull request
Mar 3, 2026
fix(antigravity): 修复非流式 Claude To Antigravity 响应内容为空的问题
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复非流式 Claude To Antigravity 响应内容为空的问题(#305)
概述
本次提交修复了 Antigravity 网关在处理非流式 Claude 请求时,响应内容为空的问题。问题根源在于流式响应收集逻辑只保留了最后一个 chunk(通常 text 为空),以及 JSON 解析逻辑未能正确处理 candidates 为空的情况。
主要改动
1. 修复 TransformGeminiToClaude 的 JSON 解析逻辑
问题描述:
技术实现:
backend/internal/pkg/antigravity/response_transformer.go: 新增判断逻辑,当 candidates 为空时尝试直接解析为 GeminiResponse 格式。2. 修复 handleClaudeStreamToNonStreaming 流式响应收集逻辑
问题描述:
技术实现:
backend/internal/service/antigravity_gateway_service.go:collectedParts变量,累积所有 chunks 的 parts(包括 text、thinking、functionCall、inlineData 等)。mergeCollectedPartsToResponse函数,合并所有类型的 parts,保持原始顺序,连续的普通 text parts 合并为一个。3. 修复 NonStreamingProcessor 的 text 处理逻辑
问题描述:
技术实现:
backend/internal/pkg/antigravity/response_transformer.go: 修改带签名 text 的处理逻辑,直接输出 text 块而不是累积到 builder。文件变更
后端:
backend/internal/pkg/antigravity/response_transformer.go- 修复 JSON 解析逻辑和 text 处理逻辑backend/internal/service/antigravity_gateway_service.go- 新增 parts 收集和合并逻辑核心改进
数据完整性:
合并策略:
测试验证