Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The model: gpt-4 does not exist #41

Closed
ankitkat042 opened this issue Jun 15, 2023 · 13 comments
Closed

The model: gpt-4 does not exist #41

ankitkat042 opened this issue Jun 15, 2023 · 13 comments

Comments

@ankitkat042
Copy link

After adding api key and running the project for the first time, I am getting an error as follows:

C:\Users\kitkat\Desktop\gpt-engineer-main>python main.py proj
Traceback (most recent call last):

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\main.py", line 51, in <module>
    app()

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\main.py", line 46, in chat
    messages = step(ai, dbs)
               ^^^^^^^^^^^^^

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\steps.py", line 21, in clarify
    messages = ai.next(messages, user)
               ^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\ai.py", line 27, in next
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
    raise self.handle_error_response(

openai.error.InvalidRequestError: The model: `gpt-4` does not exist


C:\Users\kitkat\Desktop\gpt-engineer-main>
@jebarpg
Copy link
Contributor

jebarpg commented Jun 15, 2023

Try using gpt-3.5-turbo it worked best for me.

@jebarpg
Copy link
Contributor

jebarpg commented Jun 15, 2023

After adding api key and running the project for the first time, I am getting an error as follows:

C:\Users\kitkat\Desktop\gpt-engineer-main>python main.py proj
Traceback (most recent call last):

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\main.py", line 51, in <module>
    app()

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\main.py", line 46, in chat
    messages = step(ai, dbs)
               ^^^^^^^^^^^^^

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\steps.py", line 21, in clarify
    messages = ai.next(messages, user)
               ^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\ai.py", line 27, in next
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
    raise self.handle_error_response(

openai.error.InvalidRequestError: The model: `gpt-4` does not exist


C:\Users\kitkat\Desktop\gpt-engineer-main>

Actually to help you even further go to your https://platform.openai.com/account/rate-limits page and you will see a list of models you can replace gpt-4 with... test out all the different models available for your account. additionally you can get on the waiting list for gpt-4 here: https://openai.com/waitlist/gpt-4-api

@ScorchChamp
Copy link

Make a PR with a fix to automatically switch over to gpt-3.5-turbo: #42

@ankitkat042
Copy link
Author

After adding api key and running the project for the first time, I am getting an error as follows:

C:\Users\kitkat\Desktop\gpt-engineer-main>python main.py proj
Traceback (most recent call last):

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\main.py", line 51, in <module>
    app()

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\main.py", line 46, in chat
    messages = step(ai, dbs)
               ^^^^^^^^^^^^^

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\steps.py", line 21, in clarify
    messages = ai.next(messages, user)
               ^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\Desktop\gpt-engineer-main\ai.py", line 27, in next
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(

  File "C:\Users\kitkat\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
    raise self.handle_error_response(

openai.error.InvalidRequestError: The model: `gpt-4` does not exist


C:\Users\kitkat\Desktop\gpt-engineer-main>

Actually to help you even further go to your https://platform.openai.com/account/rate-limits page and you will see a list of models you can replace gpt-4 with... test out all the different models available for your account. additionally you can get on the waiting list for gpt-4 here: https://openai.com/waitlist/gpt-4-api

yeah I changed model: str = "gpt-4" to model: str = "gpt-3.5-turbo" which gave me acceptable results. Thanks

@Keyvanhardani
Copy link

You should check that you have access to the GPT-4 model.

@zajcomm
Copy link

zajcomm commented Jun 15, 2023

So I do have GPT-4 (on ChatGPT) and I am getting the same error.

@patillacode
Copy link
Collaborator

So I do have GPT-4 (on ChatGPT) and I am getting the same error.

I don't have access to gpt-4 so I can't replicate, the only thing that comes to mind is: are you sure the API Key you are using is a gpt-4 one?

@majorrawdawg
Copy link

In db.py I had to add utf-8 encoding because I'm on Windows:
def getitem(self, key):
with open(self.path / key, 'r', encoding='utf-8') as f:
return f.read()

And I also had to play around (didn't work the first time) with the set command (export doesn't work in Windows Anaconda):
The set command in Windows sets an environment variable only for the current terminal session. If you close the terminal and reopen it, you'll lose the environment variable that you set. It's useful if you want to set a variable temporarily for the purpose of running a specific command or script, but it's not a permanent solution.

The setx command, on the other hand, permanently sets an environment variable. The new setting will persist even after you close and reopen the terminal. However, it won't affect any currently open terminals — only new ones.

If you're having trouble with the set command, using setx might solve your problem. But remember, after setting the environment variable with setx, you'll need to start a new terminal session for the change to take effect.

If you're still having trouble, you could set the API key directly in your Python code as I suggested earlier, but be sure not to share this code with anyone or commit it to a public version control repository, as that would expose your API key.

What (I think) eventually worked was manually setting the Windows environment variable manually, closing the Anaconda, reopening it, and then I did start getting some results (though it does seem to just stop arbitrarily without warning or error...but it is digging into some of the work. Give it a try and good luck.

Manually set a windows environment variable like this:
As an alternative, you can try setting the environment variable through the Windows System Properties:

Right-click on Computer on the desktop or in the Start menu.
Choose Properties.
Click on Advanced system settings.
Click on the Advanced tab, then click on the Environment Variables button.
Under the System Variables section, click New.
Enter OPENAI_API_KEY for the Variable name.
Enter your API key for the Variable value.
Click OK in each dialog to save.

ALSO!!! If you do have gpt-4 api access, use the new model gpt-4-0613 (not just main.py, you gotta look through and find everywhere the model is defined).

@majorrawdawg
Copy link

Oh, also, I think I did have to rerun the activate command after manually setting the environment variable and reopening anaconda.

@zajcomm
Copy link

zajcomm commented Jun 15, 2023

Update: Seems like I thought I have GPT-4 API access but apparently not. based on the below output.
Good part, I didnt need to change the model manually, it was done automatically.

Model gpt-4 not available for provided api key reverting to gpt-3.5.turbo. Sign up for the gpt-4 wait list here: https://openai.com/waitlist/gpt-4-api

@patillacode
Copy link
Collaborator

Correct, we recently merged that functionality, falling back into model gpt-3.5-turbo for when gpt-4 fails.

for anyone landing on this issue in the future: make sure you have a valid gpt-4 api key.

@patillacode
Copy link
Collaborator

Open discussion related to this in #135

@jebarpg
Copy link
Contributor

jebarpg commented Jun 18, 2023

@patillacode my PR also solves this for both the main.py and the rerun_edited_message_logs.py in a central file in the main repo directory called model_select.py. this way both fall back to the same fallback model and also centralizes the change out of the ai.py so that the rest of the code can reference in the future, making things easier to maintain and add to later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@Keyvanhardani @patillacode @ScorchChamp @ankitkat042 @majorrawdawg @zajcomm @jebarpg and others