mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
Improved makeprompt, cleaned code a bit
This commit is contained in:
@@ -12,14 +12,7 @@ class Chat (discord.Cog) :
|
||||
self.bot = bot
|
||||
@discord.Cog.listener()
|
||||
async def on_message(self, message: discord.Message):
|
||||
try:
|
||||
c.execute("SELECT * FROM model WHERE guild_id = ?", (message.guild.id,))
|
||||
model = c.fetchone()[1]
|
||||
except: model = "davinci"
|
||||
if model == "davinci":
|
||||
await mp.davinci_process(self, message)
|
||||
if model == "chatGPT":
|
||||
await mp.chat_process(self, message)
|
||||
await mp.chat_process(self, message)
|
||||
|
||||
@discord.slash_command(name="say", description="Say a message")
|
||||
async def say(self, ctx: discord.ApplicationContext, message: str):
|
||||
@@ -34,10 +27,6 @@ class Chat (discord.Cog) :
|
||||
if message_to_delete.author.id == self.bot.user.id:
|
||||
await message_to_delete.delete()
|
||||
else:
|
||||
await ctx.respond("The last message wasn't sent by the bot", ephemeral=True)
|
||||
return
|
||||
#get the message before the last message, because the new last message is the bot thinking message, so the message before the last message is the message to redo
|
||||
await ctx.respond("The message to redo was sent by the bot", ephemeral=True)
|
||||
return
|
||||
message_to_redo=history[0]
|
||||
await ctx.respond("Message redone !", ephemeral=True)
|
||||
await mp.process(self, message_to_redo)
|
||||
await mp.chat_process(self, message_to_redo)
|
||||
@@ -17,12 +17,16 @@ class Setup (discord.Cog) :
|
||||
await ctx.respond("Invalid channel id", ephemeral=True)
|
||||
return
|
||||
#check if the guild is already in the database bi checking if there is a key for the guild
|
||||
c.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
if c.fetchone() is not None:
|
||||
#in this case, the guild is already in the database, so we update the channel id and the api key
|
||||
try:
|
||||
c.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
data = c.fetchone()
|
||||
if data[3] == None: data = None
|
||||
except:
|
||||
data = None
|
||||
|
||||
if data != None:
|
||||
c.execute("UPDATE data SET channel_id = ?, api_key = ? WHERE guild_id = ?", (channel.id, api_key, ctx.guild.id))
|
||||
#we will also set the advanced settings to their default values
|
||||
c.execute("UPDATE data SET is_active = ?, max_tokens = ?, temperature = ?, frequency_penalty = ?, presence_penalty = ?, prompt_size = ? WHERE guild_id = ?", (False, 64, 0.9, 0.0, 0.0, 5, ctx.guild.id))
|
||||
# c.execute("UPDATE data SET is_active = ?, max_tokens = ?, temperature = ?, frequency_penalty = ?, presence_penalty = ?, prompt_size = ? WHERE guild_id = ?", (False, 64, 0.9, 0.0, 0.0, 5, ctx.guild.id))
|
||||
conn.commit()
|
||||
await ctx.respond("The channel id and the api key have been updated", ephemeral=True)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user