DB-GPT/web/components/chat/chat-content/agent-messages.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

46 lines
1.4 KiB
TypeScript

import ModelIcon from '@/new-components/chat/content/ModelIcon';
import { SwapRightOutlined } from '@ant-design/icons';
import { GPTVis } from '@antv/gpt-vis';
import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm';
import ReferencesContent from './ReferencesContent';
import markdownComponents from './config';
interface Props {
data: {
sender: string;
receiver: string;
model: string | null;
markdown: string;
resource: any;
}[];
}
function AgentMessages({ data }: Props) {
if (!data || !data.length) return null;
return (
<>
{data.map((item, index) => (
<div key={index} className='rounded'>
<div className='flex items-center mb-3 text-sm'>
{item.model ? <ModelIcon model={item.model} /> : <div className='rounded-full w-6 h-6 bg-gray-100' />}
<div className='ml-2 opacity-70'>
{item.sender}
<SwapRightOutlined className='mx-2 text-base' />
{item.receiver}
</div>
</div>
<div className='whitespace-normal text-sm mb-3'>
<GPTVis components={markdownComponents} remarkPlugins={[remarkGfm]} rehypePlugins={[rehypeRaw]}>
{item.markdown}
</GPTVis>
</div>
{item.resource && item.resource !== 'null' && <ReferencesContent references={item.resource} />}
</div>
))}
</>
);
}
export default AgentMessages;