advanced-setting.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import TextEditor from '../../_base/components/editor/text-editor'
  6. import MemoryConfig from '../../_base/components/memory-config'
  7. import type { Memory } from '@/app/components/workflow/types'
  8. const i18nPrefix = 'workflow.nodes.questionClassifiers'
  9. type Props = {
  10. instruction: string
  11. onInstructionChange: (instruction: string) => void
  12. hideMemorySetting: boolean
  13. memory?: Memory
  14. onMemoryChange: (memory?: Memory) => void
  15. readonly?: boolean
  16. }
  17. const AdvancedSetting: FC<Props> = ({
  18. instruction,
  19. onInstructionChange,
  20. hideMemorySetting,
  21. memory,
  22. onMemoryChange,
  23. readonly,
  24. }) => {
  25. const { t } = useTranslation()
  26. return (
  27. <>
  28. <TextEditor
  29. isInNode
  30. title={t(`${i18nPrefix}.instruction`)!}
  31. value={instruction}
  32. onChange={onInstructionChange}
  33. minHeight={160}
  34. placeholder={t(`${i18nPrefix}.instructionPlaceholder`)!}
  35. headerRight={(
  36. <div className='flex items-center h-full'>
  37. <div className='text-xs font-medium text-gray-500'>{instruction?.length || 0}</div>
  38. <div className='mx-3 h-3 w-px bg-gray-200'></div>
  39. </div>
  40. )}
  41. readonly={readonly}
  42. />
  43. {!hideMemorySetting && (
  44. <MemoryConfig
  45. className='mt-4'
  46. readonly={false}
  47. config={{ data: memory }}
  48. onChange={onMemoryChange}
  49. canSetRoleName={false}
  50. />
  51. )}
  52. </>
  53. )
  54. }
  55. export default React.memo(AdvancedSetting)