Pythonanywhere Error The model: `davinci-codex` does not exist

 

2023-06-05 17:18:27,770: error_code=model_not_found error_message='The model: `davinci-codex` does not exist' error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False 2023-06-05 17:18:27,772: Exception on /generate [POST] Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/home/PetCharmWorld/mysite/flask_app.py", line 14, in generate response = generate_article(prompt) File "/home/PetCharmWorld/mysite/flask_app.py", line 30, in generate_article response = openai.Completion.create(**completion_params) File "/home/PetCharmWorld/.local/lib/python3.10/site-packages/openai/api_resources/completion.py", line 25, in create return super().create(*args, **kwargs) File "/home/PetCharmWorld/.local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create response, _, api_key = requestor.request( File "/home/PetCharmWorld/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 230, in request resp, got_stream = self._interpret_response(result, stream) File "/home/PetCharmWorld/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 624, in _interpret_response self._interpret_response_line( File "/home/PetCharmWorld/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: The model: `davinci-codex` does not exist


How to fix:The error message you received indicates that the model `davinci-codex` does not exist in the OpenAI API. The model name might be outdated or no longer available.


To resolve this issue, you need to update your code to use a valid and available model. As of my knowledge cutoff in September 2021, OpenAI provides several models that you can choose from, such as `davinci`, `curie`, or `babbage`. You can refer to the OpenAI documentation or the OpenAI Playground to get the most up-to-date information on available models and their names.


Update your code with the name of a valid model and modify the `completion_params` dictionary accordingly. For example, you can replace `'davinci-codex'` with `'davinci'`:


```python

completion_params = {

    'prompt': prompt,

    'max_tokens': 500,

    'temperature': 0.8,

    'top_p': 1.0,

    'n': 1,

    'stop': None,

    'engine': 'davinci'  # Update the engine name

}

```


Remember to use a model that is currently supported and available in the OpenAI API.


If you need further assistance or encounter any other issues, please let me know.

Comments

Popular posts from this blog

Unlocking Python's Potential: Exploring Fibonacci Series, Factorials, Prime Numbers, and Temperature Conversion

Simplifying Data Insertion: Extracting Insert Scripts from a PostgreSQL Database

Building Your First Web Application with Flask: A Simple Introduction to Flask Framework