From a63467d75154a386b37e93154974fff6a84e6143 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Thu, 21 Mar 2024 19:48:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BB=BA=E8=AE=AE=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=EF=BC=9B=E4=BF=AE=E5=A4=8D=E5=A4=9A=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E8=AE=AD=E7=BB=83=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=20(#1043?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc * Optimize possible null Pointers and parts of Ux * fix: mulity index training error --- .github/ISSUE_TEMPLATE/config.yml | 2 +- .../core/dataset/training/controller.ts | 1 - .../dispatch/agent/runTool/promptCall.ts | 20 +- .../dispatch/agent/runTool/toolChoice.ts | 6 +- projects/app/public/locales/en/common.json | 1 + projects/app/public/locales/zh/common.json | 1 + .../app/src/pages/account/components/Info.tsx | 10 +- .../pages/account/components/InformTable.tsx | 4 +- .../components/SimpleEdit/ToolSelectModal.tsx | 3 +- .../service/core/dataset/data/controller.ts | 3 +- projects/app/src/web/core/app/utils.ts | 384 +++++++++++++++++- 11 files changed, 407 insertions(+), 28 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 1cedc8a78..2990e6328 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - name: 微信交流群 - url: https://doc.fastgpt.in/wechat-fastgpt.webp + url: https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg about: FastGPT 全是问题群 diff --git a/packages/service/core/dataset/training/controller.ts b/packages/service/core/dataset/training/controller.ts index 612202454..39f0d532b 100644 --- a/packages/service/core/dataset/training/controller.ts +++ b/packages/service/core/dataset/training/controller.ts @@ -9,7 +9,6 @@ import { getCollectionWithDataset } from '../controller'; import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants'; import { simpleText } from '@fastgpt/global/common/string/tools'; import { countPromptTokens } from '@fastgpt/global/common/string/tiktoken'; -import type { VectorModelItemType, LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; export const lockTrainingDataByTeamId = async (teamId: string): Promise => { try { diff --git a/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts b/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts index 9c9f5942a..02ffddcbb 100644 --- a/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts +++ b/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts @@ -164,6 +164,15 @@ export const runToolWithPromptCall = async ( parseAnswerResult.toolName = toolModule.name; parseAnswerResult.toolAvatar = toolModule.avatar; + // run tool flow + const startParams = (() => { + try { + return json5.parse(parseAnswerResult.arguments); + } catch (error) { + return {}; + } + })(); + // SSE response to client if (stream && detail) { responseWrite({ @@ -182,15 +191,6 @@ export const runToolWithPromptCall = async ( }); } - // run tool flow - const startParams = (() => { - try { - return json5.parse(parseAnswerResult.arguments); - } catch (error) { - return {}; - } - })(); - const moduleRunResponse = await dispatchWorkFlow({ ...props, runtimeModules: runtimeModules.map((module) => ({ @@ -374,7 +374,7 @@ const parseAnswer = (str: string): FunctionCallCompletion | string => { return { id: getNanoid(), name: toolCall.toolId, - arguments: JSON.stringify(toolCall.arguments) + arguments: JSON.stringify(toolCall.arguments || toolCall.parameters) }; } catch (error) { return str; diff --git a/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts b/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts index c2b4e0192..d84936353 100644 --- a/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts +++ b/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts @@ -332,8 +332,8 @@ async function streamResponse({ const responseChoice = part.choices?.[0]?.delta; // console.log(JSON.stringify(responseChoice, null, 2)); - if (responseChoice.content) { - const content = responseChoice?.content || ''; + if (responseChoice?.content) { + const content = responseChoice.content || ''; textAnswer += content; responseWrite({ @@ -343,7 +343,7 @@ async function streamResponse({ text: content }) }); - } else if (responseChoice.tool_calls?.[0]) { + } else if (responseChoice?.tool_calls?.[0]) { const toolCall: ChatCompletionMessageToolCall = responseChoice.tool_calls[0]; // 流响应中,每次只会返回一个工具. 如果带了 id,说明是执行一个工具 diff --git a/projects/app/public/locales/en/common.json b/projects/app/public/locales/en/common.json index 1f146cc65..c66a70b50 100644 --- a/projects/app/public/locales/en/common.json +++ b/projects/app/public/locales/en/common.json @@ -1334,6 +1334,7 @@ "Not sufficient": "Your AI points are insufficient, please upgrade the package or purchase additional AI points before continuing to use.", "Pay error": "Pay error", "Pay success": "Pay success", + "Plan expired time": "Plan expired time", "Standard Plan Detail": "Standard Plan Detail", "To read plan": "Read plan", "bill": { diff --git a/projects/app/public/locales/zh/common.json b/projects/app/public/locales/zh/common.json index dcd232e38..aafe31860 100644 --- a/projects/app/public/locales/zh/common.json +++ b/projects/app/public/locales/zh/common.json @@ -1336,6 +1336,7 @@ "Not sufficient": "您的 AI 积分不足,请先升级套餐或购买额外 AI 积分后继续使用。", "Pay error": "支付失败", "Pay success": "支付成功", + "Plan expired time": "套餐到期时间", "Standard Plan Detail": "套餐详情", "To read plan": "查看套餐", "bill": { diff --git a/projects/app/src/pages/account/components/Info.tsx b/projects/app/src/pages/account/components/Info.tsx index 659b9e50d..0eccb9df1 100644 --- a/projects/app/src/pages/account/components/Info.tsx +++ b/projects/app/src/pages/account/components/Info.tsx @@ -397,15 +397,15 @@ const PlanUsage = () => { {t(planName)} + + {t('support.wallet.Plan expired time')}: + {formatTime2YMD(standardPlan?.expiredTime)} + {isFreeTeam && ( - + 免费版用户15天无任何使用记录时,系统会自动清理账号知识库。 )} - - {t('common.Expired Time')}: - {formatTime2YMD(standardPlan?.expiredTime)} -