feat: simplify query and histories initialization in debug API handler

This commit is contained in:
sd0ric4
2025-03-24 21:53:42 +08:00
parent 70388f1fde
commit ccc9260ed5

View File

@@ -173,128 +173,121 @@ async function handler(
]
}
];
const query: UserChatItemValueItemType[] = requestQuery || [
{
type: ChatItemValueTypeEnum.text,
text: {
content: 'Cancel'
}
}
];
const histories: ChatItemType[] = requestHistories || [
{
dataId: 'debug-history-1',
obj: ChatRoleEnum.Human,
value: [
{
type: ChatItemValueTypeEnum.text,
text: {
content: '启动工作流'
}
}
]
},
{
dataId: 'debug-history-2',
obj: ChatRoleEnum.AI,
value: [
{
type: ChatItemValueTypeEnum.interactive,
interactive: {
type: 'userSelect',
params: {
description: '请选择操作',
userSelectOptions: [
{ value: 'Confirm', key: 'option1' },
{ value: 'Cancel', key: 'option2' }
],
// 已选择的值使得此交互不会被getLastInteractiveValue返回
userSelectedVal: 'Confirm'
},
entryNodeIds: ['nodeId1'],
memoryEdges: [
{
source: 'workflowStartNodeId',
target: 'nodeId1',
sourceHandle: 'workflowStartNodeId-source-right',
targetHandle: 'nodeId1-target-left',
status: 'active'
}
],
nodeOutputs: [
{
nodeId: 'workflowStartNodeId',
key: NodeOutputKeyEnum.userChatInput,
value: '启动工作流'
}
]
}
}
]
},
{
dataId: 'bglb040v1wPQ3C1iNaDStPhm',
obj: ChatRoleEnum.AI, // 使用枚举值
value: [
{
type: ChatItemValueTypeEnum.interactive, // 使用枚举值
interactive: {
type: 'userSelect',
params: {
description: '你是谁',
userSelectOptions: [
{
value: 'Confirm',
key: 'option1'
},
{
value: 'Cancel',
key: 'option2'
},
{
value: 'wqeqweqwe',
key: 'y7eOdrYzYS5C'
}
]
// 重要:这里没有 userSelectedVal所以这个交互会被getLastInteractiveValue返回
},
entryNodeIds: ['oQKWr1cGFVBG'],
memoryEdges: [
{
source: 'workflowStartNodeId',
target: 'oQKWr1cGFVBG',
sourceHandle: 'workflowStartNodeId-source-right',
targetHandle: 'oQKWr1cGFVBG-target-left',
status: 'waiting'
},
{
source: 'oQKWr1cGFVBG',
target: 'uFnqha6Nx9qw',
sourceHandle: 'oQKWr1cGFVBG-source-option1',
targetHandle: 'uFnqha6Nx9qw-target-left',
status: 'waiting'
},
{
source: 'oQKWr1cGFVBG',
target: '7kwgL1dVlwG6',
sourceHandle: 'oQKWr1cGFVBG-source-option2',
targetHandle: '7kwgL1dVlwG6-target-left',
status: 'waiting'
}
],
nodeOutputs: [
{
nodeId: 'workflowStartNodeId',
key: NodeOutputKeyEnum.userChatInput,
value: 'Confirm'
}
]
}
}
]
}
];
const query: UserChatItemValueItemType[] = requestQuery || [];
const histories: ChatItemType[] = requestHistories || [];
// || [
// {
// dataId: 'debug-history-1',
// obj: ChatRoleEnum.Human,
// value: [
// {
// type: ChatItemValueTypeEnum.text,
// text: {
// content: '启动工作流'
// }
// }
// ]
// },
// {
// dataId: 'debug-history-2',
// obj: ChatRoleEnum.AI,
// value: [
// {
// type: ChatItemValueTypeEnum.interactive,
// interactive: {
// type: 'userSelect',
// params: {
// description: '请选择操作',
// userSelectOptions: [
// { value: 'Confirm', key: 'option1' },
// { value: 'Cancel', key: 'option2' }
// ],
// // 已选择的值使得此交互不会被getLastInteractiveValue返回
// userSelectedVal: 'Confirm'
// },
// entryNodeIds: ['nodeId1'],
// memoryEdges: [
// {
// source: 'workflowStartNodeId',
// target: 'nodeId1',
// sourceHandle: 'workflowStartNodeId-source-right',
// targetHandle: 'nodeId1-target-left',
// status: 'active'
// }
// ],
// nodeOutputs: [
// {
// nodeId: 'workflowStartNodeId',
// key: NodeOutputKeyEnum.userChatInput,
// value: '启动工作流'
// }
// ]
// }
// }
// ]
// },
// {
// dataId: 'bglb040v1wPQ3C1iNaDStPhm',
// obj: ChatRoleEnum.AI, // 使用枚举值
// value: [
// {
// type: ChatItemValueTypeEnum.interactive, // 使用枚举值
// interactive: {
// type: 'userSelect',
// params: {
// description: '你是谁',
// userSelectOptions: [
// {
// value: 'Confirm',
// key: 'option1'
// },
// {
// value: 'Cancel',
// key: 'option2'
// },
// {
// value: 'wqeqweqwe',
// key: 'y7eOdrYzYS5C'
// }
// ]
// // 重要:这里没有 userSelectedVal所以这个交互会被getLastInteractiveValue返回
// },
// entryNodeIds: ['oQKWr1cGFVBG'],
// memoryEdges: [
// {
// source: 'workflowStartNodeId',
// target: 'oQKWr1cGFVBG',
// sourceHandle: 'workflowStartNodeId-source-right',
// targetHandle: 'oQKWr1cGFVBG-target-left',
// status: 'waiting'
// },
// {
// source: 'oQKWr1cGFVBG',
// target: 'uFnqha6Nx9qw',
// sourceHandle: 'oQKWr1cGFVBG-source-option1',
// targetHandle: 'uFnqha6Nx9qw-target-left',
// status: 'waiting'
// },
// {
// source: 'oQKWr1cGFVBG',
// target: '7kwgL1dVlwG6',
// sourceHandle: 'oQKWr1cGFVBG-source-option2',
// targetHandle: '7kwgL1dVlwG6-target-left',
// status: 'waiting'
// }
// ],
// nodeOutputs: [
// {
// nodeId: 'workflowStartNodeId',
// key: NodeOutputKeyEnum.userChatInput,
// value: 'Confirm'
// }
// ]
// }
// }
// ]
// }
// ];
/* user auth */
const [{ teamId, tmbId }, { app }] = await Promise.all([
authCert({