mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 07:36:39 +08:00
add more criteria for detecting invalid messages
This commit is contained in:
parent
cea5b91f96
commit
7fa823447f
@ -693,6 +693,17 @@ export const useChatStore = createPersistStore(
|
||||
}
|
||||
|
||||
function isValidMessage(message: any): boolean {
|
||||
if (message.startsWith("```") && message.endsWith("```")) {
|
||||
const jsonString = message.slice(3, -3).trim();
|
||||
try {
|
||||
const jsonObject = JSON.parse(jsonString);
|
||||
if (jsonObject.error) {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Invalid JSON format.");
|
||||
}
|
||||
}
|
||||
return typeof message === "string" && !message.startsWith("```json");
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user