advanced-setting.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. import TooltipPlus from '@/app/components/base/tooltip-plus'
  9. import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
  10. const i18nPrefix = 'workflow.nodes.questionClassifiers'
  11. type Props = {
  12. instruction: string
  13. onInstructionChange: (instruction: string) => void
  14. hideMemorySetting: boolean
  15. memory?: Memory
  16. onMemoryChange: (memory?: Memory) => void
  17. readonly?: boolean
  18. }
  19. const AdvancedSetting: FC<Props> = ({
  20. instruction,
  21. onInstructionChange,
  22. hideMemorySetting,
  23. memory,
  24. onMemoryChange,
  25. readonly,
  26. }) => {
  27. const { t } = useTranslation()
  28. return (
  29. <>
  30. <TextEditor
  31. isInNode
  32. title={
  33. <div className='flex items-center space-x-1'>
  34. <span className='uppercase'>{t(`${i18nPrefix}.instruction`)}</span>
  35. <TooltipPlus popupContent={
  36. <div className='w-[120px]'>
  37. {t(`${i18nPrefix}.instructionTip`)}
  38. </div>}>
  39. <HelpCircle className='w-3.5 h-3.5 ml-0.5 text-gray-400' />
  40. </TooltipPlus>
  41. </div>
  42. }
  43. value={instruction}
  44. onChange={onInstructionChange}
  45. minHeight={160}
  46. placeholder={t(`${i18nPrefix}.instructionPlaceholder`)!}
  47. headerRight={(
  48. <div className='flex items-center h-full'>
  49. <div className='text-xs font-medium text-gray-500'>{instruction?.length || 0}</div>
  50. <div className='mx-3 h-3 w-px bg-gray-200'></div>
  51. </div>
  52. )}
  53. readonly={readonly}
  54. />
  55. {!hideMemorySetting && (
  56. <MemoryConfig
  57. className='mt-4'
  58. readonly={false}
  59. config={{ data: memory }}
  60. onChange={onMemoryChange}
  61. canSetRoleName={false}
  62. />
  63. )}
  64. </>
  65. )
  66. }
  67. export default React.memo(AdvancedSetting)