diff --git a/web/app/components/workflow/nodes/question-classifier/panel.tsx b/web/app/components/workflow/nodes/question-classifier/panel.tsx index 62db8a7c84..07a220d379 100644 --- a/web/app/components/workflow/nodes/question-classifier/panel.tsx +++ b/web/app/components/workflow/nodes/question-classifier/panel.tsx @@ -8,7 +8,8 @@ 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' -import type { NodePanelProps } from '@/app/components/workflow/types' +import { InputVarType, type NodePanelProps } from '@/app/components/workflow/types' +import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form' const i18nPrefix = 'workflow.nodes.questionClassifiers' @@ -27,56 +28,86 @@ const Panel: FC> = ({ handleTopicsChange, handleInstructionChange, handleMemoryChange, + isShowSingleRun, + hideSingleRun, + runningStatus, + handleRun, + handleStop, + query, + setQuery, } = useConfig(id, data) const model = inputs.model return ( -
- - +
+ + + + + + + + + + + + +
+ {isShowSingleRun && ( + setQuery((keyValue as any).query), + }, + ]} + runningStatus={runningStatus} + onRun={handleRun} + onStop={handleStop} /> -
- - - - - - - - - + )}
) } diff --git a/web/app/components/workflow/nodes/question-classifier/use-config.ts b/web/app/components/workflow/nodes/question-classifier/use-config.ts index 62086f250a..0fb5d223ba 100644 --- a/web/app/components/workflow/nodes/question-classifier/use-config.ts +++ b/web/app/components/workflow/nodes/question-classifier/use-config.ts @@ -3,6 +3,7 @@ import produce from 'immer' import type { Memory, ValueSelector } from '../../types' import type { QuestionClassifierNodeType } from './types' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' +import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run' const useConfig = (id: string, payload: QuestionClassifierNodeType) => { const { inputs, setInputs } = useNodeCrud(id, payload) @@ -52,6 +53,31 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => { setInputs(newInputs) }, [inputs, setInputs]) + // single run + const { + isShowSingleRun, + hideSingleRun, + runningStatus, + handleRun, + handleStop, + runInputData, + setRunInputData, + } = useOneStepRun({ + id, + data: inputs, + defaultRunInputData: { + query: 'Negative or positive sentiment?', + }, + }) + + const query = runInputData.query + const setQuery = useCallback((newQuery: string) => { + setRunInputData({ + ...runInputData, + query: newQuery, + }) + }, [runInputData, setRunInputData]) + return { inputs, handleModelChanged, @@ -60,6 +86,13 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => { handleTopicsChange: handleClassesChange, handleInstructionChange, handleMemoryChange, + isShowSingleRun, + hideSingleRun, + runningStatus, + handleRun, + handleStop, + query, + setQuery, } }