fix: prevent title update on invalid message response

This commit is contained in:
Dogtiti 2024-09-25 00:37:37 +08:00
parent 9bbd7d3185
commit e8581c8f3c
1 changed files with 5 additions and 0 deletions

View File

@ -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) {