Compare commits
6 Commits
v4.8.10-fi
...
v4.8.10-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02bf400bf3 | ||
|
|
11cbcca2d4 | ||
|
|
34422f9549 | ||
|
|
aeba79267a | ||
|
|
7473be5922 | ||
|
|
de59b3d2e5 |
@@ -24,8 +24,8 @@ STORE_LOG_LEVEL=warn
|
|||||||
|
|
||||||
### 3. 修改镜像tag
|
### 3. 修改镜像tag
|
||||||
|
|
||||||
- 更新 FastGPT 镜像 tag: v4.8.10
|
- 更新 FastGPT 镜像 tag: v4.8.10-fix
|
||||||
- 更新 FastGPT 商业版镜像 tag: v4.8.10
|
- 更新 FastGPT 商业版镜像 tag: v4.8.10-fix
|
||||||
- Sandbox 镜像,可以不更新
|
- Sandbox 镜像,可以不更新
|
||||||
|
|
||||||
## 4. 执行初始化
|
## 4. 执行初始化
|
||||||
|
|||||||
@@ -22,3 +22,7 @@ weight: 813
|
|||||||
5. 新增 - 插件支持配置使用引导、全局变量和文件输入。
|
5. 新增 - 插件支持配置使用引导、全局变量和文件输入。
|
||||||
6. 新增 - 简易模式支持新的版本管理方式。
|
6. 新增 - 简易模式支持新的版本管理方式。
|
||||||
7. 新增 - 聊天记录滚动加载,不再只加载 30 条。
|
7. 新增 - 聊天记录滚动加载,不再只加载 30 条。
|
||||||
|
8. 优化 - 工作流嵌套层级限制 20 层,避免因编排不合理导致的无限死循环。
|
||||||
|
9. 优化 - 工作流 handler 性能优化。
|
||||||
|
10. 修复 - 知识库选择权限问题。
|
||||||
|
11. 修复 - 空 chatId 发起对话,首轮携带用户选择时会异常。
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ export enum DispatchNodeResponseKeyEnum {
|
|||||||
assistantResponses = 'assistantResponses', // assistant response
|
assistantResponses = 'assistantResponses', // assistant response
|
||||||
rewriteHistories = 'rewriteHistories', // If have the response, workflow histories will be rewrite
|
rewriteHistories = 'rewriteHistories', // If have the response, workflow histories will be rewrite
|
||||||
|
|
||||||
interactive = 'INTERACTIVE' // is interactive
|
interactive = 'INTERACTIVE', // is interactive
|
||||||
|
runTimes = 'runTimes' // run times
|
||||||
}
|
}
|
||||||
|
|
||||||
export const needReplaceReferenceInputTypeList = [
|
export const needReplaceReferenceInputTypeList = [
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export type ChatDispatchProps = {
|
|||||||
maxRunTimes: number;
|
maxRunTimes: number;
|
||||||
isToolCall?: boolean;
|
isToolCall?: boolean;
|
||||||
workflowStreamResponse?: WorkflowResponseType;
|
workflowStreamResponse?: WorkflowResponseType;
|
||||||
|
workflowDispatchDeep?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModuleDispatchProps<T> = ChatDispatchProps & {
|
export type ModuleDispatchProps<T> = ChatDispatchProps & {
|
||||||
@@ -181,6 +182,7 @@ export type DispatchNodeResultType<T = {}> = {
|
|||||||
[DispatchNodeResponseKeyEnum.toolResponses]?: ToolRunResponseItemType; // Tool response
|
[DispatchNodeResponseKeyEnum.toolResponses]?: ToolRunResponseItemType; // Tool response
|
||||||
[DispatchNodeResponseKeyEnum.assistantResponses]?: AIChatItemValueItemType[]; // Assistant response(Store to db)
|
[DispatchNodeResponseKeyEnum.assistantResponses]?: AIChatItemValueItemType[]; // Assistant response(Store to db)
|
||||||
[DispatchNodeResponseKeyEnum.rewriteHistories]?: ChatItemType[];
|
[DispatchNodeResponseKeyEnum.rewriteHistories]?: ChatItemType[];
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]?: number;
|
||||||
} & T;
|
} & T;
|
||||||
|
|
||||||
/* Single node props */
|
/* Single node props */
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { ClientSession } from '../../../common/mongo';
|
|||||||
import { getLLMModel, getVectorModel } from '../../ai/model';
|
import { getLLMModel, getVectorModel } from '../../ai/model';
|
||||||
import { addLog } from '../../../common/system/log';
|
import { addLog } from '../../../common/system/log';
|
||||||
import { getCollectionWithDataset } from '../controller';
|
import { getCollectionWithDataset } from '../controller';
|
||||||
|
import { mongoSessionRun } from '../../../common/mongo/sessionRun';
|
||||||
|
|
||||||
export const lockTrainingDataByTeamId = async (teamId: string): Promise<any> => {
|
export const lockTrainingDataByTeamId = async (teamId: string): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
@@ -64,7 +65,7 @@ export async function pushDataListToTrainingQueue({
|
|||||||
vectorModel: string;
|
vectorModel: string;
|
||||||
session?: ClientSession;
|
session?: ClientSession;
|
||||||
} & PushDatasetDataProps): Promise<PushDatasetDataResponse> {
|
} & PushDatasetDataProps): Promise<PushDatasetDataResponse> {
|
||||||
const checkModelValid = async () => {
|
const { model, maxToken, weight } = await (async () => {
|
||||||
const agentModelData = getLLMModel(agentModel);
|
const agentModelData = getLLMModel(agentModel);
|
||||||
if (!agentModelData) {
|
if (!agentModelData) {
|
||||||
return Promise.reject(`File model ${agentModel} is inValid`);
|
return Promise.reject(`File model ${agentModel} is inValid`);
|
||||||
@@ -91,9 +92,16 @@ export async function pushDataListToTrainingQueue({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(`Training mode "${trainingMode}" is inValid`);
|
return Promise.reject(`Training mode "${trainingMode}" is inValid`);
|
||||||
};
|
})();
|
||||||
|
|
||||||
const { model, maxToken, weight } = await checkModelValid();
|
// filter repeat or equal content
|
||||||
|
const set = new Set();
|
||||||
|
const filterResult: Record<string, PushDatasetDataChunkProps[]> = {
|
||||||
|
success: [],
|
||||||
|
overToken: [],
|
||||||
|
repeat: [],
|
||||||
|
error: []
|
||||||
|
};
|
||||||
|
|
||||||
// format q and a, remove empty char
|
// format q and a, remove empty char
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
@@ -108,19 +116,8 @@ export async function pushDataListToTrainingQueue({
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
});
|
|
||||||
|
|
||||||
// filter repeat or equal content
|
|
||||||
const set = new Set();
|
|
||||||
const filterResult: Record<string, PushDatasetDataChunkProps[]> = {
|
|
||||||
success: [],
|
|
||||||
overToken: [],
|
|
||||||
repeat: [],
|
|
||||||
error: []
|
|
||||||
};
|
|
||||||
|
|
||||||
// filter repeat content
|
// filter repeat content
|
||||||
data.forEach((item) => {
|
|
||||||
if (!item.q) {
|
if (!item.q) {
|
||||||
filterResult.error.push(item);
|
filterResult.error.push(item);
|
||||||
return;
|
return;
|
||||||
@@ -150,9 +147,15 @@ export async function pushDataListToTrainingQueue({
|
|||||||
const failedDocuments: PushDatasetDataChunkProps[] = [];
|
const failedDocuments: PushDatasetDataChunkProps[] = [];
|
||||||
|
|
||||||
// 使用 insertMany 批量插入
|
// 使用 insertMany 批量插入
|
||||||
|
const batchSize = 200;
|
||||||
|
const insertData = async (startIndex: number, session: ClientSession) => {
|
||||||
|
const list = filterResult.success.slice(startIndex, startIndex + batchSize);
|
||||||
|
|
||||||
|
if (list.length === 0) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await MongoDatasetTraining.insertMany(
|
await MongoDatasetTraining.insertMany(
|
||||||
filterResult.success.map((item) => ({
|
list.map((item) => ({
|
||||||
teamId,
|
teamId,
|
||||||
tmbId,
|
tmbId,
|
||||||
datasetId,
|
datasetId,
|
||||||
@@ -169,7 +172,7 @@ export async function pushDataListToTrainingQueue({
|
|||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
session,
|
session,
|
||||||
ordered: false
|
ordered: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -180,10 +183,19 @@ export async function pushDataListToTrainingQueue({
|
|||||||
});
|
});
|
||||||
console.log('failed', failedDocuments);
|
console.log('failed', failedDocuments);
|
||||||
}
|
}
|
||||||
|
console.log(startIndex, '===');
|
||||||
// 对于失败的文档,尝试单独插入
|
// 对于失败的文档,尝试单独插入
|
||||||
for await (const item of failedDocuments) {
|
await MongoDatasetTraining.create(failedDocuments, { session });
|
||||||
await MongoDatasetTraining.create(item);
|
|
||||||
|
return insertData(startIndex + batchSize, session);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (session) {
|
||||||
|
await insertData(0, session);
|
||||||
|
} else {
|
||||||
|
await mongoSessionRun(async (session) => {
|
||||||
|
await insertData(0, session);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete filterResult.success;
|
delete filterResult.success;
|
||||||
|
|||||||
3
packages/service/core/workflow/constants.ts
Normal file
3
packages/service/core/workflow/constants.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export const WORKFLOW_MAX_RUN_TIMES = process.env.WORKFLOW_MAX_RUN_TIMES
|
||||||
|
? parseInt(process.env.WORKFLOW_MAX_RUN_TIMES)
|
||||||
|
: 500;
|
||||||
@@ -298,7 +298,10 @@ export const runToolWithFunctionCall = async (
|
|||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages: filterMessages,
|
completeMessages: filterMessages,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +313,10 @@ export const runToolWithFunctionCall = async (
|
|||||||
{
|
{
|
||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -330,7 +336,8 @@ export const runToolWithFunctionCall = async (
|
|||||||
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value]
|
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value],
|
||||||
|
runTimes: (response?.runTimes || 0) + 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
|||||||
dispatchFlowResponse, // tool flow response
|
dispatchFlowResponse, // tool flow response
|
||||||
totalTokens,
|
totalTokens,
|
||||||
completeMessages = [], // The actual message sent to AI(just save text)
|
completeMessages = [], // The actual message sent to AI(just save text)
|
||||||
assistantResponses = [] // FastGPT system store assistant.value response
|
assistantResponses = [], // FastGPT system store assistant.value response
|
||||||
|
runTimes
|
||||||
} = await (async () => {
|
} = await (async () => {
|
||||||
const adaptMessages = chats2GPTMessages({ messages, reserveId: false });
|
const adaptMessages = chats2GPTMessages({ messages, reserveId: false });
|
||||||
|
|
||||||
@@ -195,6 +196,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
|||||||
const previewAssistantResponses = filterToolResponseToPreview(assistantResponses);
|
const previewAssistantResponses = filterToolResponseToPreview(assistantResponses);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||||
[NodeOutputKeyEnum.answerText]: previewAssistantResponses
|
[NodeOutputKeyEnum.answerText]: previewAssistantResponses
|
||||||
.filter((item) => item.text?.content)
|
.filter((item) => item.text?.content)
|
||||||
.map((item) => item.text?.content || '')
|
.map((item) => item.text?.content || '')
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ export const runToolWithPromptCall = async (
|
|||||||
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value]
|
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value],
|
||||||
|
runTimes: (response?.runTimes || 0) + 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +319,8 @@ ANSWER: `;
|
|||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages: filterMessages,
|
completeMessages: filterMessages,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes: (response?.runTimes || 0) + toolsRunResponse.moduleRunResponse.runTimes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +332,8 @@ ANSWER: `;
|
|||||||
{
|
{
|
||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes: (response?.runTimes || 0) + toolsRunResponse.moduleRunResponse.runTimes
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -325,7 +325,10 @@ export const runToolWithToolChoice = async (
|
|||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +341,10 @@ export const runToolWithToolChoice = async (
|
|||||||
{
|
{
|
||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -358,7 +364,8 @@ export const runToolWithToolChoice = async (
|
|||||||
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value]
|
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value],
|
||||||
|
runTimes: (response?.runTimes || 0) + 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/
|
|||||||
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
||||||
import type { DispatchFlowResponse } from '../../type.d';
|
import type { DispatchFlowResponse } from '../../type.d';
|
||||||
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
||||||
|
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||||
|
|
||||||
export type DispatchToolModuleProps = ModuleDispatchProps<{
|
export type DispatchToolModuleProps = ModuleDispatchProps<{
|
||||||
[NodeInputKeyEnum.history]?: ChatItemType[];
|
[NodeInputKeyEnum.history]?: ChatItemType[];
|
||||||
@@ -25,6 +26,7 @@ export type RunToolResponse = {
|
|||||||
totalTokens: number;
|
totalTokens: number;
|
||||||
completeMessages?: ChatCompletionMessageParam[];
|
completeMessages?: ChatCompletionMessageParam[];
|
||||||
assistantResponses?: AIChatItemValueItemType[];
|
assistantResponses?: AIChatItemValueItemType[];
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: number;
|
||||||
};
|
};
|
||||||
export type ToolNodeItemType = RuntimeNodeItemType & {
|
export type ToolNodeItemType = RuntimeNodeItemType & {
|
||||||
toolParams: RuntimeNodeItemType['inputs'];
|
toolParams: RuntimeNodeItemType['inputs'];
|
||||||
|
|||||||
@@ -119,6 +119,31 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
...props
|
...props
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
|
// 初始化深度和自动增加深度,避免无限嵌套
|
||||||
|
if (!props.workflowDispatchDeep) {
|
||||||
|
props.workflowDispatchDeep = 1;
|
||||||
|
} else {
|
||||||
|
props.workflowDispatchDeep += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.workflowDispatchDeep > 20) {
|
||||||
|
return {
|
||||||
|
flowResponses: [],
|
||||||
|
flowUsages: [],
|
||||||
|
debugResponse: {
|
||||||
|
finishedNodes: [],
|
||||||
|
finishedEdges: [],
|
||||||
|
nextStepRunNodes: []
|
||||||
|
},
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: 1,
|
||||||
|
[DispatchNodeResponseKeyEnum.assistantResponses]: [],
|
||||||
|
[DispatchNodeResponseKeyEnum.toolResponses]: null,
|
||||||
|
newVariables: removeSystemVariable(variables)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let workflowRunTimes = 0;
|
||||||
|
|
||||||
// set sse response headers
|
// set sse response headers
|
||||||
if (stream && res) {
|
if (stream && res) {
|
||||||
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
|
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
|
||||||
@@ -154,7 +179,8 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
nodeDispatchUsages,
|
nodeDispatchUsages,
|
||||||
toolResponses,
|
toolResponses,
|
||||||
assistantResponses,
|
assistantResponses,
|
||||||
rewriteHistories
|
rewriteHistories,
|
||||||
|
runTimes = 1
|
||||||
}: Omit<
|
}: Omit<
|
||||||
DispatchNodeResultType<{
|
DispatchNodeResultType<{
|
||||||
[NodeOutputKeyEnum.answerText]?: string;
|
[NodeOutputKeyEnum.answerText]?: string;
|
||||||
@@ -163,6 +189,10 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
'nodeResponse'
|
'nodeResponse'
|
||||||
>
|
>
|
||||||
) {
|
) {
|
||||||
|
// Add run times
|
||||||
|
workflowRunTimes += runTimes;
|
||||||
|
props.maxRunTimes -= runTimes;
|
||||||
|
|
||||||
if (responseData) {
|
if (responseData) {
|
||||||
chatResponses.push(responseData);
|
chatResponses.push(responseData);
|
||||||
}
|
}
|
||||||
@@ -330,7 +360,6 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
const nodeRunResult = await (() => {
|
const nodeRunResult = await (() => {
|
||||||
if (status === 'run') {
|
if (status === 'run') {
|
||||||
nodeRunBeforeHook(node);
|
nodeRunBeforeHook(node);
|
||||||
props.maxRunTimes--;
|
|
||||||
addLog.debug(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
|
addLog.debug(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
|
||||||
return nodeRunWithActive(node);
|
return nodeRunWithActive(node);
|
||||||
}
|
}
|
||||||
@@ -565,6 +594,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
finishedEdges: runtimeEdges,
|
finishedEdges: runtimeEdges,
|
||||||
nextStepRunNodes: debugNextStepRunNodes
|
nextStepRunNodes: debugNextStepRunNodes
|
||||||
},
|
},
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: workflowRunTimes,
|
||||||
[DispatchNodeResponseKeyEnum.assistantResponses]:
|
[DispatchNodeResponseKeyEnum.assistantResponses]:
|
||||||
mergeAssistantResponseAnswerText(chatAssistantResponse),
|
mergeAssistantResponseAnswerText(chatAssistantResponse),
|
||||||
[DispatchNodeResponseKeyEnum.toolResponses]: toolRunResponse,
|
[DispatchNodeResponseKeyEnum.toolResponses]: toolRunResponse,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
|||||||
appId: String(plugin.id)
|
appId: String(plugin.id)
|
||||||
};
|
};
|
||||||
|
|
||||||
const { flowResponses, flowUsages, assistantResponses } = await dispatchWorkFlow({
|
const { flowResponses, flowUsages, assistantResponses, runTimes } = await dispatchWorkFlow({
|
||||||
...props,
|
...props,
|
||||||
runningAppInfo: {
|
runningAppInfo: {
|
||||||
id: String(plugin.id),
|
id: String(plugin.id),
|
||||||
@@ -92,6 +92,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
|||||||
return {
|
return {
|
||||||
assistantResponses,
|
assistantResponses,
|
||||||
// responseData, // debug
|
// responseData, // debug
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||||
moduleLogo: plugin.avatar,
|
moduleLogo: plugin.avatar,
|
||||||
totalPoints: usagePoints,
|
totalPoints: usagePoints,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export const dispatchRunAppNode = async (props: Props): Promise<Response> => {
|
|||||||
appId: String(appData._id)
|
appId: String(appData._id)
|
||||||
};
|
};
|
||||||
|
|
||||||
const { flowResponses, flowUsages, assistantResponses } = await dispatchWorkFlow({
|
const { flowResponses, flowUsages, assistantResponses, runTimes } = await dispatchWorkFlow({
|
||||||
...props,
|
...props,
|
||||||
runningAppInfo: {
|
runningAppInfo: {
|
||||||
id: String(appData._id),
|
id: String(appData._id),
|
||||||
@@ -107,6 +107,7 @@ export const dispatchRunAppNode = async (props: Props): Promise<Response> => {
|
|||||||
const { text } = chatValue2RuntimePrompt(assistantResponses);
|
const { text } = chatValue2RuntimePrompt(assistantResponses);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||||
moduleLogo: appData.avatar,
|
moduleLogo: appData.avatar,
|
||||||
query: userChatInput,
|
query: userChatInput,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export type DispatchFlowResponse = {
|
|||||||
};
|
};
|
||||||
[DispatchNodeResponseKeyEnum.toolResponses]: ToolRunResponseItemType;
|
[DispatchNodeResponseKeyEnum.toolResponses]: ToolRunResponseItemType;
|
||||||
[DispatchNodeResponseKeyEnum.assistantResponses]: AIChatItemValueItemType[];
|
[DispatchNodeResponseKeyEnum.assistantResponses]: AIChatItemValueItemType[];
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: number;
|
||||||
newVariables: Record<string, string>;
|
newVariables: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -90,13 +90,15 @@ export const authDatasetByTmbId = async ({
|
|||||||
const { dataset: parent } = await authDatasetByTmbId({
|
const { dataset: parent } = await authDatasetByTmbId({
|
||||||
tmbId,
|
tmbId,
|
||||||
datasetId: dataset.parentId,
|
datasetId: dataset.parentId,
|
||||||
per
|
per,
|
||||||
|
isRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
const Per = new DatasetPermission({
|
const Per = new DatasetPermission({
|
||||||
per: parent.permission.value,
|
per: parent.permission.value,
|
||||||
isOwner
|
isOwner
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Per,
|
Per,
|
||||||
defaultPermission: parent.defaultPermission
|
defaultPermission: parent.defaultPermission
|
||||||
|
|||||||
1167
pnpm-lock.yaml
generated
1167
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -36,3 +36,6 @@ HOME_URL=/
|
|||||||
# 日志等级: debug, info, warn, error
|
# 日志等级: debug, info, warn, error
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
STORE_LOG_LEVEL=warn
|
STORE_LOG_LEVEL=warn
|
||||||
|
|
||||||
|
# 工作流最大运行次数,避免极端的死循环情况
|
||||||
|
WORKFLOW_MAX_RUN_TIMES=500
|
||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
ModalBody,
|
ModalBody,
|
||||||
useDisclosure,
|
useDisclosure,
|
||||||
Image,
|
|
||||||
HStack,
|
HStack,
|
||||||
Switch,
|
Switch,
|
||||||
ModalFooter
|
ModalFooter
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ import { formatChatValue2InputType } from '../utils';
|
|||||||
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||||
import { ChatBoxContext } from '../Provider';
|
import { ChatBoxContext } from '../Provider';
|
||||||
import { useContextSelector } from 'use-context-selector';
|
import { useContextSelector } from 'use-context-selector';
|
||||||
import { SendPromptFnType } from '../type';
|
|
||||||
|
|
||||||
export type ChatControllerProps = {
|
export type ChatControllerProps = {
|
||||||
isLastChild: boolean;
|
isLastChild: boolean;
|
||||||
chat: ChatSiteItemType;
|
chat: ChatSiteItemType;
|
||||||
showVoiceIcon?: boolean;
|
showVoiceIcon?: boolean;
|
||||||
onSendMessage: SendPromptFnType;
|
|
||||||
onRetry?: () => void;
|
onRetry?: () => void;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
onMark?: () => void;
|
onMark?: () => void;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { useCopyData } from '@/web/common/hooks/useCopyData';
|
|||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { SendPromptFnType } from '../type';
|
|
||||||
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
||||||
import { CodeClassNameEnum } from '@/components/Markdown/utils';
|
import { CodeClassNameEnum } from '@/components/Markdown/utils';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
@@ -51,7 +50,6 @@ type BasicProps = {
|
|||||||
|
|
||||||
type Props = BasicProps & {
|
type Props = BasicProps & {
|
||||||
type: ChatRoleEnum.Human | ChatRoleEnum.AI;
|
type: ChatRoleEnum.Human | ChatRoleEnum.AI;
|
||||||
onSendMessage: SendPromptFnType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const RenderQuestionGuide = ({ questionGuides }: { questionGuides: string[] }) => {
|
const RenderQuestionGuide = ({ questionGuides }: { questionGuides: string[] }) => {
|
||||||
@@ -80,14 +78,12 @@ const AIContentCard = React.memo(function AIContentCard({
|
|||||||
dataId,
|
dataId,
|
||||||
isLastChild,
|
isLastChild,
|
||||||
isChatting,
|
isChatting,
|
||||||
onSendMessage,
|
|
||||||
questionGuides
|
questionGuides
|
||||||
}: {
|
}: {
|
||||||
dataId: string;
|
dataId: string;
|
||||||
chatValue: ChatItemValueItemType[];
|
chatValue: ChatItemValueItemType[];
|
||||||
isLastChild: boolean;
|
isLastChild: boolean;
|
||||||
isChatting: boolean;
|
isChatting: boolean;
|
||||||
onSendMessage: SendPromptFnType;
|
|
||||||
questionGuides: string[];
|
questionGuides: string[];
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -101,7 +97,6 @@ const AIContentCard = React.memo(function AIContentCard({
|
|||||||
value={value}
|
value={value}
|
||||||
isLastChild={isLastChild && i === chatValue.length - 1}
|
isLastChild={isLastChild && i === chatValue.length - 1}
|
||||||
isChatting={isChatting}
|
isChatting={isChatting}
|
||||||
onSendMessage={onSendMessage}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -113,16 +108,7 @@ const AIContentCard = React.memo(function AIContentCard({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const ChatItem = (props: Props) => {
|
const ChatItem = (props: Props) => {
|
||||||
const {
|
const { type, avatar, statusBoxData, children, isLastChild, questionGuides = [], chat } = props;
|
||||||
type,
|
|
||||||
avatar,
|
|
||||||
statusBoxData,
|
|
||||||
children,
|
|
||||||
isLastChild,
|
|
||||||
questionGuides = [],
|
|
||||||
onSendMessage,
|
|
||||||
chat
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
const styleMap: BoxProps =
|
const styleMap: BoxProps =
|
||||||
type === ChatRoleEnum.Human
|
type === ChatRoleEnum.Human
|
||||||
@@ -270,7 +256,6 @@ const ChatItem = (props: Props) => {
|
|||||||
dataId={chat.dataId}
|
dataId={chat.dataId}
|
||||||
isLastChild={isLastChild && i === splitAiResponseResults.length - 1}
|
isLastChild={isLastChild && i === splitAiResponseResults.length - 1}
|
||||||
isChatting={isChatting}
|
isChatting={isChatting}
|
||||||
onSendMessage={onSendMessage}
|
|
||||||
questionGuides={questionGuides}
|
questionGuides={questionGuides}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ import dynamic from 'next/dynamic';
|
|||||||
import type { StreamResponseType } from '@/web/common/api/fetch';
|
import type { StreamResponseType } from '@/web/common/api/fetch';
|
||||||
import { useContextSelector } from 'use-context-selector';
|
import { useContextSelector } from 'use-context-selector';
|
||||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||||
import { useCreation, useMemoizedFn, useThrottleFn, useTrackedEffect } from 'ahooks';
|
import { useCreation, useMemoizedFn, useThrottleFn } from 'ahooks';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
|
|
||||||
const ResponseTags = dynamic(() => import('./components/ResponseTags'));
|
const ResponseTags = dynamic(() => import('./components/ResponseTags'));
|
||||||
@@ -832,12 +832,10 @@ const ChatBox = (
|
|||||||
};
|
};
|
||||||
window.addEventListener('message', windowMessage);
|
window.addEventListener('message', windowMessage);
|
||||||
|
|
||||||
eventBus.on(EventNameEnum.sendQuestion, ({ text }: { text: string }) => {
|
const fn: SendPromptFnType = (e) => {
|
||||||
if (!text) return;
|
sendPrompt(e);
|
||||||
sendPrompt({
|
};
|
||||||
text
|
eventBus.on(EventNameEnum.sendQuestion, fn);
|
||||||
});
|
|
||||||
});
|
|
||||||
eventBus.on(EventNameEnum.editQuestion, ({ text }: { text: string }) => {
|
eventBus.on(EventNameEnum.editQuestion, ({ text }: { text: string }) => {
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
resetInputVal({ text });
|
resetInputVal({ text });
|
||||||
@@ -881,7 +879,6 @@ const ChatBox = (
|
|||||||
onRetry={retryInput(item.dataId)}
|
onRetry={retryInput(item.dataId)}
|
||||||
onDelete={delOneMessage(item.dataId)}
|
onDelete={delOneMessage(item.dataId)}
|
||||||
isLastChild={index === chatHistories.length - 1}
|
isLastChild={index === chatHistories.length - 1}
|
||||||
onSendMessage={sendPrompt}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.obj === ChatRoleEnum.AI && (
|
{item.obj === ChatRoleEnum.AI && (
|
||||||
@@ -891,7 +888,6 @@ const ChatBox = (
|
|||||||
avatar={appAvatar}
|
avatar={appAvatar}
|
||||||
chat={item}
|
chat={item}
|
||||||
isLastChild={index === chatHistories.length - 1}
|
isLastChild={index === chatHistories.length - 1}
|
||||||
onSendMessage={sendPrompt}
|
|
||||||
{...{
|
{...{
|
||||||
showVoiceIcon,
|
showVoiceIcon,
|
||||||
shareId,
|
shareId,
|
||||||
@@ -977,7 +973,6 @@ const ChatBox = (
|
|||||||
outLinkUid,
|
outLinkUid,
|
||||||
questionGuides,
|
questionGuides,
|
||||||
retryInput,
|
retryInput,
|
||||||
sendPrompt,
|
|
||||||
shareId,
|
shareId,
|
||||||
showEmpty,
|
showEmpty,
|
||||||
showMarkIcon,
|
showMarkIcon,
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { ChatSiteItemType } from '@fastgpt/global/core/chat/type';
|
|||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useRef, useState } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { PluginRunBoxTabEnum } from './PluginRunBox/constants';
|
import { PluginRunBoxTabEnum } from './PluginRunBox/constants';
|
||||||
import { ComponentRef as ChatComponentRef } from './ChatBox/type';
|
import { ComponentRef as ChatComponentRef, SendPromptFnType } from './ChatBox/type';
|
||||||
|
import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
|
||||||
|
|
||||||
export const useChat = () => {
|
export const useChat = () => {
|
||||||
const ChatBoxRef = useRef<ChatComponentRef>(null);
|
const ChatBoxRef = useRef<ChatComponentRef>(null);
|
||||||
@@ -61,3 +62,5 @@ export const useChat = () => {
|
|||||||
resetChatRecords
|
resetChatRecords
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const onSendPrompt: SendPromptFnType = (e) => eventBus.emit(EventNameEnum.sendQuestion, e);
|
||||||
|
|||||||
@@ -12,24 +12,20 @@ import {
|
|||||||
import { ChatItemValueTypeEnum } from '@fastgpt/global/core/chat/constants';
|
import { ChatItemValueTypeEnum } from '@fastgpt/global/core/chat/constants';
|
||||||
import {
|
import {
|
||||||
AIChatItemValueItemType,
|
AIChatItemValueItemType,
|
||||||
ChatSiteItemType,
|
|
||||||
ToolModuleResponseItemType,
|
ToolModuleResponseItemType,
|
||||||
UserChatItemValueItemType
|
UserChatItemValueItemType
|
||||||
} from '@fastgpt/global/core/chat/type';
|
} from '@fastgpt/global/core/chat/type';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||||
import { SendPromptFnType } from '../ChatContainer/ChatBox/type';
|
|
||||||
import { useContextSelector } from 'use-context-selector';
|
|
||||||
import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider';
|
|
||||||
import { InteractiveNodeResponseItemType } from '@fastgpt/global/core/workflow/template/system/userSelect/type';
|
import { InteractiveNodeResponseItemType } from '@fastgpt/global/core/workflow/template/system/userSelect/type';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
import { onSendPrompt } from '../ChatContainer/useChat';
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
value: UserChatItemValueItemType | AIChatItemValueItemType;
|
value: UserChatItemValueItemType | AIChatItemValueItemType;
|
||||||
isLastChild: boolean;
|
isLastChild: boolean;
|
||||||
isChatting: boolean;
|
isChatting: boolean;
|
||||||
onSendMessage?: SendPromptFnType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const RenderText = React.memo(function RenderText({
|
const RenderText = React.memo(function RenderText({
|
||||||
@@ -128,17 +124,10 @@ ${toolResponse}`}
|
|||||||
},
|
},
|
||||||
(prevProps, nextProps) => isEqual(prevProps, nextProps)
|
(prevProps, nextProps) => isEqual(prevProps, nextProps)
|
||||||
);
|
);
|
||||||
const RenderInteractive = React.memo(
|
const RenderInteractive = React.memo(function RenderInteractive({
|
||||||
function RenderInteractive({
|
interactive
|
||||||
isChatting,
|
|
||||||
interactive,
|
|
||||||
onSendMessage,
|
|
||||||
chatHistories
|
|
||||||
}: {
|
}: {
|
||||||
isChatting: boolean;
|
|
||||||
interactive: InteractiveNodeResponseItemType;
|
interactive: InteractiveNodeResponseItemType;
|
||||||
onSendMessage?: SendPromptFnType;
|
|
||||||
chatHistories: ChatSiteItemType[];
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -164,7 +153,7 @@ const RenderInteractive = React.memo(
|
|||||||
}
|
}
|
||||||
: {})}
|
: {})}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onSendMessage?.({
|
onSendPrompt({
|
||||||
text: option.value,
|
text: option.value,
|
||||||
isInteractivePrompt: true
|
isInteractivePrompt: true
|
||||||
});
|
});
|
||||||
@@ -177,18 +166,9 @@ const RenderInteractive = React.memo(
|
|||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
(
|
|
||||||
prevProps,
|
|
||||||
nextProps // isChatting 更新时候,onSendMessage 和 chatHistories 肯定都更新了,这里不需要额外的刷新
|
|
||||||
) =>
|
|
||||||
prevProps.isChatting === nextProps.isChatting &&
|
|
||||||
isEqual(prevProps.interactive, nextProps.interactive)
|
|
||||||
);
|
|
||||||
|
|
||||||
const AIResponseBox = ({ value, isLastChild, isChatting, onSendMessage }: props) => {
|
|
||||||
const chatHistories = useContextSelector(ChatBoxContext, (v) => v.chatHistories);
|
|
||||||
|
|
||||||
|
const AIResponseBox = ({ value, isLastChild, isChatting }: props) => {
|
||||||
if (value.type === ChatItemValueTypeEnum.text && value.text)
|
if (value.type === ChatItemValueTypeEnum.text && value.text)
|
||||||
return <RenderText showAnimation={isChatting && isLastChild} text={value.text.content} />;
|
return <RenderText showAnimation={isChatting && isLastChild} text={value.text.content} />;
|
||||||
if (value.type === ChatItemValueTypeEnum.tool && value.tools)
|
if (value.type === ChatItemValueTypeEnum.tool && value.tools)
|
||||||
@@ -198,14 +178,7 @@ const AIResponseBox = ({ value, isLastChild, isChatting, onSendMessage }: props)
|
|||||||
value.interactive &&
|
value.interactive &&
|
||||||
value.interactive.type === 'userSelect'
|
value.interactive.type === 'userSelect'
|
||||||
)
|
)
|
||||||
return (
|
return <RenderInteractive interactive={value.interactive} />;
|
||||||
<RenderInteractive
|
|
||||||
isChatting={isChatting}
|
|
||||||
interactive={value.interactive}
|
|
||||||
onSendMessage={onSendMessage}
|
|
||||||
chatHistories={chatHistories}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(AIResponseBox);
|
export default React.memo(AIResponseBox);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ const QRCodePayModal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
|
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
|
||||||
<ModalBody textAlign={'center'} py={6} whiteSpace={'pre'}>
|
<ModalBody textAlign={'center'} py={6} whiteSpace={'pre-wrap'}>
|
||||||
{tip && (
|
{tip && (
|
||||||
<Box fontSize={'sm'} whiteSpace={'pre'} mb={3}>
|
<Box fontSize={'sm'} whiteSpace={'pre'} mb={3}>
|
||||||
{tip}
|
{tip}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import {
|
|||||||
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
||||||
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
||||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
messages: ChatCompletionMessageParam[];
|
messages: ChatCompletionMessageParam[];
|
||||||
@@ -120,7 +121,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
chatConfig,
|
chatConfig,
|
||||||
histories: chatMessages,
|
histories: chatMessages,
|
||||||
stream: true,
|
stream: true,
|
||||||
maxRunTimes: 200,
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES,
|
||||||
workflowStreamResponse: workflowResponseWrite
|
workflowStreamResponse: workflowResponseWrite
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,7 @@ async function handler(req: NextApiRequest): Promise<DatasetSimpleItemType[]> {
|
|||||||
|
|
||||||
const [myDatasets, rpList] = await Promise.all([
|
const [myDatasets, rpList] = await Promise.all([
|
||||||
MongoDataset.find({
|
MongoDataset.find({
|
||||||
teamId,
|
teamId
|
||||||
type: {
|
|
||||||
$ne: DatasetTypeEnum.folder
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.sort({
|
.sort({
|
||||||
updateTime: -1
|
updateTime: -1
|
||||||
@@ -45,9 +42,29 @@ async function handler(req: NextApiRequest): Promise<DatasetSimpleItemType[]> {
|
|||||||
|
|
||||||
const filterDatasets = myDatasets
|
const filterDatasets = myDatasets
|
||||||
.map((dataset) => {
|
.map((dataset) => {
|
||||||
|
const perVal = (() => {
|
||||||
const perVal = rpList.find(
|
const perVal = rpList.find(
|
||||||
(item) => String(item.resourceId) === String(dataset._id)
|
(item) => String(item.resourceId) === String(dataset._id)
|
||||||
)?.permission;
|
)?.permission;
|
||||||
|
if (perVal) {
|
||||||
|
return perVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataset.inheritPermission && dataset.parentId) {
|
||||||
|
const parentDataset = myDatasets.find(
|
||||||
|
(item) => String(item._id) === String(dataset.parentId)
|
||||||
|
);
|
||||||
|
if (parentDataset) {
|
||||||
|
const parentPerVal =
|
||||||
|
rpList.find((item) => String(item.resourceId) === String(parentDataset._id))
|
||||||
|
?.permission ?? parentDataset.defaultPermission;
|
||||||
|
if (parentPerVal) {
|
||||||
|
return parentPerVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const Per = new DatasetPermission({
|
const Per = new DatasetPermission({
|
||||||
per: perVal ?? dataset.defaultPermission,
|
per: perVal ?? dataset.defaultPermission,
|
||||||
isOwner: String(dataset.tmbId) === tmbId || tmbPer.isOwner
|
isOwner: String(dataset.tmbId) === tmbId || tmbPer.isOwner
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { PostWorkflowDebugProps, PostWorkflowDebugResponse } from '@/global/core
|
|||||||
import { NextAPI } from '@/service/middleware/entry';
|
import { NextAPI } from '@/service/middleware/entry';
|
||||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||||
import { defaultApp } from '@/web/core/app/constants';
|
import { defaultApp } from '@/web/core/app/constants';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
|
|
||||||
async function handler(
|
async function handler(
|
||||||
req: NextApiRequest,
|
req: NextApiRequest,
|
||||||
@@ -57,7 +58,7 @@ async function handler(
|
|||||||
chatConfig: defaultApp.chatConfig,
|
chatConfig: defaultApp.chatConfig,
|
||||||
histories: [],
|
histories: [],
|
||||||
stream: false,
|
stream: false,
|
||||||
maxRunTimes: 200
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES
|
||||||
});
|
});
|
||||||
|
|
||||||
pushChatUsage({
|
pushChatUsage({
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import { getSystemTime } from '@fastgpt/global/common/time/timezone';
|
|||||||
import { rewriteNodeOutputByHistories } from '@fastgpt/global/core/workflow/runtime/utils';
|
import { rewriteNodeOutputByHistories } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||||
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
||||||
import { getPluginRunUserQuery } from '@fastgpt/service/core/workflow/utils';
|
import { getPluginRunUserQuery } from '@fastgpt/service/core/workflow/utils';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
|
|
||||||
type FastGptWebChatProps = {
|
type FastGptWebChatProps = {
|
||||||
chatId?: string; // undefined: get histories from messages, '': new chat, 'xxxxx': get histories from db
|
chatId?: string; // undefined: get histories from messages, '': new chat, 'xxxxx': get histories from db
|
||||||
@@ -264,7 +265,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
chatConfig,
|
chatConfig,
|
||||||
histories: newHistories,
|
histories: newHistories,
|
||||||
stream,
|
stream,
|
||||||
maxRunTimes: 200,
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES,
|
||||||
workflowStreamResponse: workflowResponseWrite
|
workflowStreamResponse: workflowResponseWrite
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
HStack
|
HStack
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { SmallAddIcon } from '@chakra-ui/icons';
|
import { SmallAddIcon } from '@chakra-ui/icons';
|
||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
|
||||||
import type { AppSimpleEditFormType } from '@fastgpt/global/core/app/type.d';
|
import type { AppSimpleEditFormType } from '@fastgpt/global/core/app/type.d';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
@@ -79,7 +78,6 @@ const EditForm = ({
|
|||||||
const { appDetail } = useContextSelector(AppContext, (v) => v);
|
const { appDetail } = useContextSelector(AppContext, (v) => v);
|
||||||
|
|
||||||
const { allDatasets } = useDatasetStore();
|
const { allDatasets } = useDatasetStore();
|
||||||
const { llmModelList } = useSystemStore();
|
|
||||||
const [, startTst] = useTransition();
|
const [, startTst] = useTransition();
|
||||||
|
|
||||||
const selectDatasets = useMemo(
|
const selectDatasets = useMemo(
|
||||||
@@ -506,6 +504,8 @@ const EditForm = ({
|
|||||||
...e
|
...e
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
console.dir(e);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const NodePluginConfig = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
debug: true,
|
debug: true,
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ const NodePluginInput = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
minW={'300px'}
|
minW={'300px'}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ const NodePluginOutput = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
debug: true,
|
debug: true,
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const NodeUserGuide = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
debug: true,
|
debug: true,
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ const NodeStart = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
minW={'240px'}
|
minW={'240px'}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -11,16 +11,17 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
||||||
const edges = useContextSelector(WorkflowContext, (v) => v.edges);
|
const edges = useContextSelector(WorkflowContext, (v) => v.edges);
|
||||||
|
|
||||||
const node = useMemo(() => nodeList.find((node) => node.nodeId === nodeId), [nodeList, nodeId]);
|
const { showSourceHandle, RightHandle, LeftHandlee, TopHandlee, BottomHandlee } = useMemo(() => {
|
||||||
|
const node = nodeList.find((node) => node.nodeId === nodeId);
|
||||||
|
|
||||||
/* not node/not connecting node, hidden */
|
/* not node/not connecting node, hidden */
|
||||||
const showSourceHandle = useMemo(() => {
|
const showSourceHandle = (() => {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
if (connectingEdge && connectingEdge.nodeId !== nodeId) return false;
|
if (connectingEdge && connectingEdge.nodeId !== nodeId) return false;
|
||||||
return true;
|
return true;
|
||||||
}, [connectingEdge, node, nodeId]);
|
})();
|
||||||
|
|
||||||
const RightHandle = useMemo(() => {
|
const RightHandle = (() => {
|
||||||
const handleId = getHandleId(nodeId, 'source', Position.Right);
|
const handleId = getHandleId(nodeId, 'source', Position.Right);
|
||||||
const rightTargetConnected = edges.some(
|
const rightTargetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Right)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Right)
|
||||||
@@ -36,8 +37,8 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[2, 0]}
|
translate={[2, 0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
const LeftHandlee = useMemo(() => {
|
const LeftHandlee = (() => {
|
||||||
const leftTargetConnected = edges.some(
|
const leftTargetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Left)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Left)
|
||||||
);
|
);
|
||||||
@@ -53,8 +54,8 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[-6, 0]}
|
translate={[-6, 0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
const TopHandlee = useMemo(() => {
|
const TopHandlee = (() => {
|
||||||
if (
|
if (
|
||||||
edges.some(
|
edges.some(
|
||||||
(edge) => edge.target === nodeId && edge.targetHandle === NodeOutputKeyEnum.selectedTools
|
(edge) => edge.target === nodeId && edge.targetHandle === NodeOutputKeyEnum.selectedTools
|
||||||
@@ -76,8 +77,8 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[0, -2]}
|
translate={[0, -2]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
const BottomHandlee = useMemo(() => {
|
const BottomHandlee = (() => {
|
||||||
const handleId = getHandleId(nodeId, 'source', Position.Bottom);
|
const handleId = getHandleId(nodeId, 'source', Position.Bottom);
|
||||||
const targetConnected = edges.some(
|
const targetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Bottom)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Bottom)
|
||||||
@@ -92,7 +93,16 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[0, 2]}
|
translate={[0, 2]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
|
|
||||||
|
return {
|
||||||
|
showSourceHandle,
|
||||||
|
RightHandle,
|
||||||
|
LeftHandlee,
|
||||||
|
TopHandlee,
|
||||||
|
BottomHandlee
|
||||||
|
};
|
||||||
|
}, [connectingEdge, edges, nodeId, nodeList]);
|
||||||
|
|
||||||
return showSourceHandle ? (
|
return showSourceHandle ? (
|
||||||
<>
|
<>
|
||||||
@@ -104,19 +114,32 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
export const ConnectionTargetHandle = React.memo(function ConnectionTargetHandle({
|
||||||
|
nodeId
|
||||||
|
}: {
|
||||||
|
nodeId: string;
|
||||||
|
}) {
|
||||||
const connectingEdge = useContextSelector(WorkflowContext, (ctx) => ctx.connectingEdge);
|
const connectingEdge = useContextSelector(WorkflowContext, (ctx) => ctx.connectingEdge);
|
||||||
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
||||||
|
const edges = useContextSelector(WorkflowContext, (v) => v.edges);
|
||||||
|
|
||||||
const node = useMemo(() => nodeList.find((node) => node.nodeId === nodeId), [nodeList, nodeId]);
|
const { showHandle, LeftHandle, rightHandle, topHandle, bottomHandle } = useMemo(() => {
|
||||||
|
const node = nodeList.find((node) => node.nodeId === nodeId);
|
||||||
|
const connectingNode = nodeList.find((node) => node.nodeId === connectingEdge?.nodeId);
|
||||||
|
|
||||||
const showHandle = useMemo(() => {
|
const sourceEdges = edges.filter((edge) => edge.target === connectingNode?.nodeId);
|
||||||
|
const connectingNodeSourceNodeIds = sourceEdges.map((edge) => edge.source);
|
||||||
|
|
||||||
|
const showHandle = (() => {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
|
// Unable to connect oneself
|
||||||
if (connectingEdge && connectingEdge.nodeId === nodeId) return false;
|
if (connectingEdge && connectingEdge.nodeId === nodeId) return false;
|
||||||
|
// Unable to connect to the source node
|
||||||
|
if (connectingNodeSourceNodeIds.includes(nodeId)) return false;
|
||||||
return true;
|
return true;
|
||||||
}, [connectingEdge, node, nodeId]);
|
})();
|
||||||
|
|
||||||
const LeftHandle = useMemo(() => {
|
const LeftHandle = (() => {
|
||||||
if (!node || !node?.targetHandle?.left) return null;
|
if (!node || !node?.targetHandle?.left) return null;
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Left);
|
const handleId = getHandleId(nodeId, 'target', Position.Left);
|
||||||
@@ -129,8 +152,8 @@ export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[-2, 0]}
|
translate={[-2, 0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [node, nodeId]);
|
})();
|
||||||
const rightHandle = useMemo(() => {
|
const rightHandle = (() => {
|
||||||
if (!node || !node?.targetHandle?.right) return null;
|
if (!node || !node?.targetHandle?.right) return null;
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Right);
|
const handleId = getHandleId(nodeId, 'target', Position.Right);
|
||||||
@@ -143,8 +166,8 @@ export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[2, 0]}
|
translate={[2, 0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [node, nodeId]);
|
})();
|
||||||
const topHandle = useMemo(() => {
|
const topHandle = (() => {
|
||||||
if (!node || !node?.targetHandle?.top) return null;
|
if (!node || !node?.targetHandle?.top) return null;
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Top);
|
const handleId = getHandleId(nodeId, 'target', Position.Top);
|
||||||
@@ -157,8 +180,8 @@ export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[0, -2]}
|
translate={[0, -2]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [node, nodeId]);
|
})();
|
||||||
const bottomHandle = useMemo(() => {
|
const bottomHandle = (() => {
|
||||||
if (!node || !node?.targetHandle?.bottom) return null;
|
if (!node || !node?.targetHandle?.bottom) return null;
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Bottom);
|
const handleId = getHandleId(nodeId, 'target', Position.Bottom);
|
||||||
@@ -171,7 +194,16 @@ export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
translate={[0, 2]}
|
translate={[0, 2]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [node, nodeId]);
|
})();
|
||||||
|
|
||||||
|
return {
|
||||||
|
showHandle,
|
||||||
|
LeftHandle,
|
||||||
|
rightHandle,
|
||||||
|
topHandle,
|
||||||
|
bottomHandle
|
||||||
|
};
|
||||||
|
}, [connectingEdge, edges, nodeId, nodeList]);
|
||||||
|
|
||||||
return showHandle ? (
|
return showHandle ? (
|
||||||
<>
|
<>
|
||||||
@@ -181,7 +213,7 @@ export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
{bottomHandle}
|
{bottomHandle}
|
||||||
</>
|
</>
|
||||||
) : null;
|
) : null;
|
||||||
};
|
});
|
||||||
|
|
||||||
export default function Dom() {
|
export default function Dom() {
|
||||||
return <></>;
|
return <></>;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ type Props = FlowNodeItemType & {
|
|||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
menuForbid?: {
|
menuForbid?: {
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
rename?: boolean;
|
|
||||||
copy?: boolean;
|
copy?: boolean;
|
||||||
delete?: boolean;
|
delete?: boolean;
|
||||||
};
|
};
|
||||||
@@ -154,7 +153,6 @@ const NodeCard = (props: Props) => {
|
|||||||
<Box ml={3} fontSize={'md'} fontWeight={'medium'}>
|
<Box ml={3} fontSize={'md'} fontWeight={'medium'}>
|
||||||
{t(name as any)}
|
{t(name as any)}
|
||||||
</Box>
|
</Box>
|
||||||
{!menuForbid?.rename && (
|
|
||||||
<MyIcon
|
<MyIcon
|
||||||
className="controller-rename"
|
className="controller-rename"
|
||||||
display={'none'}
|
display={'none'}
|
||||||
@@ -184,7 +182,6 @@ const NodeCard = (props: Props) => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
<Box flex={1} />
|
<Box flex={1} />
|
||||||
{hasNewVersion && (
|
{hasNewVersion && (
|
||||||
<MyTooltip label={t('app:app.modules.click to update')}>
|
<MyTooltip label={t('app:app.modules.click to update')}>
|
||||||
@@ -248,6 +245,14 @@ const NodeCard = (props: Props) => {
|
|||||||
onChangeNode,
|
onChangeNode,
|
||||||
toast
|
toast
|
||||||
]);
|
]);
|
||||||
|
const RenderHandle = useMemo(() => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ConnectionSourceHandle nodeId={nodeId} />
|
||||||
|
<ConnectionTargetHandle nodeId={nodeId} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}, [nodeId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -283,8 +288,7 @@ const NodeCard = (props: Props) => {
|
|||||||
<NodeDebugResponse nodeId={nodeId} debugResult={debugResult} />
|
<NodeDebugResponse nodeId={nodeId} debugResult={debugResult} />
|
||||||
{Header}
|
{Header}
|
||||||
{children}
|
{children}
|
||||||
<ConnectionSourceHandle nodeId={nodeId} />
|
{RenderHandle}
|
||||||
<ConnectionTargetHandle nodeId={nodeId} />
|
|
||||||
|
|
||||||
<EditTitleModal maxLength={20} />
|
<EditTitleModal maxLength={20} />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -130,7 +130,6 @@ const Chat = ({
|
|||||||
const completionChatId = chatId || getNanoid();
|
const completionChatId = chatId || getNanoid();
|
||||||
// Just send a user prompt
|
// Just send a user prompt
|
||||||
const histories = messages.slice(-1);
|
const histories = messages.slice(-1);
|
||||||
|
|
||||||
const { responseText, responseData } = await streamFetch({
|
const { responseText, responseData } = await streamFetch({
|
||||||
data: {
|
data: {
|
||||||
messages: histories,
|
messages: histories,
|
||||||
@@ -146,11 +145,9 @@ const Chat = ({
|
|||||||
const newTitle = getChatTitleFromChatMessage(GPTMessages2Chats(histories)[0]);
|
const newTitle = getChatTitleFromChatMessage(GPTMessages2Chats(histories)[0]);
|
||||||
|
|
||||||
// new chat
|
// new chat
|
||||||
if (completionChatId !== chatId) {
|
if (completionChatId !== chatId && controller.signal.reason !== 'leave') {
|
||||||
if (controller.signal.reason !== 'leave') {
|
|
||||||
onChangeChatId(completionChatId, true);
|
onChangeChatId(completionChatId, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
loadHistories();
|
loadHistories();
|
||||||
|
|
||||||
// update chat window
|
// update chat window
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import type { ResLogin } from '@/global/support/api/userRes.d';
|
import type { ResLogin } from '@/global/support/api/userRes.d';
|
||||||
import { useChatStore } from '@/web/core/chat/context/storeChat';
|
import { useChatStore } from '@/web/core/chat/context/storeChat';
|
||||||
@@ -35,9 +35,6 @@ const provider = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleSSO = useCallback(async () => {
|
const handleSSO = useCallback(async () => {
|
||||||
if (isOauthLogging) return;
|
|
||||||
isOauthLogging = true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await ssoLogin(query);
|
const res = await ssoLogin(query);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
||||||
import { addLog } from '@fastgpt/service/common/system/log';
|
import { addLog } from '@fastgpt/service/common/system/log';
|
||||||
import { MongoApp } from '@fastgpt/service/core/app/schema';
|
import { MongoApp } from '@fastgpt/service/core/app/schema';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
|
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
|
||||||
|
|
||||||
export const getScheduleTriggerApp = async () => {
|
export const getScheduleTriggerApp = async () => {
|
||||||
@@ -55,7 +56,7 @@ export const getScheduleTriggerApp = async () => {
|
|||||||
chatConfig: defaultApp.chatConfig,
|
chatConfig: defaultApp.chatConfig,
|
||||||
histories: [],
|
histories: [],
|
||||||
stream: false,
|
stream: false,
|
||||||
maxRunTimes: 200
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES
|
||||||
});
|
});
|
||||||
pushChatUsage({
|
pushChatUsage({
|
||||||
appName: app.name,
|
appName: app.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user