fix: prevent title update on invalid message response
This commit is contained in:
parent
9bbd7d3185
commit
e8581c8f3c
|
@ -615,6 +615,7 @@ export const useChatStore = createPersistStore(
|
||||||
providerName,
|
providerName,
|
||||||
},
|
},
|
||||||
onFinish(message) {
|
onFinish(message) {
|
||||||
|
if (!isValidMessage(message)) return;
|
||||||
get().updateCurrentSession(
|
get().updateCurrentSession(
|
||||||
(session) =>
|
(session) =>
|
||||||
(session.topic =
|
(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) {
|
updateStat(message: ChatMessage) {
|
||||||
|
|
Loading…
Reference in New Issue