+ Applied debug decorator to some functions and methods

This commit is contained in:
T-BENZIN 2025-03-18 19:54:34 +05:00
parent 881ef42f42
commit b93ae09b69
3 changed files with 10 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import openai
from openai import OpenAIError
from .weather import time_now, get_current_weather, get_weather_forecast
from .tools_description import TOOLS
from .debug_stuff import debug
CALLABLE_FUNCTIONS = {
# Dictionary with functions to call.
@ -20,6 +21,7 @@ class Completion:
self.__api_key = api_key
self.__messages = []
@debug
async def create_completion(self, messages: list):
self.__messages = messages
model = self.__model

View File

@ -14,6 +14,7 @@ from .blacklist import BlacklistMixin
from .memory import MemoryMixin
from .weather import time_now, get_current_weather, get_weather_forecast
from .tools_description import TOOLS
from .debug_stuff import debug
CALLABLE_FUNCTIONS = {
@ -189,6 +190,7 @@ class ReginaldCog(PermissionsMixin, BlacklistMixin, MemoryMixin, commands.Cog):
return any(message_lower.startswith(invocation) for invocation in direct_invocation)
@debug
async def generate_response(self, api_key, messages):
model = await self.config.openai_model()
try:

View File

@ -2,20 +2,24 @@ from datetime import datetime, timezone
from os import environ
import requests
import json
from .debug_stuff import debug
#WEATHER_API_KEY = environ.get('WEATHER_API_KEY')
URL = 'http://api.weatherapi.com/v1'
@debug
def time_now() -> str:
return str(datetime.now(timezone.utc))
@debug
def get_current_weather(location: str) -> str:
weather = Weather(location=location)
return json.dumps(weather.realtime())
@debug
def get_weather_forecast(location: str, days: int = 14, dt: str = '2025-03-24') -> str:
weather = Weather(location=location)
return json.dumps(weather.forecast(days=days, dt=dt))
@ -35,6 +39,7 @@ class Weather:
response = requests.get(url=f'{URL}{method}', params=params)
return response.json()
@debug
def realtime(self):
method = '/current.json'
params = {
@ -43,6 +48,7 @@ class Weather:
}
return self.make_request(method=method, params=params)
@debug
def forecast(self, days: int = 14, dt: str = '2025-03-24'):
method = '/forecast.json'
params = {