From d0cc043ad83a1df9be0a8312c7ec151c993c4f19 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Thu, 25 Jul 2024 19:22:43 +0800 Subject: [PATCH] perf: rename variable --- .../zh-cn/docs/development/upgrading/488.md | 22 ++++++++++--------- packages/global/core/workflow/utils.ts | 2 +- packages/service/common/mongo/init.ts | 11 +++++++--- .../app/src/pages/api/core/chat/chatTest.ts | 4 ++-- .../app/src/pages/api/v1/chat/completions.ts | 4 ++-- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docSite/content/zh-cn/docs/development/upgrading/488.md b/docSite/content/zh-cn/docs/development/upgrading/488.md index 192b2b41f498..699997344f75 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/488.md +++ b/docSite/content/zh-cn/docs/development/upgrading/488.md @@ -24,13 +24,15 @@ weight: 816 2. 新增 - DuckDuckGo 系统插件。 3. 新增 - 飞书 webhook 系统插件。 4. 新增 - 修改变量填写方式。提示词输入框以以及工作流中所有 Textarea 输入框,支持输入 / 唤起变量选择,可直接选择所有上游输出值,无需动态引入。 -5. 优化 - 移动端快速切换应用交互。 -6. 优化 - 节点图标。 -7. 优化 - 对话框引用增加额外复制案件,便于复制。增加引用内容折叠。 -8. 优化 - 对话框底部增加复制,简便复制交互,无需滚动到消息开头。 -9. 优化 - OpenAI sdk 升级,并自定义了 whisper 模型接口(未仔细查看 sdk 实现,但 sdk 中 whisper 接口,似乎无法适配一般 fastapi 接口) -10. 修复 - Permission 表声明问题。 -11. 修复 - 并行执行节点,运行时间未正确记录。 -12. 修复 - 简易模式,首次进入,无法正确获取知识库配置。 -13. 修复 - Log debug level 配置无效。 -14. 修复 - 插件独立运行时,会将插件输入的值进行变量替换,可能导致后续节点变量异常。 \ No newline at end of file +5. 商业版新增 - 知识库权限继承。 +6. 优化 - 移动端快速切换应用交互。 +7. 优化 - 节点图标。 +8. 优化 - 对话框引用增加额外复制案件,便于复制。增加引用内容折叠。 +9. 优化 - 对话框底部增加复制,简便复制交互,无需滚动到消息开头。 +10. 优化 - OpenAI sdk 升级,并自定义了 whisper 模型接口(未仔细查看 sdk 实现,但 sdk 中 whisper 接口,似乎无法适配一般 fastapi 接口) +11. 修复 - Permission 表声明问题。 +12. 修复 - 并行执行节点,运行时间未正确记录。 +13. 修复 - 运行详情未正确展示嵌套节点信息。 +14. 修复 - 简易模式,首次进入,无法正确获取知识库配置。 +15. 修复 - Log debug level 配置无效。 +16. 修复 - 插件独立运行时,会将插件输入的值进行变量替换,可能导致后续节点变量异常。 \ No newline at end of file diff --git a/packages/global/core/workflow/utils.ts b/packages/global/core/workflow/utils.ts index 07b69d98a958..718f1261feca 100644 --- a/packages/global/core/workflow/utils.ts +++ b/packages/global/core/workflow/utils.ts @@ -229,7 +229,7 @@ export const updatePluginInputByVariables = ( ); }; -export const filterPluginInputVariables = ( +export const removePluginInputVariables = ( variables: Record, nodes: RuntimeNodeItemType[] ) => { diff --git a/packages/service/common/mongo/init.ts b/packages/service/common/mongo/init.ts index dcd3daf49c36..e5c4850b7eeb 100644 --- a/packages/service/common/mongo/init.ts +++ b/packages/service/common/mongo/init.ts @@ -1,3 +1,4 @@ +import { delay } from '@fastgpt/global/common/system/utils'; import { addLog } from '../system/log'; import { connectionMongo } from './index'; import type { Mongoose } from 'mongoose'; @@ -17,9 +18,11 @@ export async function connectMongo(): Promise { try { connectionMongo.set('strictQuery', true); - connectionMongo.connection.on('error', (error) => { + connectionMongo.connection.on('error', async (error) => { console.log('mongo error', error); - connectionMongo.disconnect(); + await connectionMongo.disconnect(); + await delay(1000); + connectMongo(); }); connectionMongo.connection.on('disconnected', () => { console.log('mongo disconnected'); @@ -44,8 +47,10 @@ export async function connectMongo(): Promise { console.log('mongo connected'); } catch (error) { - connectionMongo.disconnect(); addLog.error('mongo connect error', error); + await connectionMongo.disconnect(); + await delay(1000); + connectMongo(); } return connectionMongo; diff --git a/projects/app/src/pages/api/core/chat/chatTest.ts b/projects/app/src/pages/api/core/chat/chatTest.ts index b7ecd2dd8de4..6556b22b2126 100644 --- a/projects/app/src/pages/api/core/chat/chatTest.ts +++ b/projects/app/src/pages/api/core/chat/chatTest.ts @@ -15,7 +15,7 @@ import { removeEmptyUserInput } from '@fastgpt/global/core/chat/utils'; import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { - filterPluginInputVariables, + removePluginInputVariables, updatePluginInputByVariables } from '@fastgpt/global/core/workflow/utils'; import { NextAPI } from '@/service/middleware/entry'; @@ -66,7 +66,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { // Plugin need to replace inputs if (isPlugin) { nodes = updatePluginInputByVariables(nodes, variables); - variables = filterPluginInputVariables(variables, nodes); + variables = removePluginInputVariables(variables, nodes); } else { if (!userInput) { throw new Error('Params Error'); diff --git a/projects/app/src/pages/api/v1/chat/completions.ts b/projects/app/src/pages/api/v1/chat/completions.ts index a510d1336c4b..b002ed04f427 100644 --- a/projects/app/src/pages/api/v1/chat/completions.ts +++ b/projects/app/src/pages/api/v1/chat/completions.ts @@ -55,7 +55,7 @@ import { getAppLatestVersion } from '@fastgpt/service/core/app/controller'; import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { - filterPluginInputVariables, + removePluginInputVariables, updatePluginInputByVariables } from '@fastgpt/global/core/workflow/utils'; import { getNanoid } from '@fastgpt/global/common/string/tools'; @@ -238,7 +238,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { ) : storeNodes2RuntimeNodes(nodes, getDefaultEntryNodeIds(nodes)); - const runtimeVariables = filterPluginInputVariables( + const runtimeVariables = removePluginInputVariables( variables, storeNodes2RuntimeNodes(nodes, getDefaultEntryNodeIds(nodes)) );