mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
fix:variable not update in nested workflow runs (#2830)
This commit is contained in:
@@ -184,6 +184,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
||||
|
||||
// flat child tool response
|
||||
const childToolResponse = dispatchFlowResponse.map((item) => item.flowResponses).flat();
|
||||
const newVariables = dispatchFlowResponse[dispatchFlowResponse.length - 1]?.newVariables;
|
||||
|
||||
// concat tool usage
|
||||
const totalPointsUsage =
|
||||
@@ -219,6 +220,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
||||
tokens: totalTokens
|
||||
},
|
||||
...flatUsages
|
||||
]
|
||||
],
|
||||
[DispatchNodeResponseKeyEnum.newVariables]: newVariables
|
||||
};
|
||||
};
|
||||
|
@@ -555,6 +555,14 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
||||
dispatchRes[item.key] = valueTypeFormat(item.defaultValue, item.valueType);
|
||||
});
|
||||
|
||||
// Update new variables
|
||||
if (dispatchRes[DispatchNodeResponseKeyEnum.newVariables]) {
|
||||
variables = {
|
||||
...variables,
|
||||
...dispatchRes[DispatchNodeResponseKeyEnum.newVariables]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
node,
|
||||
runStatus: 'run',
|
||||
|
@@ -38,6 +38,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
|
||||
const loopDetail: ChatHistoryItemResType[] = [];
|
||||
let assistantResponses: AIChatItemValueItemType[] = [];
|
||||
let totalPoints = 0;
|
||||
let newVariables: Record<string, any> = {};
|
||||
|
||||
for await (const item of loopInputArray) {
|
||||
const response = await dispatchWorkFlow({
|
||||
@@ -72,6 +73,10 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
|
||||
assistantResponses.push(...response.assistantResponses);
|
||||
|
||||
totalPoints = response.flowUsages.reduce((acc, usage) => acc + usage.totalPoints, 0);
|
||||
newVariables = {
|
||||
...newVariables,
|
||||
...response.newVariables
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -88,6 +93,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
|
||||
moduleName: name
|
||||
}
|
||||
],
|
||||
[NodeOutputKeyEnum.loopArray]: outputValueArr
|
||||
[NodeOutputKeyEnum.loopArray]: outputValueArr,
|
||||
[DispatchNodeResponseKeyEnum.newVariables]: newVariables
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user