debug in docker

This commit is contained in:
William Lane
2023-04-03 16:22:48 -07:00
parent b5b7048784
commit 7461f994e7
5 changed files with 18 additions and 13 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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."},