Skip to content

Commit 324aaae

Browse files
authored
fix: ai response test (#5544)
* fix: ai response test * fix: skip edge check * fix: app list * fix: toolset conflict interactive node * fix: username show
1 parent d2d4c76 commit 324aaae

File tree

15 files changed

+75
-34
lines changed

15 files changed

+75
-34
lines changed

document/content/docs/upgrading/4-12/4122.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: 'FastGPT V4.12.2 更新说明'
77

88
### 1. 更新镜像:
99

10-
- 更新 FastGPT 镜像tag: v4.12.2
10+
- 更新 FastGPT 镜像tag: v4.12.2-fix
1111
- 更新 FastGPT 商业版镜像tag: v4.12.2
1212
- 更新 fastgpt-plugin 镜像 tag: v0.1.11
1313
- mcp_server 无需更新
@@ -42,6 +42,7 @@ description: 'FastGPT V4.12.2 更新说明'
4242
8. 工作流,添加团队应用,搜索无效。
4343
9. 应用版本,ref 字段错误,导致无法正常使用。
4444
10. Oceanbase 批量插入时,未正确返回插入的 id。
45+
11. 交互节点与工具集存在冲突,导致交互节点后工具集无法正常使用。
4546

4647
## 🔨 工具更新
4748

document/data/doc-last-modified.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"document/content/docs/upgrading/4-11/4111.mdx": "2025-08-07T22:49:09+08:00",
105105
"document/content/docs/upgrading/4-12/4120.mdx": "2025-08-12T22:45:19+08:00",
106106
"document/content/docs/upgrading/4-12/4121.mdx": "2025-08-15T22:53:06+08:00",
107-
"document/content/docs/upgrading/4-12/4122.mdx": "2025-08-26T17:29:42+08:00",
107+
"document/content/docs/upgrading/4-12/4122.mdx": "2025-08-26T23:08:11+08:00",
108108
"document/content/docs/upgrading/4-8/40.mdx": "2025-08-02T19:38:37+08:00",
109109
"document/content/docs/upgrading/4-8/41.mdx": "2025-08-02T19:38:37+08:00",
110110
"document/content/docs/upgrading/4-8/42.mdx": "2025-08-02T19:38:37+08:00",

packages/global/common/error/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export const getErrText = (err: any, def = ''): any => {
1818
return ERROR_RESPONSE[msg].message;
1919
}
2020

21+
// Axios special
22+
if (err?.errors && Array.isArray(err.errors) && err.errors.length > 0) {
23+
return err.errors[0].message;
24+
}
25+
2126
// msg && console.log('error =>', msg);
2227
return replaceSensitiveText(msg);
2328
};

packages/global/core/app/mcpTools/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const getMCPToolRuntimeNode = ({
6161
parentId: string;
6262
}): RuntimeNodeItemType => {
6363
return {
64-
nodeId: getNanoid(16),
64+
nodeId: getNanoid(),
6565
flowNodeType: FlowNodeTypeEnum.tool,
6666
avatar,
6767
intro: tool.description,

packages/service/core/ai/llm/request.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ export const createLLMResponse = async <T extends CompletionsBodyType>(
6767
const { body, custonHeaders, userKey } = args;
6868
const { messages, useVision, requestOrigin, tools, toolCallMode } = body;
6969

70-
const modelData = getLLMModel(body.model);
71-
7270
// Messages process
7371
const requestMessages = await loadRequestMessages({
7472
messages,
@@ -475,13 +473,11 @@ type LLMRequestBodyType<T> = Omit<T, 'model' | 'stop' | 'response_format' | 'mes
475473

476474
// Custom field
477475
retainDatasetCite?: boolean;
478-
reasoning?: boolean; // Whether to response reasoning content
479476
toolCallMode?: 'toolChoice' | 'prompt';
480477
useVision?: boolean;
481478
requestOrigin?: string;
482479
};
483480
const llmCompletionsBodyFormat = async <T extends CompletionsBodyType>({
484-
reasoning,
485481
retainDatasetCite,
486482
useVision,
487483
requestOrigin,

packages/service/core/workflow/dispatch/ai/agent/toolCall.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ export const runToolCall = async (
287287
body: {
288288
model: toolModel.model,
289289
stream,
290-
reasoning: aiChatReasoning,
291290
messages: filterMessages,
292291
tool_choice: 'auto',
293292
toolCallMode: toolModel.toolChoice ? 'toolChoice' : 'prompt',
@@ -308,6 +307,7 @@ export const runToolCall = async (
308307
isAborted: () => res?.closed,
309308
userKey: externalProvider.openaiAccount,
310309
onReasoning({ text }) {
310+
if (!aiChatReasoning) return;
311311
workflowStreamResponse?.({
312312
write,
313313
event: SseResponseEventEnum.answer,

packages/service/core/workflow/dispatch/ai/chat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
184184
body: {
185185
model: modelConstantsData.model,
186186
stream,
187-
reasoning: aiChatReasoning,
188187
messages: filterMessages,
189188
temperature,
190189
max_tokens,
@@ -201,6 +200,7 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
201200
userKey: externalProvider.openaiAccount,
202201
isAborted: () => res?.closed,
203202
onReasoning({ text }) {
203+
if (!aiChatReasoning) return;
204204
workflowStreamResponse?.({
205205
write,
206206
event: SseResponseEventEnum.answer,
@@ -210,6 +210,7 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
210210
});
211211
},
212212
onStreaming({ text }) {
213+
if (!isResponseAnswerText) return;
213214
workflowStreamResponse?.({
214215
write,
215216
event: SseResponseEventEnum.answer,

packages/service/core/workflow/dispatch/index.ts

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
152152
方案:
153153
- 采用回调的方式,避免深度递归。
154154
- 使用 activeRunQueue 记录待运行检查的节点(可能可以运行),并控制并发数量。
155-
- 每次添加新节点,以及节点运行结束后,均会执行一次 processNextNode 方法。 processNextNode 方法,如果没触发跳出条件,则必定会取一个 activeRunQueue 继续检查处理。
155+
- 每次添加新节点,以及节点运行结束后,均会执行一次 processActiveNode 方法。 processActiveNode 方法,如果没触发跳出条件,则必定会取一个 activeRunQueue 继续检查处理。
156156
- checkNodeCanRun 会检查该节点状态
157157
- 没满足运行条件:跳出函数
158158
- 运行:执行节点逻辑,并返回结果,将 target node 加入到 activeRunQueue 中,等待队列处理。
159159
- 跳过:执行跳过逻辑,并将其后续的 target node 也进行一次检查。
160+
特殊情况:
161+
- 触发交互节点后,需要跳过所有 skip 节点,避免后续执行了 skipNode。
160162
*/
161163
class WorkflowQueue {
162164
// Workflow variables
@@ -176,6 +178,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
176178

177179
// Queue variables
178180
private activeRunQueue = new Set<string>();
181+
private skipNodeQueue: { node: RuntimeNodeItemType; skippedNodeIdList: Set<string> }[] = [];
179182
private runningNodeCount = 0;
180183
private maxConcurrency: number;
181184
private resolve: (e: WorkflowQueue) => void;
@@ -198,13 +201,17 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
198201
}
199202
this.activeRunQueue.add(nodeId);
200203

201-
this.processNextNode();
204+
this.processActiveNode();
202205
}
203206
// Process next active node
204-
private processNextNode() {
207+
private processActiveNode() {
205208
// Finish
206209
if (this.activeRunQueue.size === 0 && this.runningNodeCount === 0) {
207-
this.resolve(this);
210+
if (this.skipNodeQueue.length > 0 && !this.nodeInteractiveResponse) {
211+
this.processSkipNodes();
212+
} else {
213+
this.resolve(this);
214+
}
208215
return;
209216
}
210217

@@ -224,12 +231,26 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
224231

225232
this.checkNodeCanRun(node).finally(() => {
226233
this.runningNodeCount--;
227-
this.processNextNode();
234+
this.processActiveNode();
228235
});
229236
}
230237
// 兜底,除非极端情况,否则不可能触发
231238
else {
232-
this.processNextNode();
239+
this.processActiveNode();
240+
}
241+
}
242+
243+
private addSkipNode(node: RuntimeNodeItemType, skippedNodeIdList: Set<string>) {
244+
this.skipNodeQueue.push({ node, skippedNodeIdList });
245+
}
246+
private processSkipNodes() {
247+
const skipItem = this.skipNodeQueue.shift();
248+
if (skipItem) {
249+
this.checkNodeCanRun(skipItem.node, skipItem.skippedNodeIdList).finally(() => {
250+
this.processActiveNode();
251+
});
252+
} else {
253+
this.processActiveNode();
233254
}
234255
}
235256

@@ -695,9 +716,9 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
695716
nodeRunResult.result
696717
);
697718

698-
await Promise.all(
699-
nextStepSkipNodes.map((node) => this.checkNodeCanRun(node, skippedNodeIdList))
700-
);
719+
nextStepSkipNodes.forEach((node) => {
720+
this.addSkipNode(node, skippedNodeIdList);
721+
});
701722

702723
// Run next nodes
703724
nextStepActiveNodes.forEach((node) => {

packages/service/core/workflow/dispatch/tools/codeSandbox.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import axios from 'axios';
55
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
66
import { SandboxCodeTypeEnum } from '@fastgpt/global/core/workflow/template/system/sandbox/constants';
77
import { getErrText } from '@fastgpt/global/common/error/utils';
8-
import { getNodeErrResponse } from '../utils';
98

109
type RunCodeType = ModuleDispatchProps<{
1110
[NodeInputKeyEnum.codeType]: string;

packages/service/core/workflow/dispatch/utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,22 @@ export const rewriteRuntimeWorkFlow = async ({
210210
if (!app) continue;
211211
const toolList = await getMCPChildren(app);
212212

213-
for (const tool of toolList) {
213+
const parentId = mcpToolsetVal.toolId ?? toolSetNode.pluginId;
214+
toolList.forEach((tool, index) => {
214215
const newToolNode = getMCPToolRuntimeNode({
215216
avatar: toolSetNode.avatar,
216217
tool,
217218
// New ?? Old
218-
parentId: mcpToolsetVal.toolId ?? toolSetNode.pluginId
219+
parentId
219220
});
221+
newToolNode.nodeId = `${parentId}${index}`; // ID 不能随机,否则下次生成时候就和之前的记录对不上
220222

221-
nodes.push({ ...newToolNode, name: `${toolSetNode.name}/${tool.name}` });
223+
nodes.push({
224+
...newToolNode,
225+
name: `${toolSetNode.name}/${tool.name}`
226+
});
222227
pushEdges(newToolNode.nodeId);
223-
}
228+
});
224229
}
225230
}
226231

0 commit comments

Comments
 (0)