Skip to content

支持 OpenRouter 反代 DeepSeek-R1 的深度思考显示#2

Merged
ninirobot merged 2 commits into
mainfrom
还原
Jan 23, 2026

Hidden character warning

The head ref may contain hidden characters: "\u8fd8\u539f"
Merged

支持 OpenRouter 反代 DeepSeek-R1 的深度思考显示#2
ninirobot merged 2 commits into
mainfrom
还原

Conversation

@ninirobot
Copy link
Copy Markdown
Owner

🌟 核心摘要
修复了在使用 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% 一致且顺滑的。
无缝衔接:思考结束后,内容会自动收齐,并无缝切换到最终答案的输出,给用户一种模型正在“当面思考”的沉浸感。

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ninichat Ready Ready Preview, Comment Jan 23, 2026 9:43am

@ninirobot ninirobot merged commit 96d32ad into main Jan 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant