Skip to content

Commit 9ba5173

Browse files
jameslaminedanny-avila
authored andcommitted
🔧 fix: handle known OpenAI errors with empty intermediate reply (#5562)
1 parent b64b9da commit 9ba5173

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/app/clients/OpenAIClient.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,11 @@ ${convo}
14641464
(err instanceof OpenAI.OpenAIError && err?.message?.includes('missing finish_reason'))
14651465
) {
14661466
logger.error('[OpenAIClient] Known OpenAI error:', err);
1467-
return intermediateReply.join('');
1467+
if (intermediateReply.length > 0) {
1468+
return intermediateReply.join('');
1469+
} else {
1470+
throw err;
1471+
}
14681472
} else if (err instanceof OpenAI.APIError) {
14691473
if (intermediateReply.length > 0) {
14701474
return intermediateReply.join('');

0 commit comments

Comments
 (0)