advanced-setting.tsx 2.1 KB

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