update the onNodeFinished method for nodes being passed through more than once

This commit is contained in:
Yi 2024-08-30 17:00:02 +08:00
parent 708256ef1d
commit e3ae529a55
3 changed files with 13 additions and 2 deletions

View File

@ -329,7 +329,12 @@ export const useWorkflowRun = () => {
else {
const nodes = getNodes()
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
const currentIndex = draft.tracing!.findIndex(trace => trace.node_id === data.node_id)
const currentIndex = draft.tracing!.findIndex((trace) => {
if (!trace.execution_metadata?.parallel_id)
return trace.node_id === data.node_id
return trace.node_id === data.node_id && trace.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id
})
if (currentIndex > -1 && draft.tracing) {
draft.tracing[currentIndex] = {

View File

@ -382,7 +382,12 @@ export const useChat = (
}))
}
else {
const currentIndex = responseItem.workflowProcess!.tracing!.findIndex(item => item.node_id === data.node_id)
const currentIndex = responseItem.workflowProcess!.tracing!.findIndex((item) => {
if (!item.execution_metadata?.parallel_id)
return item.node_id === data.node_id
return item.node_id === data.node_id && item.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id
})
responseItem.workflowProcess!.tracing[currentIndex] = {
...(responseItem.workflowProcess!.tracing[currentIndex].extras
? { extras: responseItem.workflowProcess!.tracing[currentIndex].extras }

View File

@ -144,6 +144,7 @@ export type NodeFinishedResponse = {
total_tokens: number
total_price: number
currency: string
parallel_id?: string
}
created_at: number
}