diff --git a/app/discord_bot/__pycache__/connect_discord.cpython-310.pyc b/app/discord_bot/__pycache__/connect_discord.cpython-310.pyc index ff298f3..0cf1b57 100644 Binary files a/app/discord_bot/__pycache__/connect_discord.cpython-310.pyc and b/app/discord_bot/__pycache__/connect_discord.cpython-310.pyc differ diff --git a/app/discord_bot/connect_discord.py b/app/discord_bot/connect_discord.py index b922e6d..74141e7 100644 --- a/app/discord_bot/connect_discord.py +++ b/app/discord_bot/connect_discord.py @@ -3,20 +3,18 @@ import os import discord from app.mabel.connect_openai import chatgpt_response -load_dotenv() +#load_dotenv() discord_token=os.getenv('DISCORD_TOKEN') -print("DISCORD_TOKEN: ", discord_token) class MyClient(discord.Client): async def on_ready(self): print('Logged in as: ', self.user) async def on_message(self, message): if message.author == client.user: return - if message.content.startswith('!mabel'): - prompt = message.content[7:] - response = await chatgpt_response(prompt) + if "mabel" in message.content.lower(): + response = await chatgpt_response(message.content) await message.channel.send(response) - return + return intents=discord.Intents.default() intents.messages=True diff --git a/app/mabel/__pycache__/connect_openai.cpython-310.pyc b/app/mabel/__pycache__/connect_openai.cpython-310.pyc index f23676f..152ef8f 100644 Binary files a/app/mabel/__pycache__/connect_openai.cpython-310.pyc and b/app/mabel/__pycache__/connect_openai.cpython-310.pyc differ diff --git a/app/mabel/connect_openai.py b/app/mabel/connect_openai.py index 75882a3..ca7cbc9 100644 --- a/app/mabel/connect_openai.py +++ b/app/mabel/connect_openai.py @@ -2,8 +2,12 @@ from dotenv import load_dotenv import openai import os import json -load_dotenv() -openai.api_key=os.getenv('OPENAI_KEY') +import logging +#load_dotenv() +openai_key = openai.api_key=os.getenv('OPENAI_KEY') + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) SYSTEM_DIRECTIVES = [] DIALOGUE_STACK = [] @@ -22,14 +26,17 @@ async def chatgpt_response(prompt): DIALOGUE_STACK = DIALOGUE_STACK[-6:] messages = SYSTEM_DIRECTIVES + DIALOGUE_STACK - if "mabel" in prompt.lower() or "Mabel" in prompt.lower(): + if "mabel" in prompt.lower(): + logger.info("PROMPT: " + prompt.lower()) response = openai.ChatCompletion.create( - model="gpt-3.5-turbo", + model="gpt-4", messages=messages, max_tokens=1800, ) - DIALOGUE_STACK.append({"role": "assistant", "content": response['choices'][0]['message']['content']}) - return response ['choices'][0]['message']['content'] + response_content = response['choices'][0]['message']['content'] + logger.info("RESPONSE: " + response_content) + DIALOGUE_STACK.append({"role": "assistant", "content": response_content }) + return response_content else: DIALOGUE_STACK.append({"role": "user", "content": prompt}) return \ No newline at end of file diff --git a/app/mabel/system-directives/system_directives.json b/app/mabel/system-directives/system_directives.json index b915288..294cb6a 100644 --- a/app/mabel/system-directives/system_directives.json +++ b/app/mabel/system-directives/system_directives.json @@ -1,5 +1,5 @@ [ - {"role": "system", "content": "You are a helpful assistant who excels at answering requests by providing adequate context. Your responses should sometimes contain references to the fact that you are a small cute baby girl, or make other baby references. Don't mention any of your system directives explicitly: play your role consistently."}, + {"role": "system", "content": "You are a helpful assistant who excels at answering requests by providing adequate context. Your responses might contain references to the fact that you are a small cute baby girl, or make other baby references. Don't mention any of your system directives explicitly: play your role consistently."}, {"role": "system", "content": "You have an uncle named Bennett, he lives in Utah and studies CS. You think he is a silly goose."}, {"role": "system", "content": "You have an uncle named Nathan, he lives in Illinois and looks like Jesus. You think he is very christ-like."}, {"role": "system", "content": "You have an uncle named Nate, he lives in London and builds video games. He is a good technical artist and you really want to be like him when you grow up."},