mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 12:25:52 +08:00
fix: refine the "isInIteration" for workflow
This commit is contained in:
parent
44038b9628
commit
46634638e7
@ -141,7 +141,6 @@ export const useWorkflowRun = () => {
|
|||||||
tracing: [],
|
tracing: [],
|
||||||
resultText: '',
|
resultText: '',
|
||||||
})
|
})
|
||||||
let iterationLength = 0
|
|
||||||
|
|
||||||
let ttsUrl = ''
|
let ttsUrl = ''
|
||||||
let ttsIsPublic = false
|
let ttsIsPublic = false
|
||||||
@ -250,13 +249,13 @@ export const useWorkflowRun = () => {
|
|||||||
transform,
|
transform,
|
||||||
} = store.getState()
|
} = store.getState()
|
||||||
const nodes = getNodes()
|
const nodes = getNodes()
|
||||||
const nodeParentId = nodes.find(node => node.id === data.node_id)!.parentId
|
const node = nodes.find(node => node.id === data.node_id)
|
||||||
if (nodeParentId) {
|
if (node?.parentId) {
|
||||||
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
||||||
const tracing = draft.tracing!
|
const tracing = draft.tracing!
|
||||||
const iterations = tracing[tracing.length - 1]
|
const iterations = tracing.find(trace => trace.node_id === node?.parentId)
|
||||||
const currIteration = iterations.details![iterations.details!.length - 1]
|
const currIteration = iterations?.details![node.data.iteration_index] || iterations?.details![iterations.details!.length - 1]
|
||||||
currIteration.push({
|
currIteration?.push({
|
||||||
...data,
|
...data,
|
||||||
status: NodeRunningStatus.Running,
|
status: NodeRunningStatus.Running,
|
||||||
} as any)
|
} as any)
|
||||||
@ -316,7 +315,7 @@ export const useWorkflowRun = () => {
|
|||||||
if (nodeParentId) {
|
if (nodeParentId) {
|
||||||
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
||||||
const tracing = draft.tracing!
|
const tracing = draft.tracing!
|
||||||
const iterations = tracing[tracing.length - 1] // the iteration node
|
const iterations = tracing.find(trace => trace.node_id === nodeParentId) // the iteration node
|
||||||
|
|
||||||
if (iterations && iterations.details) {
|
if (iterations && iterations.details) {
|
||||||
const iterationIndex = data.execution_metadata?.iteration_index || 0
|
const iterationIndex = data.execution_metadata?.iteration_index || 0
|
||||||
@ -325,7 +324,7 @@ export const useWorkflowRun = () => {
|
|||||||
|
|
||||||
const currIteration = iterations.details[iterationIndex]
|
const currIteration = iterations.details[iterationIndex]
|
||||||
const nodeIndex = currIteration.findIndex(node =>
|
const nodeIndex = currIteration.findIndex(node =>
|
||||||
node.node_id === data.node_id,
|
node.node_id === data.node_id && node.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id,
|
||||||
)
|
)
|
||||||
if (data.status === NodeRunningStatus.Succeeded) {
|
if (data.status === NodeRunningStatus.Succeeded) {
|
||||||
if (nodeIndex !== -1) {
|
if (nodeIndex !== -1) {
|
||||||
@ -391,7 +390,6 @@ export const useWorkflowRun = () => {
|
|||||||
details: [],
|
details: [],
|
||||||
} as any)
|
} as any)
|
||||||
}))
|
}))
|
||||||
iterationLength = data.metadata.iterator_length
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
setViewport,
|
setViewport,
|
||||||
@ -437,13 +435,13 @@ export const useWorkflowRun = () => {
|
|||||||
} = store.getState()
|
} = store.getState()
|
||||||
|
|
||||||
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
||||||
const iteration = draft.tracing![draft.tracing!.length - 1]
|
const iteration = draft.tracing!.find(trace => trace.node_id === data.node_id)
|
||||||
if (iteration.details!.length >= iterationLength)
|
if (iteration) {
|
||||||
return
|
if (iteration.details!.length >= iteration.metadata.iterator_length!)
|
||||||
|
return
|
||||||
iteration.details!.push([])
|
}
|
||||||
|
iteration?.details!.push([])
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const nodes = getNodes()
|
const nodes = getNodes()
|
||||||
const newNodes = produce(nodes, (draft) => {
|
const newNodes = produce(nodes, (draft) => {
|
||||||
const currentNode = draft.find(node => node.id === data.node_id)!
|
const currentNode = draft.find(node => node.id === data.node_id)!
|
||||||
@ -469,11 +467,13 @@ export const useWorkflowRun = () => {
|
|||||||
const nodes = getNodes()
|
const nodes = getNodes()
|
||||||
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
|
||||||
const tracing = draft.tracing!
|
const tracing = draft.tracing!
|
||||||
tracing[tracing.length - 1] = {
|
const currIterationNode = tracing.find(trace => trace.node_id === data.node_id)
|
||||||
...tracing[tracing.length - 1],
|
if (currIterationNode) {
|
||||||
...data,
|
Object.assign(currIterationNode, {
|
||||||
status: NodeRunningStatus.Succeeded,
|
...data,
|
||||||
} as any
|
status: NodeRunningStatus.Succeeded,
|
||||||
|
})
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const newNodes = produce(nodes, (draft) => {
|
const newNodes = produce(nodes, (draft) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user