DB-GPT/web/components/chat/chat-content/agent-plans.tsx
Dreammy23 471689ba20
feat(web): Unified frontend code style (#1923)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: 谨欣 <echo.cmy@antgroup.com>
Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com>
Co-authored-by: yanzhiyong <932374019@qq.com>
2024-08-30 14:03:06 +08:00

54 lines
1.3 KiB
TypeScript

import { CaretRightOutlined, CheckOutlined, ClockCircleOutlined } from '@ant-design/icons';
import { GPTVis } from '@antv/gpt-vis';
import { Collapse } from 'antd';
import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm';
import markdownComponents from './config';
interface Props {
data: {
name: string;
num: number;
status: 'complete' | 'todo';
agent: string;
markdown: string;
}[];
}
function AgentPlans({ data }: Props) {
if (!data || !data.length) return null;
return (
<Collapse
bordered
className='my-3'
expandIcon={({ isActive }) => <CaretRightOutlined rotate={isActive ? 90 : 0} />}
items={data.map((item, index) => {
return {
key: index,
label: (
<div>
<span>
{item.name} - {item.agent}
</span>
{item.status === 'complete' ? (
<CheckOutlined className='!text-green-500 ml-2' />
) : (
<ClockCircleOutlined className='!text-gray-500 ml-2' />
)}
</div>
),
children: (
<GPTVis components={markdownComponents} rehypePlugins={[rehypeRaw]} remarkPlugins={[remarkGfm]}>
{item.markdown}
</GPTVis>
),
};
})}
/>
);
}
export default AgentPlans;