Work ongoing - rich presence and ai assistant

This commit is contained in:
2024-11-14 19:53:40 +01:00
parent 14b9a50f51
commit b15c2f06b8
5 changed files with 79 additions and 53 deletions
+22 -13
View File
@@ -9,14 +9,14 @@ import openai
import requests
from discord.ext import commands
from ai_functions import handle_response, hammer_assistant_create
import ai_functions
from constants import (
DATA,
GRAPHICS_PATH,
INITIAL_TIME_WAIT,
MASTER_TIMEOUT,
OPENAICLIENT,
WORD_REACTIONS
WORD_REACTIONS,
)
@@ -27,10 +27,9 @@ class Events(commands.Cog):
async def cog_load(self):
self.logger.info("Starting personal assistants")
await hammer_assistant_create(self.bot)
await ai_functions.hammer_assistant_create(self.bot)
self.logger.info("Started personal assistants")
@commands.Cog.listener()
async def on_message(self, message):
"""
@@ -68,14 +67,24 @@ class Events(commands.Cog):
return
if isinstance(message.channel, discord.DMChannel):
if message.author.id == 346956223645614080:
#hammer pisze dma
user = await self.bot.fetch_user(703985955312238664)
channel = await user.create_dm()
await channel.send(message.content)
await message.reply(f"Poszlo do Saint {message.content}")
await ai_functions.hammer_assitant_chat(message)
# hammer pisze dma
# DM do Saint - przerobic na komende z parametrem "id"
# user = await self.bot.fetch_user(703985955312238664)
# channel = await user.create_dm()
# await channel.send(message.content)
# await message.reply(f"Poszlo do Saint {message.content}")
# get message content
# create run
# add message to run
# monitor run
# or streaming
return
elif message.author.id == 703985955312238664:
#saint pisze DMA
# saint pisze DMA
self.logger.info(message.content)
await message.reply("Hejka Saint!")
return
@@ -84,7 +93,7 @@ class Events(commands.Cog):
await channel.send("Słyszałem ja żem że: " + message.content)
return
channel = message.channel
#await self.bot.process_commands(message) #uncomment to bilocate
# await self.bot.process_commands(message) #uncomment to bilocate
message.content = message.content.lower()
@@ -142,7 +151,7 @@ class Events(commands.Cog):
bartender = True
global MESSAGE_TABLE # pylint: disable=global-statement
result, MESSAGE_TABLE = await handle_response(
result, MESSAGE_TABLE = await ai_functions.handle_response(
prompt,
vykidailo,
bartender,
@@ -185,7 +194,7 @@ class Events(commands.Cog):
username = message.author.nick
else:
username = message.author.name
resp, _ = await handle_response(
resp, _ = await ai_functions.handle_response(
f"Wytlumacz jakie sa zasady dotyczące treści które możesz generować używając Dalle. Wytłumacz błąd {e} prostym językiem. Przeproś za nadmierną cenzurę. Wytłumacz co mogło być nie tak w prompcie '{message.content}'",
True,
True,