feat: refactor onNextNodeDebug to use parameter object for better readability
This commit is contained in:
@@ -167,16 +167,11 @@ type WorkflowContextType = {
|
|||||||
history?: ChatItemType[];
|
history?: ChatItemType[];
|
||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
onNextNodeDebug: (
|
onNextNodeDebug: (params?: {
|
||||||
history?: ChatItemType[],
|
history?: ChatItemType[];
|
||||||
query?: UserChatItemValueItemType[],
|
query?: UserChatItemValueItemType[];
|
||||||
debugData?: {
|
debugData?: DebugDataType;
|
||||||
runtimeNodes: RuntimeNodeItemType[];
|
}) => Promise<void>;
|
||||||
runtimeEdges: RuntimeEdgeItemType[];
|
|
||||||
nextRunNodes: RuntimeNodeItemType[];
|
|
||||||
variables: Record<string, any>;
|
|
||||||
}
|
|
||||||
) => Promise<void>;
|
|
||||||
onStartNodeDebug: ({
|
onStartNodeDebug: ({
|
||||||
entryNodeId,
|
entryNodeId,
|
||||||
runtimeNodes,
|
runtimeNodes,
|
||||||
@@ -253,11 +248,11 @@ export const WorkflowContext = createContext<WorkflowContextType>({
|
|||||||
throw new Error('Function not implemented.');
|
throw new Error('Function not implemented.');
|
||||||
},
|
},
|
||||||
workflowDebugData: undefined,
|
workflowDebugData: undefined,
|
||||||
onNextNodeDebug: function (
|
onNextNodeDebug: function (params?: {
|
||||||
history?: ChatItemType[],
|
history?: ChatItemType[];
|
||||||
query?: UserChatItemValueItemType[],
|
query?: UserChatItemValueItemType[];
|
||||||
debugData?: any
|
debugData?: DebugDataType;
|
||||||
): Promise<void> {
|
}): Promise<void> {
|
||||||
throw new Error('Function not implemented.');
|
throw new Error('Function not implemented.');
|
||||||
},
|
},
|
||||||
onStartNodeDebug: function ({
|
onStartNodeDebug: function ({
|
||||||
@@ -576,11 +571,13 @@ const WorkflowContextProvider = ({
|
|||||||
/* debug */
|
/* debug */
|
||||||
const [workflowDebugData, setWorkflowDebugData] = useState<DebugDataType>();
|
const [workflowDebugData, setWorkflowDebugData] = useState<DebugDataType>();
|
||||||
const onNextNodeDebug = useCallback(
|
const onNextNodeDebug = useCallback(
|
||||||
async (
|
async (params?: {
|
||||||
history?: ChatItemType[],
|
history?: ChatItemType[];
|
||||||
query?: UserChatItemValueItemType[],
|
query?: UserChatItemValueItemType[];
|
||||||
debugData = workflowDebugData
|
debugData?: DebugDataType;
|
||||||
) => {
|
}) => {
|
||||||
|
// 解构参数并提供默认值
|
||||||
|
const { history, query, debugData = workflowDebugData } = params || {};
|
||||||
if (!debugData) return;
|
if (!debugData) return;
|
||||||
// 1. Cancel node selected status and debugResult.showStatus
|
// 1. Cancel node selected status and debugResult.showStatus
|
||||||
setNodes((state) =>
|
setNodes((state) =>
|
||||||
@@ -707,7 +704,7 @@ const WorkflowContextProvider = ({
|
|||||||
|
|
||||||
// Check for an empty response
|
// Check for an empty response
|
||||||
if (flowResponses.length === 0 && nextStepRunNodes.length > 0) {
|
if (flowResponses.length === 0 && nextStepRunNodes.length > 0) {
|
||||||
onNextNodeDebug(history, query, newStoreDebugData);
|
onNextNodeDebug({ history, query, debugData: newStoreDebugData });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
entryNodes.forEach((node) => {
|
entryNodes.forEach((node) => {
|
||||||
@@ -767,7 +764,11 @@ const WorkflowContextProvider = ({
|
|||||||
onStopNodeDebug();
|
onStopNodeDebug();
|
||||||
setWorkflowDebugData(data);
|
setWorkflowDebugData(data);
|
||||||
|
|
||||||
onNextNodeDebug(history, query, data);
|
onNextNodeDebug({
|
||||||
|
history,
|
||||||
|
query,
|
||||||
|
debugData: data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user