From 2ba711ac2f83b85e1131407ee02951c21c6c05a7 Mon Sep 17 00:00:00 2001 From: Ben Gao Date: Tue, 4 Mar 2025 13:01:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=8B=E5=BA=8Fapi=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=A4=A7?= =?UTF-8?q?=E9=87=8F=E8=B0=83=E7=94=A8=E5=B8=A6=E6=9C=89=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=88=96=E8=A7=86=E9=A2=91=EF=BC=8C=E4=BA=A7=E7=94=9F=E7=9A=84?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95=E4=BC=9A=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=90=8E=E5=8F=B0mongo=E6=95=B0=E6=8D=AE=E5=BA=93=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E3=80=82=E8=BF=99=E4=B8=AA=E4=BF=AE=E6=94=B9=E7=BB=99?= =?UTF-8?q?api=E5=AE=A2=E6=88=B7=E7=AB=AF=E4=B8=80=E4=B8=AA=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E7=94=9F=E6=88=90=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E9=80=89=E9=A1=B9=EF=BC=8C=E9=81=BF=E5=85=8D=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E5=90=8E=E6=9E=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/service/core/chat/saveChat.ts | 2 ++ projects/app/src/pages/api/v1/chat/completions.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/service/core/chat/saveChat.ts b/packages/service/core/chat/saveChat.ts index 48bbcc8f4774..ddbed962f17c 100644 --- a/packages/service/core/chat/saveChat.ts +++ b/packages/service/core/chat/saveChat.ts @@ -51,6 +51,8 @@ export async function saveChat({ content, metadata = {} }: Props) { + if (!chatId) return; + try { const chat = await MongoChat.findOne( { diff --git a/projects/app/src/pages/api/v1/chat/completions.ts b/projects/app/src/pages/api/v1/chat/completions.ts index 5657a2783da5..aeea7dcbd506 100644 --- a/projects/app/src/pages/api/v1/chat/completions.ts +++ b/projects/app/src/pages/api/v1/chat/completions.ts @@ -330,7 +330,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { [DispatchNodeResponseKeyEnum.nodeResponse]: flowResponses }; - const saveChatId = chatId || getNanoid(24); + const saveChatId = chatId === 'no-history-sT$hjq*K!vmx' ? '' : chatId || getNanoid(24); if (isInteractiveRequest) { await updateInteractiveChat({ chatId: saveChatId,