2024-04-08 18:51:46 +08:00
|
|
|
import type { FC } from 'react'
|
|
|
|
import React from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import VarReferencePicker from '../_base/components/variable/var-reference-picker'
|
2024-10-21 10:32:37 +08:00
|
|
|
import ConfigVision from '../_base/components/config-vision'
|
2024-04-08 18:51:46 +08:00
|
|
|
import useConfig from './use-config'
|
|
|
|
import ClassList from './components/class-list'
|
|
|
|
import AdvancedSetting from './components/advanced-setting'
|
|
|
|
import type { QuestionClassifierNodeType } from './types'
|
|
|
|
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
|
|
|
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
|
2025-06-24 09:10:30 +08:00
|
|
|
import type { NodePanelProps } from '@/app/components/workflow/types'
|
2024-04-30 17:07:29 +08:00
|
|
|
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
|
|
|
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
2024-12-11 14:21:38 +08:00
|
|
|
import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/collapse'
|
2024-04-08 18:51:46 +08:00
|
|
|
|
|
|
|
const i18nPrefix = 'workflow.nodes.questionClassifiers'
|
|
|
|
|
|
|
|
const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
|
|
|
|
id,
|
|
|
|
data,
|
|
|
|
}) => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const {
|
|
|
|
readOnly,
|
|
|
|
inputs,
|
|
|
|
handleModelChanged,
|
|
|
|
isChatMode,
|
2024-06-04 14:01:40 +08:00
|
|
|
isChatModel,
|
2024-04-08 18:51:46 +08:00
|
|
|
handleCompletionParamsChange,
|
|
|
|
handleQueryVarChange,
|
|
|
|
handleTopicsChange,
|
2024-06-04 14:01:40 +08:00
|
|
|
hasSetBlockStatus,
|
|
|
|
availableVars,
|
|
|
|
availableNodesWithParent,
|
2024-04-08 18:51:46 +08:00
|
|
|
handleInstructionChange,
|
|
|
|
handleMemoryChange,
|
2024-10-21 10:32:37 +08:00
|
|
|
isVisionModel,
|
|
|
|
handleVisionResolutionChange,
|
|
|
|
handleVisionResolutionEnabledChange,
|
2024-04-08 18:51:46 +08:00
|
|
|
filterVar,
|
|
|
|
} = useConfig(id, data)
|
|
|
|
|
|
|
|
const model = inputs.model
|
|
|
|
|
|
|
|
return (
|
2024-12-11 14:21:38 +08:00
|
|
|
<div className='pt-2'>
|
2025-03-21 17:41:03 +08:00
|
|
|
<div className='space-y-4 px-4'>
|
2024-04-08 18:51:46 +08:00
|
|
|
<Field
|
|
|
|
title={t(`${i18nPrefix}.model`)}
|
2025-04-27 16:12:02 +08:00
|
|
|
required
|
2024-04-08 18:51:46 +08:00
|
|
|
>
|
|
|
|
<ModelParameterModal
|
|
|
|
popupClassName='!w-[387px]'
|
|
|
|
isInWorkflow
|
|
|
|
isAdvancedMode={true}
|
|
|
|
mode={model?.mode}
|
|
|
|
provider={model?.provider}
|
|
|
|
completionParams={model.completion_params}
|
|
|
|
modelId={model.name}
|
|
|
|
setModel={handleModelChanged}
|
|
|
|
onCompletionParamsChange={handleCompletionParamsChange}
|
|
|
|
hideDebugWithMultipleModel
|
|
|
|
debugWithMultipleModel={false}
|
|
|
|
readonly={readOnly}
|
|
|
|
/>
|
|
|
|
</Field>
|
2024-10-21 10:32:37 +08:00
|
|
|
<Field
|
|
|
|
title={t(`${i18nPrefix}.inputVars`)}
|
2025-04-27 16:12:02 +08:00
|
|
|
required
|
2024-10-21 10:32:37 +08:00
|
|
|
>
|
|
|
|
<VarReferencePicker
|
|
|
|
readonly={readOnly}
|
|
|
|
isShowNodeName
|
|
|
|
nodeId={id}
|
|
|
|
value={inputs.query_variable_selector}
|
|
|
|
onChange={handleQueryVarChange}
|
|
|
|
filterVar={filterVar}
|
|
|
|
/>
|
|
|
|
</Field>
|
|
|
|
<Split />
|
|
|
|
<ConfigVision
|
|
|
|
nodeId={id}
|
|
|
|
readOnly={readOnly}
|
|
|
|
isVisionModel={isVisionModel}
|
|
|
|
enabled={inputs.vision?.enabled}
|
|
|
|
onEnabledChange={handleVisionResolutionEnabledChange}
|
|
|
|
config={inputs.vision?.configs}
|
|
|
|
onConfigChange={handleVisionResolutionChange}
|
|
|
|
/>
|
2024-04-08 18:51:46 +08:00
|
|
|
<Field
|
|
|
|
title={t(`${i18nPrefix}.class`)}
|
2025-04-27 16:12:02 +08:00
|
|
|
required
|
2024-04-08 18:51:46 +08:00
|
|
|
>
|
|
|
|
<ClassList
|
2025-04-01 05:19:36 +02:00
|
|
|
nodeId={id}
|
2024-04-08 18:51:46 +08:00
|
|
|
list={inputs.classes}
|
|
|
|
onChange={handleTopicsChange}
|
|
|
|
readonly={readOnly}
|
2025-04-01 05:19:36 +02:00
|
|
|
filterVar={filterVar}
|
2024-04-08 18:51:46 +08:00
|
|
|
/>
|
|
|
|
</Field>
|
2024-12-11 14:21:38 +08:00
|
|
|
<Split />
|
2024-04-08 18:51:46 +08:00
|
|
|
</div>
|
2024-12-11 14:21:38 +08:00
|
|
|
<FieldCollapse
|
|
|
|
title={t(`${i18nPrefix}.advancedSetting`)}
|
|
|
|
>
|
|
|
|
<AdvancedSetting
|
|
|
|
hideMemorySetting={!isChatMode}
|
|
|
|
instruction={inputs.instruction}
|
|
|
|
onInstructionChange={handleInstructionChange}
|
|
|
|
memory={inputs.memory}
|
|
|
|
onMemoryChange={handleMemoryChange}
|
|
|
|
readonly={readOnly}
|
|
|
|
isChatApp={isChatMode}
|
|
|
|
isChatModel={isChatModel}
|
|
|
|
hasSetBlockStatus={hasSetBlockStatus}
|
|
|
|
nodesOutputVars={availableVars}
|
|
|
|
availableNodes={availableNodesWithParent}
|
|
|
|
/>
|
|
|
|
</FieldCollapse>
|
2024-04-30 17:07:29 +08:00
|
|
|
<Split />
|
2024-12-11 14:21:38 +08:00
|
|
|
<div>
|
2024-04-30 17:07:29 +08:00
|
|
|
<OutputVars>
|
|
|
|
<>
|
|
|
|
<VarItem
|
|
|
|
name='class_name'
|
|
|
|
type='string'
|
|
|
|
description={t(`${i18nPrefix}.outputVars.className`)}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
</OutputVars>
|
|
|
|
</div>
|
2024-04-08 18:51:46 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default React.memo(Panel)
|