Skip to content
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

docs: add docs of integrate DeepSeek's model services #519

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YumoImer
Copy link
Collaborator

@YumoImer YumoImer commented Feb 7, 2025

fix: #506

Summary by CodeRabbit

  • Documentation
    • 新增了中英文版本的集成指南,帮助开发者在基于 Ant Design X 的应用中对接 DeepSeek 模型服务。
    • 文档详细描述了如何配置必要参数(如基础 URL 和 API 密钥)、处理模型推理与响应、以及重要的安全提示。
    • 附带示例展示了通过 React 组件与 hooks 实现消息交互和错误处理。

Copy link
Contributor

coderabbitai bot commented Feb 7, 2025

📝 Walkthrough

Walkthrough

本次 PR 新增两个文档文件(英文版和中文版),详细说明了如何在 Ant Design X 应用中集成 DeepSeek 的推理模型 deepseek-reasoner。文档介绍了获取 base URL、API key 等必需参数、模型调用流程、错误处理(部分逻辑为注释)以及示例代码。中文版还展示了新增接口、Demo 组件、onSubmit 方法及相关变量。

Changes

文件 变更摘要
docs/react/model-use-deepseek.[en-US,zh-CN].md 新增 DeepSeek 模型集成示例文档。英文版阐述基础接入步骤与安全提示;中文版除基础内容外,增加了 YourMessage 接口、Demo 组件、onSubmit 方法及相关变量示例。

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户
    participant D as Demo组件
    participant S as DeepSeek服务层
    participant A as DeepSeek API

    U->>D: 提交消息
    D->>S: 调用 onSubmit()
    S->>A: 发送请求 (base URL, API key)
    A-->>S: 返回 reasoning 与答案
    S->>D: 更新组件状态
    D-->>U: 显示响应
Loading

Assessment against linked issues

Objective Addressed Explanation
Add example for DeepSeek R1 (#506)

Suggested reviewers

  • afc163

Poem

跳跃的小兔在此歌唱,
新文档如春风轻扬,
每行代码似苔痕闪光,
集成智慧奔向远方,
共舞未来,跃动光芒! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Feb 7, 2025

Preview is ready

Copy link

Walkthrough

This pull request adds documentation for integrating DeepSeek's model services into applications built with Ant Design X. It provides guidance on obtaining necessary parameters and integrating the DeepSeek-R1 reasoning model, highlighting the model's ability to generate reasoning content alongside final answers.

Changes

Files Summary
docs/react/model-use-deepseek.en-US.md, docs/react/model-use-deepseek.zh-CN.md Added new documentation files explaining how to integrate DeepSeek's model services, including setup instructions and code examples for using the DeepSeek-R1 reasoning model.

Copy link

codecov bot commented Feb 7, 2025

Bundle Report

Bundle size has no change ✅

@YumoImer YumoImer requested a review from a team February 7, 2025 07:47
};

export default Demo;
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加个动图演示一下接入后的效果?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这会貌似 R1 服务挂了,一会我再试试

Copy link

github-actions bot commented Feb 7, 2025

size-limit report 📦

Path Size
dist/antdx.min.js 40.34 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: 0

🧹 Nitpick comments (13)
docs/react/model-use-deepseek.zh-CN.md (7)

9-12: 文档介绍部分建议增强说明
这部分简要介绍了指南内容并提供了相关链接。建议确认链接地址的有效性,并视情况补充更多背景说明以便初次接触者更容易理解。


18-24: DeepSeek-R1 模型接入描述建议补充细节
该部分详细说明了 DeepSeek-R1 模型的工作流程,包括生成思维链和最终回答。建议在说明中增加对思维链作用的更详细解释,以帮助读者更好理解模型输出的意义。


26-145: 代码示例逻辑与结构良好
整个代码块示例清晰展示了如何利用 Ant Design X 的 hooks 与 OpenAI 客户端集成 DeepSeek 模型服务,示例中包含了流处理、状态更新及消息渲染。
建议:

  • 考虑在实际生产环境中移除或限制 console.log 的调试输出。
  • 补充 error 捕获处理,建议在 catch 块中调用 onError() 以便更好地反馈异常情况。

52-106: 流式响应处理逻辑清晰
在 useXAgent 钩子中,通过异步流处理更新内容和思维链的实现逻辑清楚,能够实时反馈模型输出。建议:

  • 补充 error 分支的具体处理(例如调用 onError()),以保证在请求失败时能给出合理反馈;
  • 在生产代码中,如不需要大量调试信息,建议移除或减少 console.log 调用。

108-117: 用户交互逻辑完善
使用 useXChat 钩子和 onSubmit 实现消息的发送与处理,逻辑清晰。建议对 onSubmit 的输入值增加校验,防止空字符串或格式错误的情况发生。


119-134: 消息渲染部分建议细化
通过 map 生成消息列表的方式直观展示了 reasoning_content 与 content,能够有效帮助用户辨识模型输出。建议:

  • 如项目中有特殊的消息样式需求,可在此基础上进一步封装或添加样式处理;
  • 保证每条消息的唯一性标识符的稳定性。

136-142: 组件整体返回结构清晰
返回的组件结构简单明了,包含消息列表和消息发送组件,符合常规交互模式。可考虑在外层容器上增加响应式样式或布局优化,以提供更好的用户体验。

docs/react/model-use-deepseek.en-US.md (6)

18-24: DeepSeek-R1 模型集成描述详尽
该部分说明了 DeepSeek-R1 模型的工作方式及输出结构,内容详尽。建议增加注释提醒用户注意模型输出格式可能随版本变动。


26-145: 代码示例说明充分
代码示例展示了如何利用 React 与 Ant Design X 的 hooks 集成 DeepSeek 模型,涵盖了客户端配置、消息处理、流式请求及消息渲染。建议:

  • 在客户端配置部分重申 dangerouslyAllowBrowser 的使用风险;
  • 对错误捕获部分给予更多处理(如调用 onError),确保异常情况能被妥善反馈;
  • 如非调试模式,建议移除 console.log 调用。

52-106: useXAgent 异步流处理逻辑
在 useXAgent 中对流数据进行处理与更新的方法逻辑正确,能够实时调用 onUpdate 反馈状态。建议补全错误处理逻辑(例如调用 onError)以增强健壮性。


108-117: 聊天交互部分逻辑完善
使用 useXChat 与 onSubmit 实现消息发送机制,逻辑清晰。建议增加输入校验,避免空输入影响交互效果。


119-134: 消息渲染实现直观
通过 Bubble.List 渲染消息列表的方式简洁有效,能同时展示 reasoning 和 content。建议考虑针对长文本的样式处理,以提升阅读体验。


136-142: 返回组件结构合理
组件的返回结构简洁直观,包含消息列表和消息发送组件,符合标准交互设计。建议根据项目整体风格调整容器样式。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea935d7 and 028d39a.

📒 Files selected for processing (2)
  • docs/react/model-use-deepseek.en-US.md (1 hunks)
  • docs/react/model-use-deepseek.zh-CN.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test / react component workflow
  • GitHub Check: build preview
  • GitHub Check: size
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (10)
docs/react/model-use-deepseek.zh-CN.md (4)

1-7: 文档元数据部分检查
YAML frontmatter 定义了分组、标题、顺序和标签,格式清晰,符合文档管理规范。


13-17: 参数获取说明清晰
“相关参数获取”部分列出了获取 baseURL 和 API Key 的步骤及链接,内容简洁明了。检查链接是否最新,如有需要可补充额外说明。


33-37: 客户端配置安全性提醒
在 OpenAI 客户端配置中使用了 dangerouslyAllowBrowser 参数,已在文档中提示存在安全风险。请确保团队对此配置风险有充分评估,并结合项目要求决定是否需要在示例中提供替代方案。


41-50: 消息接口定义合理
YourMessage 接口明确定义了 content 和 reasoning_content 两个字段,对于展示模型输出非常直观。如将来模型返回更多信息,可考虑扩展接口。

docs/react/model-use-deepseek.en-US.md (6)

1-7: Frontmatter 元数据校验
YAML frontmatter 定义了分组、标题、顺序和标签,符合英文文档的规范。请确认与团队文档结构保持一致。


9-12: Introduction 部分逻辑清晰
文档开头介绍了本指南的用途及相关链接,语言简洁易懂。建议确认链接内容的有效性,必要时补充更多背景说明。


13-17: 参数获取说明明确
“Obtaining Required Parameters” 部分准确列出了获取 baseURL 和 API Key 的方法与链接,内容与中文文档保持一致。


33-37: OpenAI 客户端配置安全提醒
客户端配置中包含 dangerouslyAllowBrowser 参数,请在使用前确认安全性风险,并确保该配置符合项目安全标准。


41-50: 消息接口 YourMessage 定义合理
YourMessage 接口清楚定义了 content 与 reasoning_content 字段,适用于捕捉模型返回内容。后续如需支持更多字段,可考虑扩展接口。


144-144: 组件导出正确
确保组件通过 export default 正确导出,以便在其它模块中正常引用。

@afc163
Copy link
Member

afc163 commented Feb 7, 2025

#514

这个问题是否有回答。

Copy link

Deploying ant-design-x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 028d39a
Status:🚫  Build failed.

View logs

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.

Add example for DeepSeek R1
2 participants