development #1
@ -229,9 +229,14 @@ class ReginaldCog(PermissionsMixin, BlacklistMixin, MemoryMixin, commands.Cog):
|
|||||||
# chat message.
|
# chat message.
|
||||||
response = await client.chat.completions.create(**completion_args)
|
response = await client.chat.completions.create(**completion_args)
|
||||||
|
|
||||||
|
if response.choices and response.choices[0].message and response.choices[0].message.content:
|
||||||
response_text = response.choices[0].message.content.strip()
|
response_text = response.choices[0].message.content.strip()
|
||||||
if response_text.startswith("Reginald:"):
|
if response_text.startswith("Reginald:"):
|
||||||
response_text = response_text[len("Reginald:"):].strip()
|
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
|
return response_text
|
||||||
|
|
||||||
except OpenAIError as e:
|
except OpenAIError as e:
|
||||||
|
|||||||
@ -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:
|
def get_weather_forecast(location: str, days: int = 14, dt: str = '2025-03-24') -> str:
|
||||||
weather = Weather(location=location)
|
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))
|
return json.dumps(weather.forecast(days=days, dt=dt))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user