-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
"Improve" now edits existing code base #721
Conversation
Did you also run it with 3.5-turbo? Some logic is dependant on LLM output and 3.5 might be worse at following this. I will try it myself and let you know if I get issues. |
No, I didn't. But I also wouldn't use gpt3.5 for code generation. I think we should assume people use gpt4 or similarly capable models. Happy to hear @AntonOsika's thoughts |
Wow, excellent work. super excited to see this in action. |
Nice work @UmerHA ! Looking at the code, I think it would make sense to re-use the logic in This part of # Get all the text before the first ``` block
readme = chat.split("```")[0]
files.append(("README.md", readme)) |
Running b73f793 for improving someone else's program, I get the error: Happy to provide the lengthy stack trace if requested. |
Without thinking too in-depth about it, I think it should work for other non-gtpe-generated code as well.
Yes please! Would be helpful! |
(venv) axel@axel-ThinkPad-T470s:~/Software/Opensource-Contribution-Leaderboard$ gpt-engineer -i .
Select option and press Enter (default=3): 2
Select files:54,58,61The following files will be used in the improvement process: The inserted prompt is the following:
|
@UmerHA Is the idea that it will always improve existing files, not add new ones? I'm a bit confused with how As for your change I think it's awesome but that it also needs to be able to add new files. In my case I wanted to add more database models but GPT will output everything in the
format, even new files. Also if GPT happens to add some other output to the reply, like bash commands, we get a
|
@RareMojo , I think you are right, these are different things. |
I can't seem to reproduce your error. Would it be possible for you to send me the entire project files, e.g. via Discord? |
No, it can also add new files. In this case the
When you do
Could you post the 'ask' you made to gpte? That helps me understand better if we need to add handling of such cases. :) |
Here is the project that I'm trying to modify: https://github.com/ATheorell/Opensource-Contribution-Leaderboard/tree/improveCode The prompt and the file selection are in the stack trace. I tried multiple times and always get the error @UmerHA |
I am using this for java and but several times it is not actually updating the files and i dont see any error logs. Trying to narrow down but no luck |
Okay, can reproduce now. The issue is that currently gpte expects the code to be in a subfolder name 'workplace'. I'll make the name of the workplace folder editable. In your case, you would then choose 'src'. |
What is the downside of having it work with relative paths from the execution path, rather than an explicit code path? I'm thinking about the case that the improved code files may be scattered over the file tree (and also a bit about the general UX). |
Do you mean project path (not execution path)? I mostly use gpte like this
So, the execution path ( In principle, there is no downside to using relative locations to the project path. We would then have make sure gpte-internal files are not editable. Iirc, there's a proposal to move all of those things into a |
I think we need to decide how we want to structure the gpte directory. We have two options:
We currently do 1, but when we want the ability to edit existing codebases, 2 would be easier. @AntonOsika @ATheorell @pbharrin thoughts? When that's decided, then I can finish this PR. |
I now went ahead and made a PR to use the project path as workplace and move everything else into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome.
Looking forward to try.
The prompt is pretty long, so I'd also like to compare it with sweep.dev's approach:)
I added some comments, feel free to merge without addressing, but nice if we at least address after merge!
@AntonOsika Agree the prompt is long & we should look into making it shorter. I would, however, prefer to separate it from this PR. Let's get this shipped, and then optimize it later.
Addressed all!
works now Also, reminder we need to merge #749 first :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for updating the tests.
resolved merge conflicts, all tests pass, Peter has approved; let's merge. |
Has anyone tested scenario where the model suggests multiple edits within the same file using the Found that only the first model-suggested edit is made in the file, the following edits are not made in the file as expected. Click to expand console logTested using Docker on Command line: export OPENAI_API_KEY="sk-2kMT........................................AXRK"
export DOCKER_USER="$(id -u):$(id -g)"
export OPENAI_MODEL="gpt-4"
docker run -it --rm -e OPENAI_API_KEY="$OPENAI_API_KEY" -v "/.../my-blazor-pwa:/project:cached" --user "$DOCKER_USER" gpt-engineer -i $OPENAI_MODEL | tee ".gpteng/logs/output_`date +"%Y%m%d_%H%M%S"`.txt" With output:
I've confirmed that only the first edit was made in the target file. |
@ATheorell pinging you so @rrmistry's comment doesn't get lost. I don't have time to fix this, but wanted to let the team know. |
Solves #650.
Improve mode (ie -i flag) now produces code changes and applies those changes to the existing codebase.
Changes:
Note: Unlike Aider (https://github.com/paul-gauthier/aider/blob/main/aider/coders/editblock_coder.py) which uses a lot of code to make sure edits are correctly parsed and applied, I have kept the code very simple. Still, I have found it to work well with an adjusted prompt. Still, I would encourage everyone to test this code.