mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-29 06:47:30 +00:00
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>
46 lines
1.4 KiB
TypeScript
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;
|