agent-plans.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { CaretRightOutlined, CheckOutlined, ClockCircleOutlined } from '@ant-design/icons';
  2. import { GPTVis } from '@antv/gpt-vis';
  3. import { Collapse } from 'antd';
  4. import rehypeRaw from 'rehype-raw';
  5. import remarkGfm from 'remark-gfm';
  6. import markdownComponents from './config';
  7. interface Props {
  8. data: {
  9. name: string;
  10. num: number;
  11. status: 'complete' | 'todo';
  12. agent: string;
  13. markdown: string;
  14. }[];
  15. }
  16. function AgentPlans({ data }: Props) {
  17. if (!data || !data.length) return null;
  18. return (
  19. <Collapse
  20. bordered
  21. className='my-3'
  22. expandIcon={({ isActive }) => <CaretRightOutlined rotate={isActive ? 90 : 0} />}
  23. items={data.map((item, index) => {
  24. return {
  25. key: index,
  26. label: (
  27. <div>
  28. <span>
  29. {item.name} - {item.agent}
  30. </span>
  31. {item.status === 'complete' ? (
  32. <CheckOutlined className='!text-green-500 ml-2' />
  33. ) : (
  34. <ClockCircleOutlined className='!text-gray-500 ml-2' />
  35. )}
  36. </div>
  37. ),
  38. children: (
  39. <GPTVis components={markdownComponents} rehypePlugins={[rehypeRaw]} remarkPlugins={[remarkGfm]}>
  40. {item.markdown}
  41. </GPTVis>
  42. ),
  43. };
  44. })}
  45. />
  46. );
  47. }
  48. export default AgentPlans;