Hello,
I try to use openai 1.33.0 with gpt4 in free-plan on discord
I used openai_key in environment
pip show openai
Name: openai
Version: 1.33.0
Summary: The official Python library for the openai API
pip show discord.py
Name: discord.py
Version: 2.3.2
my script
@client.command()
async def ai(ctx, *, user_message):
try:
response = openai.Completion.create(
engine="text-davinci-003",
prompt=user_message,
temperature=0.7,
max_tokens=150
)
assistant_response = response.choices[0].text.strip()
await ctx.send(assistant_response)
except Exception as e:
print(f"Une erreur s'est produite : {e}")
await ctx.send("Une erreur s'est produite lors de la génération de la réponse.")
And the error message :
Une erreur s'est produite :
You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.
You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface.
Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`
A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
I don't understand where is the problem.
Could you help me please ?