gpt-engineer
gpt-engineer copied to clipboard
.env setup for OpenAI API key
This pull request adds support for loading environment variables from a .env file in the Makefile of the gpt-engineer project. This is achieved by using the python-dotenv package to read environment variables from a .env file when the make run command is executed. The following changes have been implemented:
- Updated the Makefile: Added a new load-env target in the Makefile. This target uses python-dotenv to load the environment variables from a .env file.
- Updated the run target: Modified the run target to depend on the load-env target. This ensures that the environment variables are loaded before the run command is executed.
- Updated pyproject.toml: Added python-dotenv >= 1.0.0 to the list of project dependencies in pyproject.toml. This ensures that python-dotenv is installed when setting up the project.
- Updated README.md: Updated the new setup process to reflect the changes.
These changes allow for better management and confidentiality of environment variables in the gpt-engineer project, particularly when it comes to sensitive information that should not be hard-coded. This method will also help users keep track of their API key between runs.
Thanks @OriAshkenazi !
I like the idea I’m not sure it covers all ways to run it though.
It should be possible to pip install and then only run gpt-engineer. No make.
I thought about this last night though and what I think we want is:
- Check if API KEY env variable exist
- If it doesn’t, call load_dotenv
- Package these two steps in a nice function so it is used in main.py and all scripts etc.
What do you think?
What do you think?
I'll give it another go on Sunday to make sure it covers the scenario you mentioned! :)
Updated What do you think? I feel like everything is covered now
Great. Appreciate the effort @OriAshkenazi.
Be prepared it often takes a few iterations to make things work exactly as we want them in serious development.
I added some comments since a part of the philosophy is to minimize the LoC.
PS:
pytest failing due to that env variable doesn't exist for tests
PS:
pytest failing due to that env variable doesn't exist for tests
How can I solve this without giving away an API key to the public? Can you explain to me what can be done? Even a general broad explanation will be good. I'll make sure to attend to the rest of the comments later today.
Hey! I explained the proposed solution in my proposal in the review comments, did you see?