您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import VarReferencePicker from '../_base/components/variable/var-reference-picker'
  5. import ConfigVision from '../_base/components/config-vision'
  6. import useConfig from './use-config'
  7. import ClassList from './components/class-list'
  8. import AdvancedSetting from './components/advanced-setting'
  9. import type { QuestionClassifierNodeType } from './types'
  10. import Field from '@/app/components/workflow/nodes/_base/components/field'
  11. import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
  12. import type { NodePanelProps } from '@/app/components/workflow/types'
  13. import Split from '@/app/components/workflow/nodes/_base/components/split'
  14. import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
  15. import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/collapse'
  16. const i18nPrefix = 'workflow.nodes.questionClassifiers'
  17. const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
  18. id,
  19. data,
  20. }) => {
  21. const { t } = useTranslation()
  22. const {
  23. readOnly,
  24. inputs,
  25. handleModelChanged,
  26. isChatMode,
  27. isChatModel,
  28. handleCompletionParamsChange,
  29. handleQueryVarChange,
  30. handleTopicsChange,
  31. hasSetBlockStatus,
  32. availableVars,
  33. availableNodesWithParent,
  34. handleInstructionChange,
  35. handleMemoryChange,
  36. isVisionModel,
  37. handleVisionResolutionChange,
  38. handleVisionResolutionEnabledChange,
  39. filterVar,
  40. } = useConfig(id, data)
  41. const model = inputs.model
  42. return (
  43. <div className='pt-2'>
  44. <div className='space-y-4 px-4'>
  45. <Field
  46. title={t(`${i18nPrefix}.model`)}
  47. required
  48. >
  49. <ModelParameterModal
  50. popupClassName='!w-[387px]'
  51. isInWorkflow
  52. isAdvancedMode={true}
  53. mode={model?.mode}
  54. provider={model?.provider}
  55. completionParams={model.completion_params}
  56. modelId={model.name}
  57. setModel={handleModelChanged}
  58. onCompletionParamsChange={handleCompletionParamsChange}
  59. hideDebugWithMultipleModel
  60. debugWithMultipleModel={false}
  61. readonly={readOnly}
  62. />
  63. </Field>
  64. <Field
  65. title={t(`${i18nPrefix}.inputVars`)}
  66. required
  67. >
  68. <VarReferencePicker
  69. readonly={readOnly}
  70. isShowNodeName
  71. nodeId={id}
  72. value={inputs.query_variable_selector}
  73. onChange={handleQueryVarChange}
  74. filterVar={filterVar}
  75. />
  76. </Field>
  77. <Split />
  78. <ConfigVision
  79. nodeId={id}
  80. readOnly={readOnly}
  81. isVisionModel={isVisionModel}
  82. enabled={inputs.vision?.enabled}
  83. onEnabledChange={handleVisionResolutionEnabledChange}
  84. config={inputs.vision?.configs}
  85. onConfigChange={handleVisionResolutionChange}
  86. />
  87. <Field
  88. title={t(`${i18nPrefix}.class`)}
  89. required
  90. >
  91. <ClassList
  92. nodeId={id}
  93. list={inputs.classes}
  94. onChange={handleTopicsChange}
  95. readonly={readOnly}
  96. filterVar={filterVar}
  97. />
  98. </Field>
  99. <Split />
  100. </div>
  101. <FieldCollapse
  102. title={t(`${i18nPrefix}.advancedSetting`)}
  103. >
  104. <AdvancedSetting
  105. hideMemorySetting={!isChatMode}
  106. instruction={inputs.instruction}
  107. onInstructionChange={handleInstructionChange}
  108. memory={inputs.memory}
  109. onMemoryChange={handleMemoryChange}
  110. readonly={readOnly}
  111. isChatApp={isChatMode}
  112. isChatModel={isChatModel}
  113. hasSetBlockStatus={hasSetBlockStatus}
  114. nodesOutputVars={availableVars}
  115. availableNodes={availableNodesWithParent}
  116. />
  117. </FieldCollapse>
  118. <Split />
  119. <div>
  120. <OutputVars>
  121. <>
  122. <VarItem
  123. name='class_name'
  124. type='string'
  125. description={t(`${i18nPrefix}.outputVars.className`)}
  126. />
  127. </>
  128. </OutputVars>
  129. </div>
  130. </div>
  131. )
  132. }
  133. export default React.memo(Panel)