Check debug (#4384)
* feat : Added support for interactive nodes in the debugging interface (#4339)
* feat: add VSCode launch configuration and enhance debug API handler
* feat: refactor debug API handler to streamline workflow processing and enhance interactive chat features
* feat: enhance debug API handler with structured input forms and improved query handling
* feat: enhance debug API handler to support optional query and histories parameters
* feat: simplify query and histories initialization in debug API handler
* feat: add realmode parameter to workflow dispatch and update interactive handling
* feat: add optional query parameter to PostWorkflowDebugProps and remove realmode from ModuleDispatchProps
* feat: add history parameter to PostWorkflowDebugProps and update related components
* feat: remove realmode
* feat: simplify handler parameter destructuring in debug.ts
* feat: remove unused interactive prop from WholeResponseContent component
* feat: refactor onNextNodeDebug to use parameter object for better readability
* feat: Merge selections and next actions to remove unused state management
* feat: 添加 NodeDebugResponse 组件以增强调试功能
* feat: Simplify the import statements in InteractiveComponents.tsx
* feat: Update the handler function to use default parameters to simplify the code
* feat: Add optional workflowInteractiveResponse field to PostWorkflowDebugResponse type
* feat: Add the workflowInteractiveResponse field in the debugging handler to enhance response capabilities
* feat: Added workflowInteractiveResponse field in FlowNodeItemType to enhance responsiveness
* feat: Refactor NodeDebugResponse to utilize workflowInteractiveResponse for improved interactivity
* feat: Extend UserSelectInteractive and UserInputInteractive types to inherit from InteractiveBasicType
* feat: Refactor NodeDebugResponse to streamline interactive handling and improve code clarity
* feat: 重构交互式调试逻辑,创建共用 Hook 以简化用户选择和输入处理
* fix: type error
* feat: 重构 AIResponseBox 组件,简化用户交互逻辑并引入共用表单组件
* feat: 清理 AIResponseBox 和表单组件代码,移除冗余注释和未使用的导入
* fix: type error
* feat: 重构 AIResponseBox 组件,简化类型定义并优化代码结构
* refactor: 将 FormItem 接口更改为类型定义,优化代码结构
* refactor: 将 NodeDebugResponseProps 接口更改为类型定义,优化代码结构
* refactor: 移除不必要的入口节点检查,简化调试处理逻辑
* feat: 移动调试交互组件位置
* refactor: 将 InteractiveBasicType 中的属性设为可选,简化数据结构
* refactor: 优化类型定义
* refactor: 移除未使用的 ChatItemType 和 UserChatItemValueItemType 导入
* refactor: 将接口定义更改为类型别名,简化代码结构
* refactor: 更新类型定义,使用类型别名简化代码结构
* refactor: 使用类型导入简化代码结构,重构 AIResponseBox 组件
* refactor: 提取描述框和表单项标签组件,简化代码结构
* refactor: 移除多余的空行
* refactor: 移除多余的空行和注释
* refactor: 移除多余的空行,简化 AIResponseBox 组件代码
* refactor: 重构组件,移动 FormComponents 到 InteractiveComponents,简化代码结构
* refactor: 移除多余的空行,简化 NodeDebugResponse 组件代码
* refactor: 更新导入语句,使用 type 关键字优化类型导入
* refactor: 在 tsconfig.json 中启用 verbatimModuleSyntax 选项
* Revert "refactor: 在 tsconfig.json 中启用 verbatimModuleSyntax 选项"
This reverts commit 2b335a9938.
* revert: rendertool
* refactor: Remove unused imports and functions to simplify code
* perf: debug interactive
---------
Co-authored-by: Theresa <63280168+sd0ric4@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import type { AIChatItemType, UserChatItemType } from '@fastgpt/global/core/chat
|
||||
import { authApp } from '@fastgpt/service/support/permission/app/auth';
|
||||
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
|
||||
import { getUserChatInfoAndAuthTeamPoints } from '@fastgpt/service/support/permission/auth/team';
|
||||
import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import type { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import {
|
||||
concatHistories,
|
||||
getChatTitleFromChatMessage,
|
||||
@@ -25,8 +25,8 @@ import {
|
||||
} from '@fastgpt/global/core/workflow/utils';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { chatValue2RuntimePrompt, GPTMessages2Chats } from '@fastgpt/global/core/chat/adapt';
|
||||
import { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type';
|
||||
import { AppChatConfigType } from '@fastgpt/global/core/app/type';
|
||||
import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type';
|
||||
import type { AppChatConfigType } from '@fastgpt/global/core/app/type';
|
||||
import {
|
||||
getLastInteractiveValue,
|
||||
getMaxHistoryLimitFromNodes,
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
storeNodes2RuntimeNodes,
|
||||
textAdaptGptResponse
|
||||
} from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
||||
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
||||
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
||||
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||
import { getPluginInputsFromStoreNodes } from '@fastgpt/global/core/app/plugin/utils';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { authApp } from '@fastgpt/service/support/permission/app/auth';
|
||||
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
|
||||
import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { getUserChatInfoAndAuthTeamPoints } from '@fastgpt/service/support/permission/auth/team';
|
||||
import { PostWorkflowDebugProps, PostWorkflowDebugResponse } from '@/global/core/workflow/api';
|
||||
import type { PostWorkflowDebugProps, PostWorkflowDebugResponse } from '@/global/core/workflow/api';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { defaultApp } from '@/web/core/app/constants';
|
||||
@@ -15,16 +15,22 @@ async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
): Promise<PostWorkflowDebugResponse> {
|
||||
const { nodes = [], edges = [], variables = {}, appId } = req.body as PostWorkflowDebugProps;
|
||||
|
||||
const {
|
||||
nodes = [],
|
||||
edges = [],
|
||||
variables = {},
|
||||
appId,
|
||||
query = [],
|
||||
history = []
|
||||
} = req.body as PostWorkflowDebugProps;
|
||||
if (!nodes) {
|
||||
throw new Error('Prams Error');
|
||||
return Promise.reject('Prams Error');
|
||||
}
|
||||
if (!Array.isArray(nodes)) {
|
||||
throw new Error('Nodes is not array');
|
||||
return Promise.reject('Nodes is not array');
|
||||
}
|
||||
if (!Array.isArray(edges)) {
|
||||
throw new Error('Edges is not array');
|
||||
return Promise.reject('Edges is not array');
|
||||
}
|
||||
|
||||
/* user auth */
|
||||
@@ -40,31 +46,32 @@ async function handler(
|
||||
const { timezone, externalProvider } = await getUserChatInfoAndAuthTeamPoints(tmbId);
|
||||
|
||||
/* start process */
|
||||
const { flowUsages, flowResponses, debugResponse, newVariables } = await dispatchWorkFlow({
|
||||
res,
|
||||
requestOrigin: req.headers.origin,
|
||||
mode: 'debug',
|
||||
runningAppInfo: {
|
||||
id: app._id,
|
||||
teamId: app.teamId,
|
||||
tmbId: app.tmbId
|
||||
},
|
||||
runningUserInfo: {
|
||||
teamId,
|
||||
tmbId
|
||||
},
|
||||
uid: tmbId,
|
||||
timezone,
|
||||
externalProvider,
|
||||
runtimeNodes: nodes,
|
||||
runtimeEdges: edges,
|
||||
variables,
|
||||
query: [],
|
||||
chatConfig: defaultApp.chatConfig,
|
||||
histories: [],
|
||||
stream: false,
|
||||
maxRunTimes: WORKFLOW_MAX_RUN_TIMES
|
||||
});
|
||||
const { flowUsages, flowResponses, debugResponse, newVariables, workflowInteractiveResponse } =
|
||||
await dispatchWorkFlow({
|
||||
res,
|
||||
requestOrigin: req.headers.origin,
|
||||
mode: 'debug',
|
||||
timezone,
|
||||
externalProvider,
|
||||
uid: tmbId,
|
||||
runningAppInfo: {
|
||||
id: app._id,
|
||||
teamId: app.teamId,
|
||||
tmbId: app.tmbId
|
||||
},
|
||||
runningUserInfo: {
|
||||
teamId,
|
||||
tmbId
|
||||
},
|
||||
runtimeNodes: nodes,
|
||||
runtimeEdges: edges,
|
||||
variables,
|
||||
query: query,
|
||||
chatConfig: defaultApp.chatConfig,
|
||||
histories: history,
|
||||
stream: false,
|
||||
maxRunTimes: WORKFLOW_MAX_RUN_TIMES
|
||||
});
|
||||
|
||||
createChatUsage({
|
||||
appName: `${app.name}-Debug`,
|
||||
@@ -78,12 +85,12 @@ async function handler(
|
||||
return {
|
||||
...debugResponse,
|
||||
newVariables,
|
||||
flowResponses
|
||||
flowResponses,
|
||||
workflowInteractiveResponse
|
||||
};
|
||||
}
|
||||
|
||||
export default NextAPI(handler);
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: {
|
||||
|
||||
Reference in New Issue
Block a user