iteration.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use client'
  2. import { useTranslation } from 'react-i18next'
  3. import type { FC } from 'react'
  4. import ToolCall from './tool-call'
  5. import cn from '@/utils/classnames'
  6. import type { AgentIteration } from '@/models/log'
  7. type Props = {
  8. isFinal: boolean
  9. index: number
  10. iterationInfo: AgentIteration
  11. }
  12. const Iteration: FC<Props> = ({ iterationInfo, isFinal, index }) => {
  13. const { t } = useTranslation()
  14. return (
  15. <div className={cn('px-4 py-2')}>
  16. <div className='flex items-center'>
  17. {isFinal && (
  18. <div className='shrink-0 mr-3 text-gray-500 text-xs leading-[18px] font-semibold'>{t('appLog.agentLogDetail.finalProcessing')}</div>
  19. )}
  20. {!isFinal && (
  21. <div className='shrink-0 mr-3 text-gray-500 text-xs leading-[18px] font-semibold'>{`${t('appLog.agentLogDetail.iteration').toUpperCase()} ${index}`}</div>
  22. )}
  23. <div className='grow h-[1px] bg-gradient-to-r from-[#f3f4f6] to-gray-50'></div>
  24. </div>
  25. <ToolCall
  26. isLLM
  27. isFinal={isFinal}
  28. tokens={iterationInfo.tokens}
  29. observation={iterationInfo.tool_raw.outputs}
  30. finalAnswer={iterationInfo.thought}
  31. toolCall={{
  32. status: 'success',
  33. tool_icon: null,
  34. }}
  35. />
  36. {iterationInfo.tool_calls.map((toolCall, index) => (
  37. <ToolCall
  38. isLLM={false}
  39. key={index}
  40. toolCall={toolCall}
  41. />
  42. ))}
  43. </div>
  44. )
  45. }
  46. export default Iteration