Update chatbox.tsx handle "data:{xxxx}"

This commit is contained in:
2023-06-19 20:11:09 +08:00
committed by GitHub
parent 280545c224
commit da31f32fcb

View File

@@ -54,7 +54,7 @@ export default function ChatBOX(props: {
.map((line) => line.trim()) .map((line) => line.trim())
.filter((i) => { .filter((i) => {
if (!i) return false; if (!i) return false;
if (i === "data: [DONE]") { if (i === "data: [DONE]" || i === "data:[DONE]") {
responseDone = true; responseDone = true;
return false; return false;
} }
@@ -63,7 +63,7 @@ export default function ChatBOX(props: {
console.log("lines", lines); console.log("lines", lines);
const jsons: ChunkMessage[] = lines const jsons: ChunkMessage[] = lines
.map((line) => { .map((line) => {
return JSON.parse(line.trim().slice("data: ".length)); return JSON.parse(line.trim().slice("data:".length));
}) })
.filter((i) => i); .filter((i) => i);
console.log("jsons", jsons); console.log("jsons", jsons);