Skip to content

Commit

Permalink
修复换行失效
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinlic committed May 8, 2024
1 parent 60cf284 commit 4b6802d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/controllers/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ async function receiveStream(model: string, stream: any): Promise<any> {
const result = _.attempt(() => JSON.parse(event.data));
if (_.isError(result))
throw new Error(`Stream response invalid: ${event.data}`);
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content.trim() == '')
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content == ' ')
return;
data.choices[0].message.content += result.choices[0].delta.content;
if (result.choices && result.choices[0] && result.choices[0].finish_reason === "stop")
Expand Down Expand Up @@ -465,7 +465,7 @@ function createTransStream(model: string, stream: any, endCallback?: Function) {
const result = _.attempt(() => JSON.parse(event.data));
if (_.isError(result))
throw new Error(`Stream response invalid: ${event.data}`);
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content.trim() == '')
if (!result.choices || !result.choices[0] || !result.choices[0].delta || !result.choices[0].delta.content || result.choices[0].delta.content == ' ')
return;
result.model = model;
transStream.write(`data: ${JSON.stringify({
Expand Down

0 comments on commit 4b6802d

Please sign in to comment.