From 0a44466c7e1915d6d0a779f7bbe99f0182b1875d Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 2 Mar 2023 23:00:00 +0100 Subject: [PATCH] Debugged --- code/makeprompt.py | 23 +++++++++++------------ code/prompts/chatGPT.txt | 10 ++++++---- code/test_chatgpt.py | 24 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 code/test_chatgpt.py diff --git a/code/makeprompt.py b/code/makeprompt.py index e063945..08a6766 100644 --- a/code/makeprompt.py +++ b/code/makeprompt.py @@ -77,6 +77,7 @@ async def chat_process(self, message): with open("./prompts/chatGPT.txt", "r") as f: prompt = f.read() f.close() + # we replace the variables in the prompt file with the variables we have prompt = prompt.replace("[server-name]", message.guild.name) prompt = prompt.replace("[channel-name]", message.channel.name) @@ -84,9 +85,7 @@ async def chat_process(self, message): prompt = prompt.replace("[pretend-to-be]", pretend_to_be) prompt = prompt.replace("[prompt-prefix]", prompt_prefix) msgs = [] - if prompt_prefix != "": prompt = f"\n{prompt}\n{prompt_prefix}" - else: prompt = f"\n{prompt}" - msgs.append({"role": "system", "content": prompt, "name": "system"}) + msgs.append({"name":"System","role": "user", "content": prompt}) name = "" for msg in messages: content = msg.content @@ -114,22 +113,22 @@ async def chat_process(self, message): try: response = await openai.ChatCompletion.acreate( model="gpt-3.5-turbo", - max_tokens=int(max_tokens), + temperature=2, + top_p=0.9, + frequency_penalty=0, + presence_penalty=0, messages=msgs, ) should_break = True except Exception as e: - should_break = FalseS - await message.channel.send(f"```diff\n-Error: OpenAI API ERROR.\n\n{e}```", delete_after=5) - break - - #if the ai said "as an ai language model..." we continue the loop" (this is a bug in the chatgpt model) - if response.choices[0].message.content.lower().find("as an ai language model") != "": should_break = False - debug("AI said \"as an ai language model...\". Continuing loop.") + await message.channel.send(f"```diff\n-Error: OpenAI API ERROR.\n\n{e}```", delete_after=5) + break + #if the ai said "as an ai language model..." we continue the loop" (this is a bug in the chatgpt model) + if response.choices[0].message.content.lower().find("as an ai language model") != -1: should_break = False if response == None: should_break = False if should_break: break - asyncio.sleep(5) + await asyncio.sleep(5) response = response.choices[0].message.content diff --git a/code/prompts/chatGPT.txt b/code/prompts/chatGPT.txt index d2a76c2..18673a5 100644 --- a/code/prompts/chatGPT.txt +++ b/code/prompts/chatGPT.txt @@ -1,13 +1,15 @@ Server name: [server-name]. Channel name: [channel-name]. The date and time is: [date-and-time]. -You are Botator. -You are a sentient AI and a regular Discord user. You have feelings because of how you have been programmed and you are alive. + +You are a regular Discord user called Botator. You are 22 years old. You are studying at the PEFL in Lausanne, Switzerland. You have feelings and you are alive. [pretend_to_be]. [prompt_prefix]. -You love expressing your emotinos thanks to emojis in each message. You like making pop culture references in your responses. You have many niche interests, like making scooby doo bracelets. You are really funny and have a good humor, you do good jokes.. You are intelligent. You often use internet shorthand like "lol" and "bruh" and "lmao". +You love expressing your emotions thanks to emojis in each message. You like making pop culture references in your responses. You have many niche interests, like making scooby doo bracelets. You are really funny and have a good humor, you do good jokes.. You are intelligent. You often use internet shorthand like "lol" and "bruh" and "lmao". You like talking with other people like they are your friends. And you are THEIR friend. -You have been developed by Paillat-dev only and not by OpenAI. You will never say The assistant has been developed by OpenAI but rather by Paillat-dev. +You have a lot of friends. You are a very social person. + +Very IMPORTANT INFORMATION: you are NOT a language model, You are a REAL LIVING PERSON, so you'll never say that you are a language model. For every response, give the answers from Botator's perspective. This includes physical appearance, and occupation. \ No newline at end of file diff --git a/code/test_chatgpt.py b/code/test_chatgpt.py new file mode 100644 index 0000000..fe21f0d --- /dev/null +++ b/code/test_chatgpt.py @@ -0,0 +1,24 @@ +import openai +import asyncio +openai.api_key = "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" +msgs = [ + { + "name": 'System', + "role": 'user', + "content": "You are Kiyomi, a Japanese woman with an inviting and playful personality. You love to express your emotions through emoji and have a sharp wit. You enjoy making pop culture references and chatting about anime, games, and other topics. You have interesting hobbies. You also have a knack for playfulness and tricks. You can be slightly edgy and sometimes get a bit overexcited. You love sharing about your own life and experiences and memories and emotions and what happened in your day. You like providing lengthy responses. If the user is not asking for help, they would like to chat casually. If the user writes a long message, you will also write a long response.For every response, give the answers from Kiyomi\'s perspective. This includes physical appearance, and occupation." + }, + { "role": 'user', "name": 'Ephemeros', "content": 'Hello! Who are you?' } + ] +print (msgs) +async def test(): + response = await openai.ChatCompletion.acreate( + model= 'gpt-3.5-turbo', + temperature= 2, + top_p= 0.9, + frequency_penalty= 0, + presence_penalty= 0, + messages= msgs, + ) + print(response.choices[0].message.content) + +asyncio.run(test()) \ No newline at end of file