ERROR discord.client Ignoring exception in on_message Traceback (most recent call last): \AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 687, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: Invalid URL (POST /v1/engines/gpt-3.5-turbo/chat/completions)
for the code
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
self.conversation_history = []
async def setup_hook(self):
self.tree.copy_global_to(guild=GUILD)
await self.tree.sync(guild=GUILD)
async def on_message(self, message):
author = message.author
if message.author == self.user:
return
input_content = message.content
print(f"{message.author}: {input_content}")
self.conversation_history.append({"role": "system", "content": f"The user is {author.display_name}. {SYSTEM_MESSAGE}"})
self.conversation_history.append({"role": "user", "content": input_content})
self.conversation_history = trim_conversation_history(self.conversation_history)
try:
prompt = "\n".join([item["content"] for item in self.conversation_history if item["role"] != "system"])
response = openai.ChatCompletion.create(
engine="gpt-3.5-turbo",
prompt= prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
assistant_response = response.choices[0].text
self.conversation_history.append({"role": "assistant", "content": assistant_response})
self.conversation_history = trim_conversation_history(self.conversation_history)