Skip to content

Commit 4a04082

Browse files
authored
fix: always send mandatory response field (#3134)
Signed-off-by: Philippe Martin <[email protected]>
1 parent dfe4e93 commit 4a04082

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/backend/src/managers/apiServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export class ApiServer implements Disposable {
505505
res.write(
506506
JSON.stringify({
507507
model: modelName,
508-
response: chunk.choices[0].delta.content,
508+
response: chunk.choices[0].delta.content ?? '',
509509
done: chunk.choices[0].finish_reason === 'stop',
510510
done_reason: chunk.choices[0].finish_reason === 'stop' ? 'stop' : undefined,
511511
}) + '\n',
@@ -516,7 +516,7 @@ export class ApiServer implements Disposable {
516516
onNonStreamResponse: response => {
517517
res.status(200).json({
518518
model: modelName,
519-
response: response.choices[0].message.content,
519+
response: response.choices[0].message.content ?? '',
520520
done: true,
521521
done_reason: 'stop',
522522
});

0 commit comments

Comments
 (0)