Repository navigation
Conversation
面板与环境变量 RETURN_THOUGHTS_TO_FRONTEND 提供“是否向客户端回传思维链”的开关, 但 normalize_antigravity_request 将 return_thoughts 固定为 True,开关设置不生效。 分支以 get_return_thoughts_to_frontend() 的结果作为 return_thoughts: - 请求侧 _apply_thinking 在模型带有 thinkingConfig 时写入 includeThoughts(含 none 类型, 保留客户端 thinkingBudget;无 thinkingConfig 的模型不注入)。 - 响应侧在 stream_request / non_stream_request 统一剔除 thought:true 片段(三格式共用出口), 不依赖后端是否遵守 includeThoughts。 该开关只影响是否回传思考内容,不改变模型的思考预算/深度,也不对模型做白名单限制。
Owner
|
参数加了 专门过滤就不用了 |
Contributor
Author
只加参数在我这边测试Gemini接口不知道为什么没用,所以才加的专门过滤hhhh |
Owner
|
可能客户端传了返回思维链参数过去? |
Contributor
Author
看了下客户端请求没有带 |
Owner
|
你可以打开详细日志 看看 |
Contributor
Author
|
还是没排查出原因()让ai测了下貌似我的Gemini模型思维链不受控制,claude正常 |
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.
问题
如果只是重构还没做到这一块那么可以视情况不合()
控制面板与环境变量
RETURN_THOUGHTS_TO_FRONTEND提供了“是否向客户端回传思维链”的开关,config.py的get_return_thoughts_to_frontend()已实现读取(默认 True)。但
src/converter/antigravity_fix.py的normalize_antigravity_request将return_thoughts固定为 True,该开关设置不生效:面板关闭后,思考内容仍随响应返回。
此外,
_apply_thinking对none类型模型(如gemini-2.5-flash-lite)直接跳过,导致这类模型即使携带
thinkingConfig也不会写入includeThoughts,开关对其同样无效。修复
normalize_antigravity_request以await get_return_thoughts_to_frontend()的结果作为return_thoughts。_apply_thinking在模型带有thinkingConfig时写入includeThoughts = return_thoughts(
none类型仅保留客户端思考深度参数,不额外施加预算);无thinkingConfig的模型不注入,避免影响不支持思考的模型。
stream_request/non_stream_request(Gemini / OpenAI / Anthropic 三个路由共用的出站出口)统一过滤——开关关闭时从
candidates[].content.parts[]剔除thought:true的片段。实测后端会忽略
includeThoughts(出站确为includeThoughts:false仍回传思考),故响应侧过滤是必要补充;过滤只移除思考片段,保留答案、
finishReason、usageMetadata。行为范围
route(gemini-3 / gemini-4 / claude-5.5)与budget(模型名含 think):includeThoughts随开关。none(如 gemini-2.5 系列含 flash-lite):若请求带有thinkingConfig,保留其思考深度参数并按开关写入includeThoughts。测试
本地验证(未随仓库提交):
_apply_thinking的 route/budget/none × 开/关(含 none 带客户端thinkingConfig);normalize_antigravity_request:route 开/关、budget 关闭保留预算、flash-lite 关闭/开启、none 无配置不注入;thought_filter:strip_thought_parts、filter_sse_chunk(str/bytes、{"response":...}包装、[DONE]、非 data 行、非法 JSON、无改动原样返回)、
filter_response_bytes(包装、非法内容)全部通过。