Skip to content

Commit 81d2dff

Browse files
authored
Merge pull request #9 from wolfsilver/master
fix: 过滤空字符串导致格式错误
2 parents eae48d3 + 19ce3d0 commit 81d2dff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/api/controllers/chat.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ async function receiveStream(model: string, stream: any): Promise<any> {
411411
const result = _.attempt(() => JSON.parse(event.data));
412412
if (_.isError(result))
413413
throw new Error(`Stream response invalid: ${event.data}`);
414-
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content == ' ')
414+
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content)
415415
return;
416416
data.choices[0].message.content += result.choices[0].delta.content;
417417
if (result.choices && result.choices[0] && result.choices[0].finish_reason === "stop")
@@ -465,7 +465,7 @@ function createTransStream(model: string, stream: any, endCallback?: Function) {
465465
const result = _.attempt(() => JSON.parse(event.data));
466466
if (_.isError(result))
467467
throw new Error(`Stream response invalid: ${event.data}`);
468-
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content == ' ')
468+
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content)
469469
return;
470470
result.model = model;
471471
transStream.write(`data: ${JSON.stringify({

0 commit comments

Comments
 (0)