development #1

Merged
AllfatherHatt merged 157 commits from development into master 2025-06-14 15:47:26 +02:00
3 changed files with 10 additions and 0 deletions
Showing only changes of commit b93ae09b69 - Show all commits

View File

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

View File

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

View File

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