Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

panel.tsx 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. handleSortTopic,
  41. } = useConfig(id, data)
  42. const model = inputs.model
  43. return (
  44. <div className='pt-2'>
  45. <div className='space-y-4 px-4'>
  46. <Field
  47. title={t(`${i18nPrefix}.model`)}
  48. required
  49. >
  50. <ModelParameterModal
  51. popupClassName='!w-[387px]'
  52. isInWorkflow
  53. isAdvancedMode={true}
  54. mode={model?.mode}
  55. provider={model?.provider}
  56. completionParams={model.completion_params}
  57. modelId={model.name}
  58. setModel={handleModelChanged}
  59. onCompletionParamsChange={handleCompletionParamsChange}
  60. hideDebugWithMultipleModel
  61. debugWithMultipleModel={false}
  62. readonly={readOnly}
  63. />
  64. </Field>
  65. <Field
  66. title={t(`${i18nPrefix}.inputVars`)}
  67. required
  68. >
  69. <VarReferencePicker
  70. readonly={readOnly}
  71. isShowNodeName
  72. nodeId={id}
  73. value={inputs.query_variable_selector}
  74. onChange={handleQueryVarChange}
  75. filterVar={filterVar}
  76. />
  77. </Field>
  78. <Split />
  79. <ConfigVision
  80. nodeId={id}
  81. readOnly={readOnly}
  82. isVisionModel={isVisionModel}
  83. enabled={inputs.vision?.enabled}
  84. onEnabledChange={handleVisionResolutionEnabledChange}
  85. config={inputs.vision?.configs}
  86. onConfigChange={handleVisionResolutionChange}
  87. />
  88. <Field
  89. title={t(`${i18nPrefix}.class`)}
  90. required
  91. >
  92. <ClassList
  93. nodeId={id}
  94. list={inputs.classes}
  95. onChange={handleTopicsChange}
  96. readonly={readOnly}
  97. filterVar={filterVar}
  98. handleSortTopic={handleSortTopic}
  99. />
  100. </Field>
  101. <Split />
  102. </div>
  103. <FieldCollapse
  104. title={t(`${i18nPrefix}.advancedSetting`)}
  105. >
  106. <AdvancedSetting
  107. hideMemorySetting={!isChatMode}
  108. instruction={inputs.instruction}
  109. onInstructionChange={handleInstructionChange}
  110. memory={inputs.memory}
  111. onMemoryChange={handleMemoryChange}
  112. readonly={readOnly}
  113. isChatApp={isChatMode}
  114. isChatModel={isChatModel}
  115. hasSetBlockStatus={hasSetBlockStatus}
  116. nodesOutputVars={availableVars}
  117. availableNodes={availableNodesWithParent}
  118. />
  119. </FieldCollapse>
  120. <Split />
  121. <div>
  122. <OutputVars>
  123. <>
  124. <VarItem
  125. name='class_name'
  126. type='string'
  127. description={t(`${i18nPrefix}.outputVars.className`)}
  128. />
  129. <VarItem
  130. name='usage'
  131. type='object'
  132. description={t(`${i18nPrefix}.outputVars.usage`)}
  133. />
  134. </>
  135. </OutputVars>
  136. </div>
  137. </div>
  138. )
  139. }
  140. export default React.memo(Panel)