node.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import type { ToolNodeType } from './types'
  4. import type { NodeProps } from '@/app/components/workflow/types'
  5. import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
  6. const Node: FC<NodeProps<ToolNodeType>> = ({
  7. data,
  8. }) => {
  9. const { tool_configurations } = data
  10. const toolConfigs = Object.keys(tool_configurations || {})
  11. if (!toolConfigs.length)
  12. return null
  13. return (
  14. <div className='mb-1 px-3 py-1'>
  15. <div className='space-y-0.5'>
  16. {toolConfigs.map((key, index) => (
  17. <div key={index} className='flex items-center h-6 justify-between bg-gray-100 rounded-md px-1 space-x-1 text-xs font-normal text-gray-700'>
  18. <div title={key} className='max-w-[100px] shrink-0 truncate text-xs font-medium text-gray-500 uppercase'>
  19. {key}
  20. </div>
  21. {typeof tool_configurations[key] === 'string' && (
  22. <div title={tool_configurations[key]} className='grow w-0 shrink-0 truncate text-right text-xs font-normal text-gray-700'>
  23. {tool_configurations[key]}
  24. </div>
  25. )}
  26. {typeof tool_configurations[key] !== 'string' && tool_configurations[key]?.type === FormTypeEnum.modelSelector && (
  27. <div title={tool_configurations[key].model} className='grow w-0 shrink-0 truncate text-right text-xs font-normal text-gray-700'>
  28. {tool_configurations[key].model}
  29. </div>
  30. )}
  31. {/* {typeof tool_configurations[key] !== 'string' && tool_configurations[key]?.type === FormTypeEnum.appSelector && (
  32. <div title={tool_configurations[key].app_id} className='grow w-0 shrink-0 truncate text-right text-xs font-normal text-gray-700'>
  33. {tool_configurations[key].app_id}
  34. </div>
  35. )} */}
  36. </div>
  37. ))}
  38. </div>
  39. </div>
  40. )
  41. }
  42. export default React.memo(Node)