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

Error Applying Code Edit in Improve Code Mode #945

Closed
aix10 opened this issue Dec 31, 2023 · 1 comment
Closed

Error Applying Code Edit in Improve Code Mode #945

aix10 opened this issue Dec 31, 2023 · 1 comment
Labels
bug Something isn't working triage Interesting but stale issue. Will be close if inactive for 3 more days after label added.

Comments

@aix10
Copy link

aix10 commented Dec 31, 2023

I'm running GPT Engineer in improve mode. After successfully writing some code and making some improvements to the code, GPT Engineer is no longer able to make edits to the code. It starts writing the updated code in CMD but in inevitably always terminates in error and none of the code changes take effect.

I am trying to understand why this error occurs so GPT Engineer can finish updating the code to files.

After seeing a lot of files being updated in the console I get the following error and it terminates without applying any edits:

These changes implement the requested functionality. The `myMethodName` method now accepts a list of XXX... The `Main` class has been updated to pass the correct parameters and format the output as requested. The `CoResult` class is a new addition to store and format . Lastly, the `CoUtil` class is a utility to generate...Traceback (most recent call last):

  File "C:\Users\XDX\AppData\Local\pypoetry\Cache\virtualenvs\gpt-engineer-upNWTwXa-py3.11\Scripts\\gpte", line 6, in <module>
    sys.exit(app())
             ^^^^^

  File "C:\Agents\gpt-engineer\gpt_engineer\applications\cli\main.py", line 194, in main
    files_dict = agent.improve(files_dict, prompt)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Agents\gpt-engineer\gpt_engineer\applications\cli\cli_agent.py", line 132, in improve
    files_dict = self.improve_fn(
                 ^^^^^^^^^^^^^^^^

  File "C:\Agents\gpt-engineer\gpt_engineer\core\default\steps.py", line 182, in improve
    overwrite_code_with_edits(chat, files_dict)

  File "C:\Agents\gpt-engineer\gpt_engineer\core\chat_to_files.py", line 97, in overwrite_code_with_edits
    apply_edits(edits, files_dict)

  File "C:\Agents\gpt-engineer\gpt_engineer\core\chat_to_files.py", line 185, in apply_edits
    occurrences_cnt = files_dict[filename].count(edit.before)
                      ~~~~~~~~~~^^^^^^^^^^

KeyError: 'src/MyJavaClass.java'

I've changed the class and method name. This error always surfaces but the "MyJavaClass" can change.

@AntonOsika

What is causing this error and how to resolve?

@aix10 aix10 added bug Something isn't working triage Interesting but stale issue. Will be close if inactive for 3 more days after label added. labels Dec 31, 2023
@ATheorell
Copy link
Collaborator

Unfortunately, the improve/edit syntax is not so powerful atm, which is why I've suggested an improvement in #869 .
Hopefully we will have this up soon. I'm closing this for now, but you report is helpful, since it emphasizes how important this is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Interesting but stale issue. Will be close if inactive for 3 more days after label added.
Projects
None yet
Development

No branches or pull requests

2 participants