mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
Update code.py
This commit is contained in:
27
code/code.py
27
code/code.py
@@ -106,21 +106,18 @@ async def advanced(ctx, max_tokens=None, temperature=None, frequency_penalty=Non
|
|||||||
#save the current settings into a list: is_active, max_tokens, temperature, frequency_penalty, presence_penalty, prompt_size, prompt_prefix
|
#save the current settings into a list: is_active, max_tokens, temperature, frequency_penalty, presence_penalty, prompt_size, prompt_prefix
|
||||||
current_settings = [c.fetchone()[4], c.fetchone()[5], c.fetchone()[6], c.fetchone()[7], c.fetchone()[9]]
|
current_settings = [c.fetchone()[4], c.fetchone()[5], c.fetchone()[6], c.fetchone()[7], c.fetchone()[9]]
|
||||||
#get the new settings
|
#get the new settings
|
||||||
new_settings = [max_tokens, temperature, frequency_penalty, presence_penalty, prompt_size]
|
if max_tokens is None:
|
||||||
#for each setting, if it is not None, we update it in the database
|
max_tokens = current_settings[1]
|
||||||
for i in range(len(new_settings)):
|
if temperature is None:
|
||||||
if new_settings[i] is not None:
|
temperature = current_settings[2]
|
||||||
if i == 0:
|
if frequency_penalty is None:
|
||||||
c.execute("UPDATE data SET max_tokens = ? WHERE guild_id = ?", (new_settings[i], ctx.guild.id))
|
frequency_penalty = current_settings[3]
|
||||||
elif i == 1:
|
if presence_penalty is None:
|
||||||
c.execute("UPDATE data SET temperature = ? WHERE guild_id = ?", (new_settings[i], ctx.guild.id))
|
presence_penalty = current_settings[4]
|
||||||
elif i == 2:
|
if prompt_size is None:
|
||||||
c.execute("UPDATE data SET frequency_penalty = ? WHERE guild_id = ?", (new_settings[i], ctx.guild.id))
|
prompt_size = current_settings[5]
|
||||||
elif i == 3:
|
#update the settings
|
||||||
c.execute("UPDATE data SET presence_penalty = ? WHERE guild_id = ?", (new_settings[i], ctx.guild.id))
|
c.execute("UPDATE data SET max_tokens = ?, temperature = ?, frequency_penalty = ?, presence_penalty = ?, prompt_size = ? WHERE guild_id = ?", (max_tokens, temperature, frequency_penalty, presence_penalty, prompt_size, ctx.guild.id))
|
||||||
elif i == 4:
|
|
||||||
c.execute("UPDATE data SET prompt_size = ? WHERE guild_id = ?", (new_settings[i], ctx.guild.id))
|
|
||||||
conn.commit()
|
|
||||||
await ctx.respond("The advanced settings have been updated", ephemeral=True)
|
await ctx.respond("The advanced settings have been updated", ephemeral=True)
|
||||||
#create a command called "delete" that only admins can use wich deletes the guild id, the api key, the channel id and the advanced settings from the database
|
#create a command called "delete" that only admins can use wich deletes the guild id, the api key, the channel id and the advanced settings from the database
|
||||||
@bot.command(name="default", description="Default settings")
|
@bot.command(name="default", description="Default settings")
|
||||||
|
|||||||
Reference in New Issue
Block a user