From b843a4ef589e4dc8c99c39e9ed12ab77ae2e3bc5 Mon Sep 17 00:00:00 2001 From: AllfatherHatt Date: Sun, 16 Mar 2025 13:48:36 +0100 Subject: [PATCH] Adding debug stuff --- reginaldCog/reginald.py | 11 ++++++++--- reginaldCog/weather.py | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/reginaldCog/reginald.py b/reginaldCog/reginald.py index 4fca2a8..3a1ca55 100644 --- a/reginaldCog/reginald.py +++ b/reginaldCog/reginald.py @@ -229,9 +229,14 @@ class ReginaldCog(PermissionsMixin, BlacklistMixin, MemoryMixin, commands.Cog): # chat message. response = await client.chat.completions.create(**completion_args) - response_text = response.choices[0].message.content.strip() - if response_text.startswith("Reginald:"): - response_text = response_text[len("Reginald:"):].strip() + if response.choices and response.choices[0].message and response.choices[0].message.content: + response_text = response.choices[0].message.content.strip() + if response_text.startswith("Reginald:"): + response_text = response_text[len("Reginald:"):].strip() + else: + print("DEBUG: OpenAI response was empty or malformed:", response) + response_text = "⚠️ No response received from AI." + return response_text except OpenAIError as e: diff --git a/reginaldCog/weather.py b/reginaldCog/weather.py index 18acab1..86e6b79 100644 --- a/reginaldCog/weather.py +++ b/reginaldCog/weather.py @@ -18,9 +18,6 @@ def get_current_weather(location: str) -> str: def get_weather_forecast(location: str, days: int = 14, dt: str = '2025-03-24') -> str: weather = Weather(location=location) - response = weather.forecast(days=days, dt=dt) - - print(f"DEBUG: Forecast API Response: {response}") return json.dumps(weather.forecast(days=days, dt=dt))