-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
๐ fix: fix reasoning output for OpenRouter reasoning models like deepseek-r1 #5903
๐ fix: fix reasoning output for OpenRouter reasoning models like deepseek-r1 #5903
Conversation
@deephbz is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
๐ @deephbz Thank you for raising your pull request and contributing to our Community |
TestGru AssignmentSummary
Tip You can |
ca6d009
to
d579c59
Compare
bb8bcfa
to
e471961
Compare
its "reasoning" to be consistent with most other platforms: reasoning outputs wrapped by <think> XML tag.
1f04a01
to
6e943d9
Compare
6e943d9
to
d014d34
Compare
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now. Thanks for your great job!
โค๏ธ Great PR @deephbz โค๏ธ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
### [Version 1.53.1](v1.53.0...v1.53.1) <sup>Released on **2025-02-12**</sup> #### ๐ Bug Fixes - **misc**: Fix reasoning output for OpenRouter reasoning models like deepseek-r1. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Fix reasoning output for OpenRouter reasoning models like deepseek-r1, closes [#5903](#5903) [#5766](#5766) ([bfd9317](bfd9317)) </details> <div align="right"> [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) </div>
๐ This PR is included in version 1.53.1 ๐ The release is available on: Your semantic-release bot ๐ฆ๐ |
### [Version 1.95.1](v1.95.0...v1.95.1) <sup>Released on **2025-02-12**</sup> #### ๐ Bug Fixes - **misc**: Disable openrouter client fetch, fix reasoning output for OpenRouter reasoning models like deepseek-r1. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Disable openrouter client fetch, closes [lobehub#6043](https://github.com/bentwnghk/lobe-chat/issues/6043) ([63b22ce](63b22ce)) * **misc**: Fix reasoning output for OpenRouter reasoning models like deepseek-r1, closes [lobehub#5903](https://github.com/bentwnghk/lobe-chat/issues/5903) [lobehub#5766](https://github.com/bentwnghk/lobe-chat/issues/5766) ([bfd9317](bfd9317)) </details> <div align="right"> [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) </div>
โฆpseek-r1 (lobehub#5903) * โจ feat: Support include_reasoning for OpenRouter provider's models. Solves lobehub#5766 * โจ feat: Support display OpenRouter's "reasoning" output by transforming its "reasoning" to be consistent with most other platforms: reasoning outputs wrapped by <think> XML tag. * Revert openrouter stream transformer: Capture reasoning content inside openai stream processor * Address PR comments: r1 does not support functional calling * add unittest for openrouter reasoning stream handling
### [Version 1.53.1](lobehub/lobe-chat@v1.53.0...v1.53.1) <sup>Released on **2025-02-12**</sup> #### ๐ Bug Fixes - **misc**: Fix reasoning output for OpenRouter reasoning models like deepseek-r1. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Fix reasoning output for OpenRouter reasoning models like deepseek-r1, closes [lobehub#5903](lobehub#5903) [lobehub#5766](lobehub#5766) ([bfd9317](lobehub@bfd9317)) </details> <div align="right"> [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) </div>
๐ป ๅๆด็ฑปๅ | Change Type
๐ ๅๆด่ฏดๆ | Description of Change
Business Description
Get reasoning (i.e. deep thinking) outputs for all OpenRouter reasoning models, and display them in lobe-chat UI.
Fully tested: unittests as well as integration testing.
Technical Description
Unlike most other DeepSeek-R1 providers which simply return
<think> ... </think>
inside reply messages. OpenRouter use a separate"reasoning"
key to return reasoning outputs. Besides it requires addinclude_reasoning=True
in payload. See their docs.Therefore, to support it we need two changes:
include_reasoning=True
by usinghandlePayload
callback. This does not affect non-reasoning models at all. Verification:-you could see reasoning outputs in response:
to
This transformed content is consistent with other platforms - a single 'content' stream of thinking then normal output tokens. Therefore, the part gets automatically picked up and displayed.
Verification:
![image](https://private-user-images.githubusercontent.com/13776377/411286534-0829849c-14c7-47ee-8cf3-4e2dd31ab3fd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1Mjg4NjgsIm5iZiI6MTczOTUyODU2OCwicGF0aCI6Ii8xMzc3NjM3Ny80MTEyODY1MzQtMDgyOTg0OWMtMTRjNy00N2VlLThjZjMtNGUyZGQzMWFiM2ZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDEwMjI0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ4OTNiYWRhODI0ZmM2N2NkNWRmZDg4MzhlMTZhZDBmYjA1YjBmZjYxZWJkM2I0M2Y5MjAxNzUxNjlkNjFkNzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.aB7LKPGtLf6GAmJsPASJv9kzGPwS93SYNk-oYQ6vnNY)
๐ ่กฅๅ ไฟกๆฏ | Additional Information
Solves #5766 , related #5860