Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kimteayon
Copy link
Collaborator

@kimteayon kimteayon commented Dec 4, 2025

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese 修复DeepSeekChatProvider 对 标签的处理错误导致 Markdown 渲染异常 ,同时补齐Markdown 对标签的处理文档

Summary by CodeRabbit

发布说明

  • Bug 修复

    • 优化“思考”内容的换行与标签闭合处理,避免未闭合标签或多余换行导致的显示异常。
  • 更新

    • 切换了用于聊天流请求的后端 API 端点,以改善流式交互的请求目标。
  • 渲染改进

    • 移除了对连续空行的自动转换,内容将按原样传递以保留 Markdown 格式效果。
  • 测试

    • 增加了针对复杂流与非流响应及边缘情况的验证用例集合。

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Preview is ready

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between f75bbad and 0395718.

📒 Files selected for processing (1)
  • packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts (1 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit 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.

📝 Walkthrough

Walkthrough

修正 DeepSeek 聊天提供者中对 内容的封装与未闭合标签处理,示例将请求端点切换为流式 DeepSeek 接口,并移除示例渲染中把双换行替换为换行的转换;同时新增针对 DeepSeekChatProvider 的一组高级测试用例。

Changes

Cohort / 文件(s) 变更摘要
思考内容格式化
packages/x-sdk/src/chat-providers/DeepSeekChatProvider.ts
当没有 origin 内容且存在 currentThink 时,创建独立的带前导换行的 <think> 块并移除 currentThink 开头的换行标记;当 originMessageContent 含未闭合 <think> 且存在 currentContent 时,先修剪 origin 尾部空白并补上闭合 </think>,再追加 currentContent;其它分支保持原拼接逻辑但调整了格式化与空值安全处理。
API 端点更新(示例)
packages/x/docs/x-sdk/demos/chat-providers/deep-seek-chat-provider.tsx
将示例中 DeepSeekChatProvider 的请求 URL 从 https://api.x.ant.design/api/big_model_glm-4.5-flash 更改为 https://api.x.ant.design/api/deepseek_chat_provider_stream(流式端点)。
内容渲染修改(示例)
packages/x/docs/x-sdk/demos/x-chat/deepSeek.tsx
移除将助手内容中连续双换行转换为单个换行的转换,内容现在原样传递给 XMarkdown 渲染。
测试:行为覆盖扩展
packages/x-sdk/src/chat-providers/__test__/providers.test.ts
新增“大量”高级测试用例,覆盖流式与非流式响应中的 reasoning_content、think 标签完成语义、对象型内容、缺失/空 responseHeaders、JSON 解析错误、originMessage 为 null/undefined 以及多步 think 流程等边界场景。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • 重点审查 DeepSeekChatProvider.ts 中对 <think> 插入、闭合、前后空白修剪与拼接逻辑的多种输入路径覆盖。
  • 审核新测试用例以确认断言与期望行为与实现一致,防止假阳性/假阴性。
  • 验证示例中更换的流式端点是否在示例上下文中正确使用(URL、请求体/头部示例是否需同步更新)。
  • 检查去掉双换行替换后在 XMarkdown 中的渲染效果是否符合预期(段落/空行显示)。

Poem

🐰 思考成串绕标签,
换端点去听新潮,
双行不折直呈现,
测试细审保周到,
萌兔鼓掌庆一跳 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了主要变更内容:修复DeepSeekChatProvider对标签的处理,这是PR的核心目标。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot bot added bug Something isn't working documentation Improvements or additions to documentation labels Dec 4, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 <think> tag, which previously led to incorrect Markdown rendering. The changes involve refining the content formatting within the provider, updating a demo's API endpoint, and removing a now-unnecessary Markdown preprocessing step, resulting in more robust and accurate display of AI-generated content.

Highlights

  • DeepSeek Provider Logic: Modified the DeepSeekChatProvider to correctly format content wrapped in <think> tags, ensuring proper Markdown rendering by adding strategic newlines and cleaning up existing ones.
  • API Endpoint Update: Updated the demo for the DeepSeek chat provider to use the appropriate streaming API endpoint.
  • Markdown Rendering Refinement: Removed a redundant newline replacement workaround in the XMarkdown component, as the DeepSeekChatProvider now handles Markdown formatting correctly.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@kimteayon kimteayon linked an issue Dec 4, 2025 that may be closed by this pull request
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 4, 2025

Deploying ant-design-x with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3434f8a and 39c3419.

📒 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
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.43%. Comparing base (3434f8a) to head (0395718).
⚠️ Report is 14 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

size-limit report 📦

Path Size
packages/x/dist/antdx.min.js 55.35 KB
packages/x-sdk/dist/x-sdk.min.js 7.34 KB (+40 B 🔺)
packages/x-markdown/dist/x-markdown.min.js 50.77 KB
packages/x-markdown/dist/plugins/code-high-light.min.js 313.73 KB
packages/x-markdown/dist/plugins/latex.min.js 61.95 KB
packages/x-markdown/dist/plugins/mermaid.min.js 883.19 KB

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 57b1979 and f75bbad.

📒 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 解析错误)
  • 完整的多步骤思考工作流

测试用例组织良好,命名清晰,期望值与生产代码的逻辑一致。

@codecov
Copy link

codecov bot commented Dec 4, 2025

Bundle Report

Changes will decrease total bundle size by 2.88MB (-48.99%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
x-markdown-array-push 1.25MB -2.88MB (-69.81%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: x-markdown-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
code-high-light.min.js (New) 1.25MB 1.25MB 100.0% 🚀
mermaid.min.js (Deleted) -4.13MB 0 bytes -100.0% 🗑️

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 5, 2025
@kimteayon kimteayon merged commit 5f36663 into main Dec 5, 2025
15 checks passed
@kimteayon kimteayon deleted the deepseepsdk branch December 5, 2025 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

思考模式下,思考结束后正文内容展示错误

3 participants