From d8038e3b1942199c6be5debaf220b1cb28689e8b Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 19 Feb 2024 11:03:42 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A4=20refactor:=20Utilize=20`intermedi?= =?UTF-8?q?ateReply`=20when=20`message.content`=20is=20Empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/clients/OpenAIClient.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/app/clients/OpenAIClient.js b/api/app/clients/OpenAIClient.js index 0e61fdcbaa..e913c6a994 100644 --- a/api/app/clients/OpenAIClient.js +++ b/api/app/clients/OpenAIClient.js @@ -1097,6 +1097,14 @@ ${convo} logger.debug('[OpenAIClient] chatCompletion response', chatCompletion); + if (!message?.content?.trim() && intermediateReply.length) { + logger.debug( + '[OpenAIClient] chatCompletion: using intermediateReply due to empty message.content', + { intermediateReply }, + ); + return intermediateReply; + } + return message.content; } catch (err) { if (