advanced-setting.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. title={t(`${i18nPrefix}.instruction`)!}
  30. value={instruction}
  31. onChange={onInstructionChange}
  32. minHeight={160}
  33. placeholder={t(`${i18nPrefix}.instructionPlaceholder`)!}
  34. headerRight={(
  35. <div className='flex items-center h-full'>
  36. <div className='text-xs font-medium text-gray-500'>{instruction?.length || 0}</div>
  37. <div className='mx-3 h-3 w-px bg-gray-200'></div>
  38. </div>
  39. )}
  40. readonly={readonly}
  41. />
  42. {!hideMemorySetting && (
  43. <MemoryConfig
  44. className='mt-4'
  45. readonly={false}
  46. config={{ data: memory }}
  47. onChange={onMemoryChange}
  48. canSetRoleName={false}
  49. />
  50. )}
  51. </>
  52. )
  53. }
  54. export default React.memo(AdvancedSetting)