Traceback (most recent call last):
File “/home/runner/BasicAcidicComputing/main.py”, line 22, in
response = openai. chat. completions. create(
File “/home/runner/BasicAcidicComputing/.pythonlibs/lib/python3.11/site-packages/openai/_utils/_utils.py”, line 303,
in wrapper
return func(*args, ** kwargs )
File "/home/runner/BasicAcidicComputing/.pythonlibs/lib/python3.11/site-packages/openai/resources/chat/completions. py
", line 598, in create
return self. post(
File “/home/runner/BasicAcidicComputing/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 1088,
in post
return cast(ResponseT, self. request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "/home/runner/BasicAcidicComputing/.pythonlibs/lib/python3.11/site-packages/openai/base_client.py", line 853, i
n request
return self . request(
File “/home/runner/BasicAcidicComputing/.pythonlibs/lib/python3.11/site-packages/openai/_base_client.py”, line 930, i
n request
raise self . make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {‘error’: {‘message’: ‘The model ‘text-davinci-003’ has been deprecated, learn
more here: https://platform.openai. com/docs/deprecations’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘mod
el_not_found’}}
I am facing this error in the first api code, pls help
Below is the basic template code for gpt 3.5 turbo. Do try this and let us know. If you still face any issues, please feel free to get back to us.
import openai
import os
import sys
openai.api_key = os.environ['OPENAI_API_KEY']
if openai.api_key == "":
sys.stderr.write("""
You haven't set up your API key yet.
If you don't have an API key yet, visit:
https://platform.openai.com/signup
1. Make an account or sign in
2. Click "View API Keys" from the top right menu.
3. Click "Create new secret key"
Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.
""")
exit(1)
response = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{
"role": "system",
"content": "You are a helpful assistant."
}, {
"role": "user",
"content": "Who won the world series in 2020?"
}, {
"role":
"assistant",
"content":
"The Los Angeles Dodgers won the World Series in 2020."
}, {
"role": "user",
"content": "Where was it played?"
}])
print(response)
The sixth error_description_line says that you are trying to use text-davinci-003, which has been deprecated by OpenAI recently.
To solve the error, replace text-davinci-003 with gpt-3.5-turbo-instruct.
For more information on the “deprecations” thing, you can visit OpenAI Deprecations.
It seems like you’re encountering a 404 error because you’re using a deprecated model named “text-davinci-003”. OpenAI has deprecated this model, and you need to use a different one. You should switch to a supported model instead.
You can find the list of supported models in the OpenAI API documentation. Here’s the link to the documentation: OpenAI API Documentation
Look for the current models available and choose one that suits your needs. Once you’ve chosen a supported model, update your code to use that model instead of “text-davinci-003”, and the error should be resolved.