Skip to content

Commit

Permalink
chore: note stream output
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Dec 2, 2024
1 parent 9be163a commit 94e5b02
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions components/bubble/demo/gpt-vis.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## zh-CN

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

## en-US

Cooperate with `@antv/GPT-Vis` to achieve customized rendering chart of LLM output.
Cooperate with `@antv/GPT-Vis` to achieve customized rendering chart of LLM stream output.
32 changes: 23 additions & 9 deletions components/bubble/demo/gpt-vis.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Bubble } from '@ant-design/x';
import type { BubbleProps } from '@ant-design/x';
import { GPTVis } from '@antv/gpt-vis';
import { Button, Flex } from 'antd';
/* eslint-disable react/no-danger */
import React from 'react';

Expand All @@ -22,16 +23,29 @@ Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022.
const RenderMarkdown: BubbleProps['messageRender'] = (content) => <GPTVis>{content}</GPTVis>;

const App = () => {
const [rerenderKey, setRerenderKey] = React.useState(0);

return (
<Bubble
typing={{ step: 20, interval: 150 }}
content={text}
messageRender={RenderMarkdown}
avatar={{
src: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*2Q5LRJ3LFPUAAAAAAAAAAAAADmJ7AQ/fmt.webp',
}}
variant="outlined"
/>
<Flex vertical gap="small" key={rerenderKey}>
<Button
style={{ alignSelf: 'flex-end' }}
onClick={() => {
setRerenderKey((prev) => prev + 1);
}}
>
ReRender
</Button>

<Bubble
typing={{ step: 20, interval: 150 }}
content={text}
messageRender={RenderMarkdown}
avatar={{
src: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*2Q5LRJ3LFPUAAAAAAAAAAAAADmJ7AQ/fmt.webp',
}}
variant="outlined"
/>
</Flex>
);
};

Expand Down

0 comments on commit 94e5b02

Please sign in to comment.