Skip to content

Commit

Permalink
fix wrong question being passed
Browse files Browse the repository at this point in the history
  • Loading branch information
kytpbs committed Oct 18, 2023
1 parent b1cd9c1 commit 25e634c
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/GPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,23 @@ def question(message: str, user_name: str = "MISSING", server_name: str = SERVER
logging.debug(f"{tokens} tokens used")
return answer

def chat(message: str, message_history: dict[discord.User, str]):
def chat(main_message: str, message_history: dict[discord.User, str]):
messages = [
{
"role": "system",
"content": f"You are a discord bot named '{BOT_NAME}' in a discord server named {SERVER_NAME}",
},
]
for user, message in message_history.items():
if user.bot:
messages.append({
"role": "assistant",
"content": message,
})
else:
messages.append({
"role": "user",
"name": user.name,
"content": message,
})
messages.append({
"role": "assistant" if user.bot else "user",
"name": user.name,
"content": message,
})

messages.append({
"role": "user",
"content": message,
"content": main_message,
})
try:
response = openai.ChatCompletion.create(
Expand Down

0 comments on commit 25e634c

Please sign in to comment.