advanced-setting.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import MemoryConfig from '../../_base/components/memory-config'
  6. import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
  7. import type { Memory, Node, NodeOutPutVar } 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. isChatModel: boolean
  19. isChatApp: boolean
  20. hasSetBlockStatus?: {
  21. context: boolean
  22. history: boolean
  23. query: boolean
  24. }
  25. nodesOutputVars: NodeOutPutVar[]
  26. availableNodes: Node[]
  27. }
  28. const AdvancedSetting: FC<Props> = ({
  29. instruction,
  30. onInstructionChange,
  31. hideMemorySetting,
  32. memory,
  33. onMemoryChange,
  34. readonly,
  35. isChatModel,
  36. isChatApp,
  37. hasSetBlockStatus,
  38. nodesOutputVars,
  39. availableNodes,
  40. }) => {
  41. const { t } = useTranslation()
  42. return (
  43. <>
  44. <Editor
  45. title={
  46. <div className='flex items-center space-x-1'>
  47. <span className='uppercase'>{t(`${i18nPrefix}.instruction`)}</span>
  48. <TooltipPlus popupContent={
  49. <div className='w-[120px]'>
  50. {t(`${i18nPrefix}.instructionTip`)}
  51. </div>}>
  52. <HelpCircle className='w-3.5 h-3.5 ml-0.5 text-gray-400' />
  53. </TooltipPlus>
  54. </div>
  55. }
  56. value={instruction}
  57. onChange={onInstructionChange}
  58. readOnly={readonly}
  59. isChatModel={isChatModel}
  60. isChatApp={isChatApp}
  61. isShowContext={false}
  62. hasSetBlockStatus={hasSetBlockStatus}
  63. nodesOutputVars={nodesOutputVars}
  64. availableNodes={availableNodes}
  65. />
  66. {!hideMemorySetting && (
  67. <MemoryConfig
  68. className='mt-4'
  69. readonly={false}
  70. config={{ data: memory }}
  71. onChange={onMemoryChange}
  72. canSetRoleName={false}
  73. />
  74. )}
  75. </>
  76. )
  77. }
  78. export default React.memo(AdvancedSetting)