mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-05 01:02:59 +08:00
fix: document deploy (#5868)
* mcp memory * Editor space parse error * fix: ts * fix: debug interactive * fix: templateId * fix: editor in debug * doc
This commit is contained in:
@@ -22,7 +22,6 @@ import { getNodeErrResponse } from '../utils';
|
||||
import { splitCombineToolId } from '@fastgpt/global/core/app/tool/utils';
|
||||
import { getAppVersionById } from '../../../../core/app/version/controller';
|
||||
import { runHTTPTool } from '../../../app/http';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
|
||||
type SystemInputConfigType = {
|
||||
type: SystemToolSecretInputTypeEnum;
|
||||
@@ -50,6 +49,7 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
|
||||
runningAppInfo,
|
||||
variables,
|
||||
workflowStreamResponse,
|
||||
|
||||
node: { name, avatar, toolConfig, version, catchError }
|
||||
} = props;
|
||||
|
||||
@@ -201,14 +201,19 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
|
||||
|
||||
const { headerSecret, url } =
|
||||
tool.nodes[0].toolConfig?.mcpToolSet ?? tool.nodes[0].inputs[0].value;
|
||||
const mcpClient = new MCPClient({
|
||||
url,
|
||||
headers: getSecretValue({
|
||||
storeSecret: headerSecret
|
||||
})
|
||||
});
|
||||
|
||||
const result = await mcpClient.toolCall(toolName, params);
|
||||
// Buffer mcpClient in this workflow
|
||||
const mcpClient =
|
||||
props.mcpClientMemory?.[url] ??
|
||||
new MCPClient({
|
||||
url,
|
||||
headers: getSecretValue({
|
||||
storeSecret: headerSecret
|
||||
})
|
||||
});
|
||||
props.mcpClientMemory[url] = mcpClient;
|
||||
|
||||
const result = await mcpClient.toolCall({ toolName, params, closeConnection: false });
|
||||
return {
|
||||
data: { [NodeOutputKeyEnum.rawResponse]: result },
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
@@ -285,7 +290,7 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
|
||||
storeSecret: headerSecret
|
||||
})
|
||||
});
|
||||
const result = await mcpClient.toolCall(toolName, restParams);
|
||||
const result = await mcpClient.toolCall({ toolName, params: restParams });
|
||||
|
||||
return {
|
||||
data: {
|
||||
|
||||
@@ -54,6 +54,7 @@ import { createChatUsageRecord, pushChatItemUsage } from '../../../support/walle
|
||||
import type { RequireOnlyOne } from '@fastgpt/global/common/type/utils';
|
||||
import { getS3ChatSource } from '../../../common/s3/sources/chat';
|
||||
import { addPreviewUrlToChatItems } from '../../chat/utils';
|
||||
import type { MCPClient } from '../../app/mcp';
|
||||
|
||||
type Props = Omit<ChatDispatchProps, 'workflowDispatchDeep' | 'timezone' | 'externalProvider'> & {
|
||||
runtimeNodes: RuntimeNodeItemType[];
|
||||
@@ -152,6 +153,8 @@ export async function dispatchWorkFlow({
|
||||
}))
|
||||
};
|
||||
|
||||
let mcpClientMemory = {} as Record<string, MCPClient>;
|
||||
|
||||
// Init some props
|
||||
return runWorkflow({
|
||||
...data,
|
||||
@@ -163,17 +166,24 @@ export async function dispatchWorkFlow({
|
||||
variables: defaultVariables,
|
||||
workflowDispatchDeep: 0,
|
||||
usageId: newUsageId,
|
||||
concatUsage
|
||||
concatUsage,
|
||||
mcpClientMemory
|
||||
}).finally(() => {
|
||||
if (streamCheckTimer) {
|
||||
clearInterval(streamCheckTimer);
|
||||
}
|
||||
|
||||
// Close mcpClient connections
|
||||
Object.values(mcpClientMemory).forEach((client) => {
|
||||
client.closeConnection();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
type RunWorkflowProps = ChatDispatchProps & {
|
||||
runtimeNodes: RuntimeNodeItemType[];
|
||||
runtimeEdges: RuntimeEdgeItemType[];
|
||||
mcpClientMemory: Record<string, MCPClient>;
|
||||
defaultSkipNodeQueue?: WorkflowDebugResponse['skipNodeQueue'];
|
||||
concatUsage?: (points: number) => any;
|
||||
};
|
||||
@@ -192,7 +202,8 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
responseAllData = true,
|
||||
usageId,
|
||||
concatUsage,
|
||||
runningUserInfo: { teamId }
|
||||
runningUserInfo: { teamId },
|
||||
mcpClientMemory
|
||||
} = data;
|
||||
|
||||
// Over max depth
|
||||
@@ -458,7 +469,8 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
|
||||
const dispatchData: ModuleDispatchProps<Record<string, any>> = {
|
||||
...data,
|
||||
lastInteractive: data.lastInteractive?.entryNodeIds.includes(node.nodeId)
|
||||
mcpClientMemory,
|
||||
lastInteractive: data.lastInteractive?.entryNodeIds?.includes(node.nodeId)
|
||||
? data.lastInteractive
|
||||
: undefined,
|
||||
variables,
|
||||
|
||||
Reference in New Issue
Block a user