result-panel.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. 'use client'
  2. import type { FC } from 'react'
  3. import StatusPanel from './status'
  4. import MetaData from './meta'
  5. import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
  6. import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
  7. type ResultPanelProps = {
  8. inputs?: string
  9. process_data?: string
  10. outputs?: string
  11. status: string
  12. error?: string
  13. elapsed_time?: number
  14. total_tokens?: number
  15. created_at?: number
  16. created_by?: string
  17. finished_at?: number
  18. steps?: number
  19. showSteps?: boolean
  20. }
  21. const ResultPanel: FC<ResultPanelProps> = ({
  22. inputs,
  23. process_data,
  24. outputs,
  25. status,
  26. error,
  27. elapsed_time,
  28. total_tokens,
  29. created_at,
  30. created_by,
  31. steps,
  32. showSteps,
  33. }) => {
  34. return (
  35. <div className='bg-white py-2'>
  36. <div className='px-4 py-2'>
  37. <StatusPanel
  38. status={status}
  39. time={elapsed_time}
  40. tokens={total_tokens}
  41. error={error}
  42. />
  43. </div>
  44. <div className='px-4 py-2 flex flex-col gap-2'>
  45. <CodeEditor
  46. readOnly
  47. title={<div>INPUT</div>}
  48. language={CodeLanguage.json}
  49. value={inputs}
  50. isJSONStringifyBeauty
  51. />
  52. {process_data && (
  53. <CodeEditor
  54. readOnly
  55. title={<div>PROCESS DATA</div>}
  56. language={CodeLanguage.json}
  57. value={process_data}
  58. isJSONStringifyBeauty
  59. />
  60. )}
  61. {(outputs || status === 'running') && (
  62. <CodeEditor
  63. readOnly
  64. title={<div>OUTPUT</div>}
  65. language={CodeLanguage.json}
  66. value={outputs}
  67. isJSONStringifyBeauty
  68. />
  69. )}
  70. </div>
  71. <div className='px-4 py-2'>
  72. <div className='h-[0.5px] bg-black opacity-5' />
  73. </div>
  74. <div className='px-4 py-2'>
  75. <MetaData
  76. status={status}
  77. executor={created_by}
  78. startTime={created_at}
  79. time={elapsed_time}
  80. tokens={total_tokens}
  81. steps={steps}
  82. showSteps={showSteps}
  83. />
  84. </div>
  85. </div>
  86. )
  87. }
  88. export default ResultPanel