I am creating a fun Discord bot which talks like my imaginary crush, lol!
The problem is that its working for the first 5-6 lines but then gives this error
import openai
openai.api_key = "Hidden"
DISCORD_BOT_TOKEN = "Hidden"
start_sequence = "\nAnamika:"
restart_sequence = "\n\nFaraaz:"
session_prompt = "This is a conversation between me (Faraaz) and my crush Anamika. Keep the replies long, and such that the person can reply. Anamika is a really gorgeous happy girl. She lives in New York. She loves Spiderman, coding and poetry. She loves Andrew Garfield amongst all spider men, in coding she is fascinated by boom of AI. She loves John Milton and writes poetry herself as well. Initially Anamika will be reluctant to my flirting but slowly she will start to like it. If the conversation goes very good, she can agree to become my girlfriend or marry me.Faraaz:- Hi! what is your name? Anamika:- Hey! My name is Anamika, how are you Faraaz! Faraaz:- I am really good, actually you were looking really pretty so wanted to come and talk to you. Anamika:- Oh really, that is interesting. So what did you intend to talk about?!"
chat_log = None
import discord
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_message(message):
# Don't respond to messages sent by the bot itself
global chat_log
if message.author == client.user:
return
print(chat_log)
if chat_log == None:
chat_log = session_prompt
#print(message.content)
#chat_log = f'{chat_log}{restart_sequence} {question}{start_sequence}{answer}'
# Use the GPT-3 API to generate a response to the message
response = openai.Completion.create(
engine="text-davinci-003",
#prompt="I recently moved to New York and I love design. I'm fascinated by technology and the growth of AI, but I realize that anything we build for the future must be rooted in the core desires of humans. " + message.content,
#return f'{chat_log}{restart_sequence} {question}{start_sequence}{answer}'
#chat_log = f'{chat_log}{restart_sequence} {question}{start_sequence}{answer}'
prompt = f'{chat_log}{restart_sequence}{message.content}',
#prompt = f'{chat_log}{restart_sequence}: {question}{start_sequence}:'
max_tokens=700,
n=1,
temperature=0.5,
stop=["\n"]
)
# Send the response back to the Discord channel
await message.channel.send(response["choices"][0]["text"])
chat_log = f'{chat_log}{restart_sequence}{message.content}{start_sequence}{response["choices"][0]["text"]}'
client.run(DISCORD_BOT_TOKEN)
I am seeing this error Error
The Discord Chat, after this messages not coming
I tried changing the max_tokens and also the prompt but to no avail. I have given administrator permissions to the bot.