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 GPT-Vis demo for bubble #288

Merged
merged 10 commits into from
Dec 2, 2024
Merged

Conversation

lvisei
Copy link
Contributor

@lvisei lvisei commented Dec 1, 2024

image

Summary by CodeRabbit

  • 新功能
    • 引入了新的 gpt-vis 组件,支持基于大语言模型输出的图表渲染。
    • 添加了对 @antv/GPT-Vis 的支持,提供了动态内容展示。
  • 文档
    • 更新了 gpt-vis.md 文件,增加了中英文使用说明。
    • 在 Bubble 组件文档中新增了使用 GPT-Vis 渲染图表的示例。
  • 依赖项
    • devDependencies 中添加了 @antv/gpt-vis 依赖。

Copy link
Contributor

coderabbitai bot commented Dec 1, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

此次更改在多个文件中引入了与“GPT-Vis”相关的新功能和配置。在.dumirc.ts文件中添加了externals配置,以优化构建过程,同时在测试文件中更新了extendTestdemoTest函数的调用,允许跳过特定的测试。在文档中,新增了中英文的gpt-vis.md部分,展示如何使用@antv/GPT-Vis进行图表渲染。此外,新增了一个React组件App,并在文档中添加了相关示例。最后,package.json中添加了@antv/gpt-vis的依赖。

Changes

文件路径 更改摘要
.dumirc.ts 新增externals配置,指定mapbox-glmaplibre-gl为外部库。
components/bubble/__tests__/demo-extend.test.ts 更新extendTest函数调用,新增选项对象以跳过gpt-vis演示测试。
components/bubble/__tests__/demo.test.ts 更新demoTest函数调用,新增选项对象以跳过gpt-vis演示测试。
components/bubble/demo/gpt-vis.md 新增中英文部分,描述如何使用@antv/GPT-Vis进行图表渲染。
components/bubble/demo/gpt-vis.tsx 新增App组件和RenderMarkdown函数,用于渲染Bubble组件和动态内容。
components/bubble/index.en-US.md 在文档中新增示例,展示如何使用GPT-Vis渲染图表。
components/bubble/index.zh-CN.md 在文档中新增示例,展示如何使用GPT-Vis渲染图表。
package.json devDependencies中新增依赖@antv/gpt-vis,版本为^0.3.0

Possibly related PRs

兔子欢快跳跃,代码更新真美妙,
GPT-Vis来助阵,图表渲染乐无穷。
测试跳过不烦恼,文档新增更清晰,
依赖包也添新,开发之路更顺畅! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9be163a and a475af4.

📒 Files selected for processing (2)
  • components/bubble/demo/gpt-vis.md (1 hunks)
  • components/bubble/demo/gpt-vis.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/bubble/demo/gpt-vis.md
  • components/bubble/demo/gpt-vis.tsx

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 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 Dec 1, 2024

Preview is ready

Copy link

codecov bot commented Dec 1, 2024

Bundle Report

Bundle size has no change ✅

Copy link

socket-security bot commented Dec 1, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@ant-design/[email protected] None 0 34.4 kB zombiej
npm/@ant-design/[email protected] environment 0 91.2 kB afc163
npm/@ant-design/[email protected] environment 0 285 kB zombiej
npm/@ant-design/[email protected] None 0 43.9 kB zombiej
npm/@ant-design/[email protected] environment 0 8.74 MB afc163
npm/@ant-design/[email protected] filesystem 0 65.7 kB madccc
npm/@antv/[email protected] None 0 4.77 MB lvisei
npm/@babel/[email protected] None 0 248 kB nicolo-ribaudo
npm/@biomejs/[email protected] None 0 210 kB conaclos, dominionl, ematipico, ...1 more
npm/@codecov/[email protected] None 0 59.5 kB codecov-devops
npm/@codesandbox/[email protected] network 0 1.21 MB danilowoz
npm/@ctrl/[email protected] None 0 244 kB scttcper
npm/@emotion/[email protected] None 0 824 kB andarist, emmatown, emotion-release-bot, ...1 more
npm/@emotion/[email protected] environment 0 48.7 kB emotion-release-bot
npm/@happy-dom/[email protected] None 0 31.5 kB davidortner
npm/@ianvs/[email protected] environment, unsafe 0 114 kB ianvs
npm/@madccc/[email protected] None 0 19 kB madccc
npm/@microflash/[email protected] None 0 6.71 kB naiyer
npm/@npmcli/[email protected] environment 0 18.3 kB npm-cli-ops
npm/@octokit/[email protected] None 0 8.28 kB gr2m, kfcampbell, nickfloyd, ...1 more
npm/@qixian.cs/[email protected] network 0 19.6 kB chenshuai2144
npm/@rc-component/[email protected] environment, filesystem, shell 0 8.62 kB afc163
npm/@rc-component/[email protected] None 0 184 kB afc163, madccc, peachscript, ...1 more
npm/@size-limit/[email protected] None 0 3.43 kB ai
npm/@stackblitz/[email protected] None 0 186 kB tsulkowski
npm/@testing-library/[email protected] environment 0 2.43 MB testing-library-bot
npm/@testing-library/[email protected] None 0 282 kB brrianalexis, cmckinstry, dfcook, ...13 more
npm/@testing-library/[email protected] environment 0 329 kB testing-library-bot
npm/@testing-library/[email protected] None 0 435 kB testing-library-bot
npm/@types/[email protected] None 0 24.6 kB types
npm/@types/[email protected] None 0 42.2 kB types
npm/@types/[email protected] None 0 13.1 kB types
npm/@types/[email protected] None 0 36.8 kB types
npm/@types/[email protected] None 0 9.1 kB types
npm/@types/[email protected] None 0 4.58 kB types
npm/@types/[email protected] None 0 73.6 kB types
npm/@types/[email protected] None 0 2.77 kB types
npm/@types/[email protected] None 0 6.62 kB types
npm/@types/[email protected] None 0 6.09 kB types
npm/@types/[email protected] None 0 9.68 kB types
npm/@types/[email protected] None 0 78.8 kB types
npm/@types/[email protected] None 0 1.12 MB types
npm/@types/[email protected] None 0 21.9 kB types
npm/@types/[email protected] None 0 868 kB types
npm/@types/[email protected] None 0 73 kB types
npm/@types/[email protected] None 0 6.27 kB types
npm/@types/[email protected] None 0 4.83 kB types
npm/@types/[email protected] None 0 1.7 kB types
npm/@types/[email protected] None 0 7.87 kB types
npm/@types/[email protected] None 0 5.47 kB types
npm/@types/[email protected] None 0 19.4 kB types
npm/@types/[email protected] None 0 6.51 kB types
npm/@types/[email protected] None 0 7.46 kB types
npm/@types/[email protected] None 0 4.36 kB types
npm/@types/[email protected] None 0 0 B
npm/@types/[email protected] None 0 5.75 kB types
npm/@types/[email protected] None 0 7.36 kB types
npm/@types/[email protected] None 0 439 kB types
npm/@types/[email protected] None 0 23.3 kB types
npm/@types/[email protected] None 0 8.22 kB types
npm/@types/[email protected] None 0 30.8 kB types
npm/@types/[email protected] None 0 6.48 kB types
npm/@types/[email protected] None 0 2.71 kB types
npm/@umijs/[email protected] environment, filesystem Transitive: unsafe +1 11.3 MB chenshuai2144
npm/[email protected] filesystem 0 121 kB cthackers
npm/[email protected] filesystem 0 2.73 MB fengmk2
npm/[email protected] environment 0 191 kB arvinxx
npm/[email protected] None 0 1.22 MB madccc
npm/[email protected] environment +1 47.7 MB madccc
npm/[email protected] network 0 2.11 MB jasonsaayman
npm/[email protected] None 0 7.78 kB marcofugaro
npm/[email protected] environment, filesystem 0 64.2 kB ai
npm/[email protected] None +1 42.1 kB sindresorhus
npm/[email protected] None 0 1.25 MB feedic
npm/[email protected] None 0 10.5 kB theron
npm/[email protected] None 0 23.6 kB jedwatson
npm/[email protected] None 0 62.2 kB andidittrich
npm/[email protected] None 0 15.1 kB sudodoki
npm/[email protected] environment 0 29.1 kB kentcdodds
npm/[email protected] network 0 88.1 kB lquixada
npm/[email protected] None 0 778 B ehsalazar
npm/[email protected] None 0 670 kB iamkun
npm/[email protected] filesystem 0 8.91 kB benjycui
npm/[email protected] None 0 38.7 kB wxh16144
npm/[email protected] environment, eval, filesystem 0 2.92 MB yifankakaxi
npm/[email protected] None 0 32.5 kB hirokiosame
npm/[email protected] filesystem 0 96.7 kB mrmlnc
npm/[email protected] Transitive: filesystem +1 281 kB yifankakaxi
npm/[email protected] None 0 12.4 kB camsong
npm/[email protected] None 0 54.9 kB ryanzim
npm/[email protected] filesystem, shell +1 848 kB tschaub
npm/[email protected] None 0 475 kB isaacs
npm/[email protected] network, shell, unsafe 0 12.2 MB davidortner
npm/[email protected] network 0 1.87 MB arvinxx
npm/[email protected] environment, filesystem, network 0 124 kB thornjad
npm/[email protected] None 0 4.04 kB typicode
npm/[email protected] None 0 8.38 kB keyanzhang
npm/[email protected] environment 0 627 kB mweststrate
npm/[email protected] None 0 71.7 kB danielchatfield, mischah, ruyadorno, ...1 more
npm/[email protected] None 0 3.81 kB sibiraj-s
npm/[email protected] Transitive: network +1 169 kB mattandrews
npm/[email protected] None 0 21 kB nickcolley
npm/[email protected] None 0 112 kB atool
npm/[email protected] unsafe 0 9.37 kB simenb
npm/[email protected] environment, filesystem, shell 0 84.9 kB amexopensource
npm/[email protected] None 0 3.72 kB neoziro
npm/[email protected] None 0 5.01 kB simenb
npm/[email protected] None 0 1.25 MB timmywil
npm/[email protected] None 0 3.11 MB domenic, joris-van-der-wel, sebmaster, ...3 more
npm/[email protected] None 0 21.2 kB benjycui
npm/[email protected] None 0 28.3 kB benjycui
npm/[email protected] None 0 122 kB okonet
npm/[email protected] network 0 25.7 MB airnan
npm/[email protected] None 0 1.35 MB 6tail
npm/[email protected] None 0 176 kB pieroxy
npm/[email protected] Transitive: environment, filesystem +1 939 kB vitaly
npm/[email protected] None 0 13.8 kB boblauer
npm/[email protected] network 0 107 kB node-fetch-bot
npm/[email protected] environment, filesystem, network, shell +1 5.69 MB mikaelb
npm/[email protected] None 0 31.8 kB rstacruz
npm/[email protected] environment 0 55.2 kB sindresorhus
npm/[email protected] None 0 106 kB zombiej
npm/[email protected] environment +1 265 kB zombiej
npm/[email protected] environment 0 4.51 MB react-bot
npm/[email protected] environment 0 318 kB react-bot

🚮 Removed packages: npm/[email protected]

View full report↗︎

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

🧹 Outside diff range and nitpick comments (4)
components/bubble/demo/gpt-vis.tsx (3)

7-20: 建议将示例数据抽离为单独的常量

建议将可视化数据从模板字符串中抽离出来,以提高代码的可维护性和可读性。

建议修改如下:

+const CHART_DATA = {
+  type: "line",
+  data: [
+    {"time":2013,"value":59.3},
+    {"time":2014,"value":64.4},
+    // ... other data points
+  ],
+  axisXTitle: "year",
+  axisYTitle: "sale"
+};

const text = `
**GPT-Vis**, Components for GPTs, generative AI, and LLM projects. Not only UI Components. [more...](https://github.com/antvis/GPT-Vis) \n\n

Here's a visualization of Haidilao's food delivery revenue from 2013 to 2022. You can see a steady increase over the years, with notable *growth* particularly in recent years.

\`\`\`vis-chart
${JSON.stringify(CHART_DATA, null, 2)}
\`\`\`
`;

22-22: 建议添加类型注解

为了提高代码的可维护性和类型安全性,建议为 content 参数添加明确的类型注解。

建议修改如下:

-const RenderMarkdown: BubbleProps['messageRender'] = (content) => <GPTVis>{content}</GPTVis>;
+const RenderMarkdown: BubbleProps['messageRender'] = (content: string) => <GPTVis>{content}</GPTVis>;

24-36: 建议添加错误边界处理

考虑到 GPT-Vis 可能在渲染过程中出现错误,建议添加错误边界处理。

建议添加 ErrorBoundary 组件:

+class ChartErrorBoundary extends React.Component {
+  state = { hasError: false };
+
+  static getDerivedStateFromError() {
+    return { hasError: true };
+  }
+
+  render() {
+    if (this.state.hasError) {
+      return <div>图表渲染失败</div>;
+    }
+    return this.props.children;
+  }
+}

const App = () => {
  return (
+   <ChartErrorBoundary>
      <Bubble
        typing={{ step: 30, interval: 300 }}
        content={text}
        messageRender={RenderMarkdown}
        avatar={{
          src: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*2Q5LRJ3LFPUAAAAAAAAAAAAADmJ7AQ/fmt.webp',
        }}
        variant="outlined"
      />
+   </ChartErrorBoundary>
  );
};
components/bubble/demo/gpt-vis.md (1)

Line range hint 5-8: 英文描述需要优化

英文描述的语法需要改进,建议修改为:

-Cooperate with `@antv/GPT-Vis` to achieve customized rendering chart of LLM output.
+Cooperate with `@antv/GPT-Vis` to achieve customized chart rendering for LLM output.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: You might be missing the article “a” here.
Context: ...operate with @antv/GPT-Vis to achieve customized rendering chart of LLM output.

(AI_EN_LECTOR_MISSING_DETERMINER_A)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9e8234d and 1dcc9a9.

📒 Files selected for processing (8)
  • .dumirc.ts (1 hunks)
  • components/bubble/__tests__/demo-extend.test.ts (1 hunks)
  • components/bubble/__tests__/demo.test.ts (1 hunks)
  • components/bubble/demo/gpt-vis.md (1 hunks)
  • components/bubble/demo/gpt-vis.tsx (1 hunks)
  • components/bubble/index.en-US.md (1 hunks)
  • components/bubble/index.zh-CN.md (1 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
components/bubble/demo/gpt-vis.md

[uncategorized] ~7-~7: You might be missing the article “a” here.
Context: ...operate with @antv/GPT-Vis to achieve customized rendering chart of LLM output.

(AI_EN_LECTOR_MISSING_DETERMINER_A)

🔇 Additional comments (6)
components/bubble/__tests__/demo.test.ts (1)

3-6: 测试配置更改合理!

跳过 gpt-vis 演示测试的配置是正确的,因为该演示需要真实的浏览器环境而不是 jsdom。这种处理方式可以避免在不适合的环境中运行测试而导致的失败。

components/bubble/__tests__/demo-extend.test.ts (1)

3-6: 测试配置保持一致性!

与 demo.test.ts 保持了一致的配置,同样跳过了 gpt-vis 演示测试。这种一致性的处理方式确保了测试行为的可预测性。

components/bubble/index.zh-CN.md (1)

33-33: 文档示例顺序合理

新增的 GPT-Vis 示例放置在文档末尾是合适的,保持了文档的连贯性。

components/bubble/index.en-US.md (1)

32-32: 中英文文档保持一致

新增的 GPT-Vis 示例在中英文文档中的位置和描述保持一致,符合双语文档维护规范。

.dumirc.ts (1)

43-47: 构建优化配置正确!

外部依赖配置正确映射了 mapbox-gl 和 maplibre-gl,这有助于优化 GPT-Vis 的构建过程。

package.json (1)

100-100: 请验证 GPT-Vis 的版本兼容性

建议验证 @antv/gpt-vis 0.3.0 版本是否为最新的稳定版本,并确认其与项目的其他依赖没有兼容性问题。

✅ Verification successful

@antv/gpt-vis 版本兼容性验证完成

经验证:

  • 当前使用的 0.3.0 版本是最新的稳定版本
  • 项目仅在 bubble 组件的演示文件中使用该依赖,用于渲染 Markdown 内容
  • 与项目的 peer dependencies(React、React DOM 和 Antd)没有冲突
  • 使用方式符合预期,作为开发依赖使用合适
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查 GPT-Vis 的最新版本和已知问题
npm view @antv/gpt-vis versions --json | jq -r '.[-1]'

# 检查是否存在依赖冲突
npm ls @antv/gpt-vis

Length of output: 137


Script:

#!/bin/bash
# 检查项目中使用 @antv/gpt-vis 的地方
rg -l "@antv/gpt-vis"

# 检查 package.json 中的 peer dependencies
cat package.json | jq '.peerDependencies'

# 检查项目中的其他 AntV 相关依赖
cat package.json | jq '.dependencies, .devDependencies' | rg -i "antv"

Length of output: 285


Script:

#!/bin/bash
# 检查 gpt-vis demo 文件的具体使用方式
cat components/bubble/demo/gpt-vis.tsx

# 检查是否有相关的测试文件
fd -e test.tsx -e test.ts -e spec.tsx -e spec.ts gpt-vis

Length of output: 1444

Comment on lines 1 to 4
## zh-CN

配合 `@antv/GPT-Vis` 实现大模型输出的图表渲染。

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议添加示例代码

当前文档缺少具体的使用示例,建议添加:

  1. 基本的集成代码示例
  2. 数据格式示例
  3. 常见用例展示

Copy link

codecov bot commented Dec 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.13%. Comparing base (9e8234d) to head (a475af4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #288   +/-   ##
=======================================
  Coverage   91.13%   91.13%           
=======================================
  Files          66       66           
  Lines        1422     1422           
  Branches      379      364   -15     
=======================================
  Hits         1296     1296           
  Misses        126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants