mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-01 09:06:55 +00:00
refactor: upgrade gpt-vis (#1883)
This commit is contained in:
@@ -6,7 +6,7 @@ import { githubLightTheme } from '@uiw/react-json-view/githubLight';
|
||||
import { Alert, Spin } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import React, { useContext, useMemo } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { GPTVis } from '@antv/gpt-vis';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
|
||||
@@ -41,30 +41,36 @@ const VisResponse: React.FC<{ data: VisResponseProps }> = ({ data }) => {
|
||||
return (
|
||||
<div className="flex flex-1 flex-col">
|
||||
<Alert
|
||||
className={classNames('mb-4', {
|
||||
'bg-[#fafafa] border-[transparent]': !type,
|
||||
className={classNames("mb-4", {
|
||||
"bg-[#fafafa] border-[transparent]": !type,
|
||||
})}
|
||||
message={data.name}
|
||||
type={type}
|
||||
{...(type && { showIcon: true })}
|
||||
{...(type === 'warning' && { icon: <Spin indicator={<LoadingOutlined spin />} /> })}
|
||||
{...(type === "warning" && {
|
||||
icon: <Spin indicator={<LoadingOutlined spin />} />,
|
||||
})}
|
||||
/>
|
||||
{data.result && (
|
||||
<JsonView
|
||||
style={{ ...theme, width: '100%', padding: 10 }}
|
||||
style={{ ...theme, width: "100%", padding: 10 }}
|
||||
className={classNames({
|
||||
'bg-[#fafafa]': mode === 'light',
|
||||
"bg-[#fafafa]": mode === "light",
|
||||
})}
|
||||
value={JSON.parse(data.result || '{}')}
|
||||
value={JSON.parse(data.result || "{}")}
|
||||
enableClipboard={false}
|
||||
displayDataTypes={false}
|
||||
objectSortKeys={false}
|
||||
/>
|
||||
)}
|
||||
{data.err_msg && (
|
||||
<ReactMarkdown components={markdownComponents} remarkPlugins={[remarkGfm]} rehypePlugins={[rehypeRaw]}>
|
||||
<GPTVis
|
||||
components={markdownComponents}
|
||||
remarkPlugins={[remarkGfm]}
|
||||
rehypePlugins={[rehypeRaw]}
|
||||
>
|
||||
{data.err_msg}
|
||||
</ReactMarkdown>
|
||||
</GPTVis>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user