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

Load env variable handling & Project preprompt enhancement #740

Merged
merged 5 commits into from
Sep 25, 2023

Conversation

saschalalala
Copy link
Contributor

Hey everyone 👋,

thanks for the great project. I found some things that I believe can benefit the project.

env file loading

I use pyenv and pyenv-virtualenv and I noticed that my pip installed gpt-engineer always tries to load the .env from its site-packages directory and searches up to the root. My project is located somewhere else, so it did not find my .env. I introduced a small change that as a fallback, if the .env file isn't found before, will attempt to find it in the current working directory. (c834e69 and ac4cac6)

preprompt management

I noticed that the preprompts are part of the project itself and a change inside my venv directory would a) be overwritten by an update and b) be global. I wanted to have project specific preprompts so I implemented them. I noticed that the DB class cannot handle kind of a "merged" path so that only the files that I want to overwrite would come from the project specific directory so I decided to copy all existing files to the project so that when the preprompts would be updated in the future (inside gpt-engineer itself) they would be copied over to the project directory.

In order to test this feature and because I don't know every implication of the preprompts yet, I changed all of them inside my example project to say You do not code, you only shout back at people and it looks like this:

gpt-engineer --use-project-preprompts projects/example                                               
I'M SORRY, BUT I CAN'T HELP YOU WITH THAT. I DON'T CODE, I ONLY SHOUT BACK AT PEOPLE!It seems like there's a misunderstanding. Could you please provide the actual information about the codebase?
gpt-engineer projects/example           
To implement the game Snake in Python using the MVC (Model-View-Controller) design pattern, we will need several classes and files. The game will be controlled using the keyboard. Here are the core classes and their purposes: …

Future steps if this PR is accepted

  • doc enhancement
  • tests

Copy link
Collaborator

@ATheorell ATheorell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this PR increases useability and reproducibility.

see my (very minor) comment on line 25

gpt_engineer/main.py Outdated Show resolved Hide resolved
@ATheorell ATheorell merged commit b2f4f35 into gpt-engineer-org:main Sep 25, 2023
4 checks passed
Copy link
Collaborator

@AntonOsika AntonOsika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @saschalalala !

To make it a nice legacy of yours, would you consider refactoring it to make the main() file?

Could set line 109 to preprompts=DB(preprompt_path(use_custom_preprompts))

(use_custom_preprompts: bool flag, preprompt_path(use_custom_preprompts: bool) is a function)

for file in preprompts_path.glob("*"):
if not (project_preprompts_path / file.name).exists():
(project_preprompts_path / file.name).write_text(file.read_text())
preprompts_path = project_preprompts_path
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create a separate function for this? 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@@ -50,6 +53,12 @@ def main(
help="""Endpoint for your Azure OpenAI Service (https://xx.openai.azure.com).
In that case, the given model is the deployment name chosen in the Azure AI Studio.""",
),
use_project_preprompts: bool = typer.Option(
False,
"--use-project-preprompts",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--use-custom-preprompts

@saschalalala
Copy link
Contributor Author

Of course :)

I also already started writing some docs for that feature. Will create a new PR after the weekend.

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

Successfully merging this pull request may close these issues.

3 participants