fix: checkout inputs before workflow run

This commit is contained in:
StyleZhang 2024-10-17 13:47:56 +08:00
parent 63ae66b827
commit 575ef4bb9d
2 changed files with 6 additions and 2 deletions

View File

@ -114,7 +114,7 @@ export const useWorkflowStartRun = () => {
setShowDebugAndPreviewPanel(true)
setShowInputsPanel(true)
}
}, [store, workflowStore, featuresStore, handleCancelDebugAndPreviewPanel, handleRun, doSyncWorkflowDraft])
}, [store, workflowStore, featuresStore, handleCancelDebugAndPreviewPanel, handleRun, doSyncWorkflowDraft, isFromStartNode, t, currentModel, rerankDefaultModel, checkKnowledgeRetrievalValid])
const handleWorkflowStartRunInChatflow = useCallback(async () => {
const {

View File

@ -23,6 +23,7 @@ import { useFeatures } from '@/app/components/base/features/hooks'
import {
getProcessedInputs,
} from '@/app/components/base/chat/chat/utils'
import { useCheckInputsForms } from '@/app/components/base/chat/chat/check-input-forms-hooks'
type Props = {
onRun: () => void
@ -41,6 +42,7 @@ const InputsPanel = ({ onRun }: Props) => {
} = useWorkflowRun()
const startNode = nodes.find(node => node.data.type === BlockEnum.Start)
const startVariables = startNode?.data.variables
const { checkInputsForm } = useCheckInputsForms()
const variables = useMemo(() => {
const data = startVariables || []
@ -78,9 +80,11 @@ const InputsPanel = ({ onRun }: Props) => {
}
const doRun = useCallback(() => {
if (!checkInputsForm(inputs, variables as any))
return
onRun()
handleRun({ inputs: getProcessedInputs(inputs, variables as any), files })
}, [files, handleRun, inputs, onRun, variables])
}, [files, handleRun, inputs, onRun, variables, checkInputsForm])
const canRun = useMemo(() => {
if (files?.some(item => (item.transfer_method as any) === TransferMethod.local_file && !item.upload_file_id))