From e58bea20ca0df357d351c6d21c43fd1a0ff144da Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 16 May 2024 06:40:03 +0200 Subject: [PATCH] feat(logging): Add debug log for empty OpenAI responses Introduces logging for cases where OpenAI's API returns an empty response, ensuring that such occurrences are captured for debugging purposes. This change enhances visibility into the interaction with OpenAI's endpoint, facilitating easier identification and resolution of issues where empty responses are received, potentially indicating API limitations, network issues, or unexpected behavior from the AI model. --- src/gptbot/classes/openai.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gptbot/classes/openai.py b/src/gptbot/classes/openai.py index e9b2e0a..332f145 100644 --- a/src/gptbot/classes/openai.py +++ b/src/gptbot/classes/openai.py @@ -493,6 +493,9 @@ class OpenAI: model=original_model, ) + if not result_text: + self.logger.log(f"Received an empty response from the OpenAI endpoint.", "debug") + try: tokens_used = response.usage.total_tokens except: