From e8581c8f3ce9d72296abec1c5a2c002e3679723c Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Wed, 25 Sep 2024 00:37:37 +0800 Subject: [PATCH] fix: prevent title update on invalid message response --- app/store/chat.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/store/chat.ts b/app/store/chat.ts index 86de99836..968d8cb64 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -615,6 +615,7 @@ export const useChatStore = createPersistStore( providerName, }, onFinish(message) { + if (!isValidMessage(message)) return; get().updateCurrentSession( (session) => (session.topic = @@ -690,6 +691,10 @@ export const useChatStore = createPersistStore( }, }); } + + function isValidMessage(message: any): boolean { + return typeof message === "string" && !message.startsWith("```json"); + } }, updateStat(message: ChatMessage) {