You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

agent-content.tsx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import type { FC } from 'react'
  2. import { memo } from 'react'
  3. import type {
  4. ChatItem,
  5. } from '../../types'
  6. import { Markdown } from '@/app/components/base/markdown'
  7. import Thought from '@/app/components/base/chat/chat/thought'
  8. import { FileList } from '@/app/components/base/file-uploader'
  9. import { getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils'
  10. type AgentContentProps = {
  11. item: ChatItem
  12. responding?: boolean
  13. }
  14. const AgentContent: FC<AgentContentProps> = ({
  15. item,
  16. responding,
  17. }) => {
  18. const {
  19. annotation,
  20. agent_thoughts,
  21. } = item
  22. if (annotation?.logAnnotation)
  23. return <Markdown content={annotation?.logAnnotation.content || ''} />
  24. return (
  25. <div>
  26. {agent_thoughts?.map((thought, index) => (
  27. <div key={index} className='px-2 py-1'>
  28. {thought.thought && (
  29. <Markdown content={thought.thought} />
  30. )}
  31. {/* {item.tool} */}
  32. {/* perhaps not use tool */}
  33. {!!thought.tool && (
  34. <Thought
  35. thought={thought}
  36. isFinished={!!thought.observation || !responding}
  37. />
  38. )}
  39. {
  40. !!thought.message_files?.length && (
  41. <FileList
  42. files={getProcessedFilesFromResponse(thought.message_files.map((item: any) => ({ ...item, related_id: item.id })))}
  43. showDeleteAction={false}
  44. showDownloadAction={true}
  45. canPreview={true}
  46. />
  47. )
  48. }
  49. </div>
  50. ))}
  51. </div>
  52. )
  53. }
  54. export default memo(AgentContent)