-
-
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
Fix the "improve" prompt to make sure that it generates diffs, and parse and apply those diffs to the existing codebase #650
Comments
Hey, I'd take this up. eta a few days |
@AntonOsika I think replacing functions is not quite the right approach, because not every code is neatly made up of functions (eg in python we have code outside functions, classes, nested functions). What do you think about using git style diff files instead? So we'd ask the LLM to produce something like this:
I'd ask the LLM to add 2 lines before and after the code change to help us locate the change. The alternative would be asking for line numbers, but as LLMs are notoriously bad with numbers, I'd not go that way. We would then parse the above output into a git diff file
What do you think? |
Awesome. I looked at it took, I think we should first try using this prompt. It should be possible to use it by doing something like loading EditBlockCoder here and then:
And then see what happens. If we use code directly from Aider, or we use it for inspiration, we should give credits to Paul (the creator) in an inline comment 🙏 |
One way to do this is to write the prompt for gpt-engineer with
-i
flag to annotate each codeblock with one of:NEW CODE
REPLACING ONE FUNCTION
If 1., the generated code can just be written to a new file (or appended to an existing file).
If it is replacing an existing function, we could make sure to find the name of the function that is being replaced using an AST parser (see how here)
Why this is necessary
As an example, I tried to use it on the project itself and got a codeblock that was just changing one of the function (so it should not be used to overwrite the entire file)
How to do it
We can take inspiration from Aider, that generates diffs, or sweep in how they prompt for "<copy_lines>" and parse the GPT4 output here
Should be quite straightforward!
The text was updated successfully, but these errors were encountered: