Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#5522 from ConnectAI-E/fix/5494
Browse files Browse the repository at this point in the history
fix: prevent title update on invalid message response
  • Loading branch information
lloydzhou authored Sep 25, 2024
2 parents 9bbd7d3 + e8581c8 commit 4c84182
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ export const useChatStore = createPersistStore(
providerName,
},
onFinish(message) {
if (!isValidMessage(message)) return;
get().updateCurrentSession(
(session) =>
(session.topic =
Expand Down Expand Up @@ -690,6 +691,10 @@ export const useChatStore = createPersistStore(
},
});
}

function isValidMessage(message: any): boolean {
return typeof message === "string" && !message.startsWith("```json");
}
},

updateStat(message: ChatMessage) {
Expand Down

0 comments on commit 4c84182

Please sign in to comment.