Skip to content

Commit 4c84182

Browse files
authored
Merge pull request ChatGPTNextWeb#5522 from ConnectAI-E/fix/5494
fix: prevent title update on invalid message response
2 parents 9bbd7d3 + e8581c8 commit 4c84182

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/store/chat.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ export const useChatStore = createPersistStore(
615615
providerName,
616616
},
617617
onFinish(message) {
618+
if (!isValidMessage(message)) return;
618619
get().updateCurrentSession(
619620
(session) =>
620621
(session.topic =
@@ -690,6 +691,10 @@ export const useChatStore = createPersistStore(
690691
},
691692
});
692693
}
694+
695+
function isValidMessage(message: any): boolean {
696+
return typeof message === "string" && !message.startsWith("```json");
697+
}
693698
},
694699

695700
updateStat(message: ChatMessage) {

0 commit comments

Comments
 (0)