advanced-setting.tsx 2.2 KB

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