Add reasoning content support (for DeepSeek format API)#840
Add reasoning content support (for DeepSeek format API)#840PasserbyAlpha wants to merge 1 commit intoChatGPTBox-dev:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for embedding reasoning_content segments in both streaming and single-response flows for the DeepSeek-format API.
- Loads
delta.reasoning_contentandmessage.reasoning_contentwhen available. - Wraps reasoning segments with
[Think]and[Response]markers during streaming and in one-shot responses.
Comments suppressed due to low confidence (2)
src/services/apis/custom-api.mjs:42
- [nitpick] Variable names like
with_reasoninguse snake_case, which differs from the project's camelCase convention; consider renaming towithReasoning, and similarly updatehas_reasoning_start/has_reasoning_endtohasReasoningStart/hasReasoningEnd.
let with_reasoning = false
src/services/apis/custom-api.mjs:87
- New reasoning_content handling logic is introduced here but lacks accompanying unit tests to validate both streaming and single-response behaviors; consider adding tests for scenarios with and without
reasoning_content.
const delta_reasoning = data.choices[0]?.delta?.reasoning_content
| let has_reasoning_start = false | ||
| let has_reasoning_end = false | ||
|
|
||
| const REASONING_START_SIGN = '[Think]\n\n' |
There was a problem hiding this comment.
[nitpick] Magic strings for reasoning markers are declared inline; extracting these markers into a shared constants module or configuration will improve maintainability and consistency.
|
/review |
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
/improve |
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Code Suggestions ✨
|
|||||||||
For customAPI, try to load delta.reasoning_content and message.reasoning_content if it exists.
For DeepSeek-R1

For GPT-4o

Currently only delta part (streaming) has been tested (I don't know how to trigger a single-request chat completion with the repo).
I'm not familiar with nodejs. Please help me to improve it if possible, thank you!