Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
🌟 核心摘要
修复了在使用 OpenRouter 作为代理访问 DeepSeek-R1 系列模型时,无法实时显示“深度思考”(Reasoning)过程的问题。
❓ 为什么需要这个修改?
传统的 DeepSeek 官方接口使用 reasoning_content 字段返回思考过程,但 OpenRouter 使用的是自定义的 reasoning 字段,且要求在请求中显式传递 include_reasoning: true 参数。
在此修改前,由于参数缺失和字段名不匹配,导致 OpenRouter 返回的思考过程被丢弃,用户只能在思考结束后看到最终结果,体验不到 R1 模型的“心路历程”。
🛠️ 修改内容
参数透传:
在通用请求结构
RequestPayload
中增加了 include_reasoning 可选参数。
在 DeepSeek 接口调用时,默认加上 include_reasoning: true,确保代理平台(如 OpenRouter)会回传思考内容。
双字段兼容:
优化了流式解析逻辑(SSE),现在能同时识别 reasoning_content(标准)和 reasoning(OpenRouter 规范)。
无论用户是直连官方还是通过 OpenRouter 中转,都能正常看到思考进度。
📈 预期效果(用户体验提升)
实时可见,告别“假死”:解决了之前模型思考时屏幕长时间“空白”或“卡顿”的问题。现在模型在后台动脑筋的同时,前端会实时通过流式传输显示每一颗思考标记。
完美触发内置 UI:完美兼容 NextChat 优雅的“深度思考”UI 模块。思考内容会像回复里的“特别引用”一样,带有专属的折叠样式,与最终答案清晰区分。
极致的兼容感知:无论用户背后连接的是 OpenRouter 的中转站,还是直连 DeepSeek 官方,用户感受到的显示效果都是 100% 一致且顺滑的。
无缝衔接:思考结束后,内容会自动收齐,并无缝切换到最终答案的输出,给用户一种模型正在“当面思考”的沉浸感。