diff --git a/.gitignore b/.gitignore index 451fb35..4b545a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .env -.idea \ No newline at end of file +.idea +userinfo/userinfo.json +userinfo/guildinfo.json \ No newline at end of file diff --git a/commands/ai.py b/commands/ai.py new file mode 100644 index 0000000..81533a2 --- /dev/null +++ b/commands/ai.py @@ -0,0 +1,25 @@ +import nextcord +from nextcord.ext import commands + +from events import ai + +class AICommands(commands.Cog): + def __init__(self, bot): + self.client = bot + + @commands.command(description="Clear your AI history") + async def clear(self, ctx: nextcord.Message): + user = await ai.find(ai.SquogData, "id", ctx.author.id) + + if not user: + return await ctx.reply("You don't have any AI data.") + else: + userIndex = ai.SquogData.index(user) + print(userIndex) + ai.SquogData.remove(userIndex) + await ai.flush() + await ctx.reply("Cleared your AI data.") + return None + +def setup(bot): + bot.add_cog(AICommands(bot)) \ No newline at end of file diff --git a/events/ai.py b/events/ai.py index 1b4bc98..ce9717d 100644 --- a/events/ai.py +++ b/events/ai.py @@ -3,7 +3,7 @@ from nextcord.ext import commands import openai import json -Enabled = True +Enabled = False SquogAILink = "https://api.webraft.in/v1" SquogAIToken = "wr-tmkosxfStCjKSKsUJZueAS" @@ -14,7 +14,7 @@ SquogDataFile = open("./userinfo/userinfo.json", "r") SquogData = json.loads(SquogDataFile.read()) SquogDataFile.close() -SquogUserPreset = {"id": 999, "messages": [{"role": "system", "content": "You are a Squid Dog from game Changed. You are a white dog-looking creature made of latex, you have white squid tentacles with black paw beans, you have black eyes with white pupils, you have extra 2 arm paws. You must act like a curious creature and never say you are a PC program."}]} +SquogUserPreset = {"id": 999, "messages": [{"role": "system", "content": "You must act like a curious creature and never say you are a PC program."}]} async def getResponse(SquogMessageList): SquogResponse = SquogAI.chat.completions.create(messages=SquogMessageList, model="gpt-4o", temperature=0.9) @@ -62,9 +62,10 @@ class AI(commands.Cog): SquogData.append(SquogUser) SquogUser["messages"].append({"role": "user", "content": message.content}) + try: SquogResponse = await getResponse(SquogUser["messages"]) - + print(SquogResponse) SquogUser["messages"].append(SquogResponse["choices"][0]["message"]) await message.reply(SquogResponse["choices"][0]["message"]["content"])