Code Monkey home page Code Monkey logo

Comments (13)

ankitkat042 avatar ankitkat042 commented on June 30, 2024 3

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

from gpt-engineer.

zajcomm avatar zajcomm commented on June 30, 2024 1

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

from gpt-engineer.

jebarpg avatar jebarpg commented on June 30, 2024 1

@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.

from gpt-engineer.

jebarpg avatar jebarpg commented on June 30, 2024

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

from gpt-engineer.

jebarpg avatar jebarpg commented on June 30, 2024

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

from gpt-engineer.

ScorchChamp avatar ScorchChamp commented on June 30, 2024

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

from gpt-engineer.

Keyvanhardani avatar Keyvanhardani commented on June 30, 2024

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

from gpt-engineer.

patillacode avatar patillacode commented on June 30, 2024

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?

from gpt-engineer.

majorrawdawg avatar majorrawdawg commented on June 30, 2024

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).

from gpt-engineer.

majorrawdawg avatar majorrawdawg commented on June 30, 2024

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

from gpt-engineer.

zajcomm avatar zajcomm commented on June 30, 2024

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

from gpt-engineer.

patillacode avatar patillacode commented on June 30, 2024

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.

from gpt-engineer.

patillacode avatar patillacode commented on June 30, 2024

Open discussion related to this in #135

from gpt-engineer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.