4.8.1 test-fix (#1561)

This commit is contained in:
Archer
2024-05-22 18:49:39 +08:00
committed by GitHub
parent 87e4afe89b
commit b1aafde7c9
65 changed files with 1245 additions and 293 deletions

View File

@@ -35,8 +35,7 @@ type Props = ModuleDispatchProps<{
[NodeInputKeyEnum.aiModel]: string;
}>;
type Response = DispatchNodeResultType<{
[NodeOutputKeyEnum.success]?: boolean;
[NodeOutputKeyEnum.failed]?: boolean;
[NodeOutputKeyEnum.success]: boolean;
[NodeOutputKeyEnum.contextExtractFields]: string;
}>;
@@ -119,9 +118,7 @@ export async function dispatchContentExtract(props: Props): Promise<Response> {
});
return {
// [DispatchNodeResponseKeyEnum.skipHandleId]: success
// ? [getHandleId(nodeId, 'source', NodeOutputKeyEnum.failed)]
// : [getHandleId(nodeId, 'source', NodeOutputKeyEnum.success)],
[NodeOutputKeyEnum.success]: success,
[NodeOutputKeyEnum.contextExtractFields]: JSON.stringify(arg),
...arg,
[DispatchNodeResponseKeyEnum.nodeResponse]: {

View File

@@ -1,5 +1,5 @@
import { NextApiResponse } from 'next';
import { NodeInputKeyEnum, WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import type { ChatDispatchProps } from '@fastgpt/global/core/workflow/type/index.d';
@@ -45,6 +45,7 @@ import { getReferenceVariableValue } from '@fastgpt/global/core/workflow/runtime
import { dispatchSystemConfig } from './init/systemConfig';
import { dispatchUpdateVariable } from './tools/runUpdateVar';
import { addLog } from '../../../common/system/log';
import { surrenderProcess } from '../../../common/system/tools';
const callbackMap: Record<FlowNodeTypeEnum, Function> = {
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
@@ -206,25 +207,34 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
}
function checkNodeCanRun(nodes: RuntimeNodeItemType[] = []): Promise<any> {
return Promise.all(
nodes.map((node) => {
nodes.map(async (node) => {
const status = checkNodeRunStatus({
node,
runtimeEdges
});
if (res?.closed || props.maxRunTimes <= 0) return;
props.maxRunTimes--;
console.log(props.maxRunTimes, user._id);
await surrenderProcess();
if (status === 'run') {
addLog.info(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
return nodeRunWithActive(node);
}
if (status === 'skip') {
addLog.info(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
addLog.info(`[dispatchWorkFlow] nodeRunWithSkip: ${node.name}`);
return nodeRunWithSkip(node);
}
return [];
return;
})
).then((result) => {
const flat = result.flat();
const flat = result.flat().filter(Boolean) as unknown as {
node: RuntimeNodeItemType;
result: Record<string, any>;
}[];
if (flat.length === 0) return;
// Update the node output at the end of the run and get the next nodes
@@ -267,7 +277,6 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
return params;
}
async function nodeRunWithActive(node: RuntimeNodeItemType) {
if (res?.closed || props.maxRunTimes <= 0) return [];
// push run status messages
if (res && stream && detail && node.showStatus) {
responseStatus({
@@ -277,8 +286,6 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
});
}
props.maxRunTimes--;
// get node running params
const params = getNodeRunParams(node);

View File

@@ -33,7 +33,7 @@ type HttpRequestProps = ModuleDispatchProps<{
[key: string]: any;
}>;
type HttpResponse = DispatchNodeResultType<{
[NodeOutputKeyEnum.failed]?: boolean;
[NodeOutputKeyEnum.error]?: object;
[key: string]: any;
}>;
@@ -159,20 +159,16 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
} catch (error) {
addLog.error('Http request error', error);
if (isToolCall) {
return {
[NodeOutputKeyEnum.failed]: true,
[DispatchNodeResponseKeyEnum.nodeResponse]: {
totalPoints: 0,
params: Object.keys(params).length > 0 ? params : undefined,
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
headers: Object.keys(headers).length > 0 ? headers : undefined,
httpResult: { error: formatHttpError(error) }
},
[NodeOutputKeyEnum.httpRawResponse]: getErrText(error)
};
}
return Promise.reject(error);
return {
[NodeOutputKeyEnum.error]: formatHttpError(error),
[DispatchNodeResponseKeyEnum.nodeResponse]: {
params: Object.keys(params).length > 0 ? params : undefined,
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
headers: Object.keys(headers).length > 0 ? headers : undefined,
httpResult: { error: formatHttpError(error) }
},
[NodeOutputKeyEnum.httpRawResponse]: getErrText(error)
};
}
};