@@ -41,7 +42,7 @@ const Panel: FC = () => {
)
}
{
- runTaskId && (
+ runningStatus && !isChatMode && workflowRunId && (
)
}
diff --git a/web/app/components/workflow/panel/inputs-panel.tsx b/web/app/components/workflow/panel/inputs-panel.tsx
index 597665c991..06c528d9c7 100644
--- a/web/app/components/workflow/panel/inputs-panel.tsx
+++ b/web/app/components/workflow/panel/inputs-panel.tsx
@@ -1,7 +1,6 @@
import {
memo,
useCallback,
- useState,
} from 'react'
import { useTranslation } from 'react-i18next'
import { useNodes } from 'reactflow'
@@ -15,13 +14,13 @@ import Button from '@/app/components/base/button'
const InputsPanel = () => {
const { t } = useTranslation()
const nodes = useNodes
()
+ const inputs = useStore(s => s.inputs)
const run = useWorkflowRun()
- const [inputs, setInputs] = useState>({})
const startNode = nodes.find(node => node.data.type === BlockEnum.Start)
const variables = startNode?.data.variables || []
const handleValueChange = (variable: string, v: string) => {
- setInputs({
+ useStore.getState().setInputs({
...inputs,
[variable]: v,
})
@@ -32,7 +31,8 @@ const InputsPanel = () => {
}, [])
const handleRun = () => {
- run(inputs)
+ handleCancel()
+ run({ inputs })
}
return (
diff --git a/web/app/components/workflow/panel/record.tsx b/web/app/components/workflow/panel/record.tsx
index 467dc707bf..2891dd5890 100644
--- a/web/app/components/workflow/panel/record.tsx
+++ b/web/app/components/workflow/panel/record.tsx
@@ -4,19 +4,19 @@ import { useStore } from '../store'
import { XClose } from '@/app/components/base/icons/src/vender/line/general'
const Record = () => {
- const { runTaskId, setRunTaskId } = useStore()
+ const { workflowRunId, setWorkflowRunId } = useStore()
return (
Test Run#5
setRunTaskId('')}
+ onClick={() => setWorkflowRunId('')}
>
-
+
)
}
diff --git a/web/app/components/workflow/store.ts b/web/app/components/workflow/store.ts
index 25c78e745a..3214466656 100644
--- a/web/app/components/workflow/store.ts
+++ b/web/app/components/workflow/store.ts
@@ -13,7 +13,8 @@ import type { WorkflowRunningStatus } from './types'
type State = {
mode: Mode
- runTaskId: string
+ taskId: string
+ workflowRunId: string
showRunHistory: boolean
showFeaturesPanel: boolean
isDragging: boolean
@@ -25,11 +26,13 @@ type State = {
publishedAt: number
runningStatus?: WorkflowRunningStatus
showInputsPanel: boolean
+ inputs: Record
}
type Action = {
setMode: (mode: Mode) => void
- setRunTaskId: (runTaskId: string) => void
+ setTaskId: (taskId: string) => void
+ setWorkflowRunId: (workflowRunId: string) => void
setShowRunHistory: (showRunHistory: boolean) => void
setShowFeaturesPanel: (showFeaturesPanel: boolean) => void
setIsDragging: (isDragging: boolean) => void
@@ -41,12 +44,15 @@ type Action = {
setPublishedAt: (publishedAt: number) => void
setRunningStatus: (runningStatus?: WorkflowRunningStatus) => void
setShowInputsPanel: (showInputsPanel: boolean) => void
+ setInputs: (inputs: Record) => void
}
export const useStore = create(set => ({
mode: Mode.Editing,
- runTaskId: '',
- setRunTaskId: runTaskId => set(() => ({ runTaskId })),
+ taskId: '',
+ setTaskId: taskId => set(() => ({ taskId })),
+ workflowRunId: '',
+ setWorkflowRunId: workflowRunId => set(() => ({ workflowRunId })),
setMode: mode => set(() => ({ mode })),
showRunHistory: false,
setShowRunHistory: showRunHistory => set(() => ({ showRunHistory })),
@@ -70,4 +76,6 @@ export const useStore = create(set => ({
setRunningStatus: runningStatus => set(() => ({ runningStatus })),
showInputsPanel: false,
setShowInputsPanel: showInputsPanel => set(() => ({ showInputsPanel })),
+ inputs: {},
+ setInputs: inputs => set(() => ({ inputs })),
}))
diff --git a/web/app/components/workflow/utils.ts b/web/app/components/workflow/utils.ts
index 31ab59fd5f..551cb7c84e 100644
--- a/web/app/components/workflow/utils.ts
+++ b/web/app/components/workflow/utils.ts
@@ -9,6 +9,7 @@ import type {
Node,
} from './types'
import { BlockEnum } from './types'
+import type { QuestionClassifierNodeType } from './nodes/question-classifier/types'
export const nodesLevelOrderTraverse = (
firstNode: Node,
@@ -80,19 +81,43 @@ export const nodesLevelOrderTraverse = (
}
}
-export const initialNodesAndEdges = (nodes: Node[], edges: Edge[]) => {
+export const initialNodes = (nodes: Node[]) => {
const newNodes = produce(nodes, (draft) => {
draft.forEach((node) => {
node.type = 'custom'
+
+ if (node.data.type === BlockEnum.IfElse) {
+ node.data._targetBranches = [
+ {
+ id: 'true',
+ name: 'IS TRUE',
+ },
+ {
+ id: 'false',
+ name: 'IS FALSE',
+ },
+ ]
+ }
+
+ if (node.data.type === BlockEnum.QuestionClassifier) {
+ node.data._targetBranches = (node.data as QuestionClassifierNodeType).classes.map((topic) => {
+ return topic
+ })
+ }
})
})
+
+ return newNodes
+}
+
+export const initialEdges = (edges: Edge[]) => {
const newEdges = produce(edges, (draft) => {
draft.forEach((edge) => {
edge.type = 'custom'
})
})
- return [newNodes, newEdges]
+ return newEdges
}
export type PositionMap = {
diff --git a/web/service/base.ts b/web/service/base.ts
index 8e5c343f4b..b4703b3604 100644
--- a/web/service/base.ts
+++ b/web/service/base.ts
@@ -421,7 +421,27 @@ export const upload = (options: any, isPublicAPI?: boolean, url?: string, search
})
}
-export const ssePost = (url: string, fetchOptions: FetchOptionType, { isPublicAPI = false, onData, onCompleted, onThought, onFile, onMessageEnd, onMessageReplace, onError, getAbortController }: IOtherOptions) => {
+export const ssePost = (
+ url: string,
+ fetchOptions: FetchOptionType,
+ {
+ isPublicAPI = false,
+ onData,
+ onCompleted,
+ onThought,
+ onFile,
+ onMessageEnd,
+ onMessageReplace,
+ onWorkflowStarted,
+ onWorkflowFinished,
+ onNodeStarted,
+ onNodeFinished,
+ onTextChunk,
+ onTextReplace,
+ onError,
+ getAbortController,
+ }: IOtherOptions,
+) => {
const abortController = new AbortController()
const options = Object.assign({}, baseOptions, {
@@ -459,7 +479,7 @@ export const ssePost = (url: string, fetchOptions: FetchOptionType, { isPublicAP
return
}
onData?.(str, isFirstMessage, moreInfo)
- }, onCompleted, onThought, onMessageEnd, onMessageReplace, onFile)
+ }, onCompleted, onThought, onMessageEnd, onMessageReplace, onFile, onWorkflowStarted, onWorkflowFinished, onNodeStarted, onNodeFinished, onTextChunk, onTextReplace)
}).catch((e) => {
if (e.toString() !== 'AbortError: The user aborted a request.')
Toast.notify({ type: 'error', message: e })