-
-
Notifications
You must be signed in to change notification settings - Fork 998
fix: deepseek provider 's handling of the<think> tag #1445
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
Conversation
|
Warning Rate limit exceeded@kimteayon has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 43 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthrough修正 DeepSeek 聊天提供者中对 内容的封装与未闭合标签处理,示例将请求端点切换为流式 DeepSeek 接口,并移除示例渲染中把双换行替换为换行的转换;同时新增针对 DeepSeekChatProvider 的一组高级测试用例。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @kimteayon, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a bug in the DeepSeek chat provider's handling of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes an issue with how DeepSeekChatProvider handles the <think> tag, which was causing markdown rendering problems. The changes correctly add newlines around the <think> and </think> tags to ensure they are treated as block elements by markdown parsers. The related demo files are also updated to align with this fix.
My review identified a minor bug in the regular expression used to clean up the content within the <think> tag. I've provided a specific comment with a suggested fix. Apart from that, the changes are well-implemented and address the intended issue.
Deploying ant-design-x with
|
| Latest commit: |
0395718
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f956d191.ant-design-x.pages.dev |
| Branch Preview URL: | https://deepseepsdk.ant-design-x.pages.dev |
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts(1 hunks)packages/x/docs/x-sdk/demos/chat-providers/deep-seek-chat-provider.tsx(1 hunks)packages/x/docs/x-sdk/demos/x-chat/deepSeek.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: afc163
Repo: ant-design/x PR: 0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
Repo: ant-design/x PR: 0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
🪛 GitHub Check: CodeQL
packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts
[failure] 72-72: Polynomial regular expression used on uncontrolled data
This regular expression that depends on library input may run slow on strings with many repetitions of '\n'.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: test
- GitHub Check: size
- GitHub Check: build preview
- GitHub Check: test
- GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
packages/x/docs/x-sdk/demos/x-chat/deepSeek.tsx (1)
88-88: 移除双换行符转换是正确的改动。之前的
.replace(/\n\n/g, ' \n')转换会干扰新的<think>标签处理逻辑,因为 DeepSeekChatProvider 现在会在标签周围添加显式的换行符。直接传递内容给 XMarkdown 可以确保 Markdown 渲染正确处理新的格式。packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts (1)
72-72: 注意正则表达式的潜在性能风险。CodeQL 标记了此正则表达式可能存在多项式时间复杂度(ReDoS)风险。虽然
/\n+$/锚定在字符串末尾,实际风险较低,但在处理大量连续换行符时仍可能影响性能。建议考虑使用更安全的替代方案:
- content = `${originMessageContent?.replace?.(/\n+$/, '')}\n\n</think>\n\n${currentContent}`; + content = `${originMessageContent?.trimEnd?.()}\n\n</think>\n\n${currentContent}`;或者使用非回溯的正则表达式:
- content = `${originMessageContent?.replace?.(/\n+$/, '')}\n\n</think>\n\n${currentContent}`; + content = `${originMessageContent?.replace?.(/\n*$/, '')}\n\n</think>\n\n${currentContent}`;Based on static analysis hints.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1445 +/- ##
==========================================
+ Coverage 94.24% 94.43% +0.18%
==========================================
Files 144 144
Lines 3703 3703
Branches 1038 1023 -15
==========================================
+ Hits 3490 3497 +7
+ Misses 211 204 -7
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
size-limit report 📦
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts(1 hunks)packages/x-sdk/src/chat-providers/__test__/providers.test.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: afc163
Repo: ant-design/x PR: 0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
Learnt from: afc163
Repo: ant-design/x PR: 0
File: :0-0
Timestamp: 2025-04-11T14:47:09.527Z
Learning: 当评审 ant-design/x 仓库中的 PR 时,需要用中文回复中文评论。该项目的文档支持中英双语。
🪛 GitHub Check: CodeQL
packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts
[failure] 72-72: Polynomial regular expression used on uncontrolled data
This regular expression that depends on library input may run slow on strings with many repetitions of '\t'.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build preview
- GitHub Check: test
- GitHub Check: size
- GitHub Check: test
- GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts (1)
64-65: 正则表达式修复正确。已正确修复之前的正则表达式错误,现在可以正确移除
currentThink开头的换行符。packages/x-sdk/src/chat-providers/__test__/providers.test.ts (1)
930-1213: 测试覆盖全面且结构清晰。新增的测试套件很好地覆盖了 DeepSeekChatProvider 的各种场景:
- 流式和非流式响应中的
reasoning_content处理<think>标签的打开和关闭逻辑- 各种边界情况(null、undefined、空 headers、JSON 解析错误)
- 完整的多步骤思考工作流
测试用例组织良好,命名清晰,期望值与生产代码的逻辑一致。
Bundle ReportChanges will decrease total bundle size by 2.88MB (-48.99%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: x-markdown-array-pushAssets Changed:
|

中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log
Summary by CodeRabbit
发布说明
Bug 修复
更新
渲染改进
测试
✏️ Tip: You can customize this high-level summary in your review settings.