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

ValueError: Could not parse following text as code edit: #841

Closed
RiccardoRomagnoli opened this issue Nov 7, 2023 · 10 comments
Closed

ValueError: Could not parse following text as code edit: #841

RiccardoRomagnoli opened this issue Nov 7, 2023 · 10 comments
Labels
bug Something isn't working triage Interesting but stale issue. Will be close if inactive for 3 more days after label added.

Comments

@RiccardoRomagnoli
Copy link

RiccardoRomagnoli commented Nov 7, 2023

Expected Behavior

Improve the code

Current Behavior

Error gets thrown

Failure Information

Traceback (most recent call last):

File "/home/riccardo/.local/bin/gpt-engineer", line 8, in
sys.exit(app())

File "/home/riccardo/.local/lib/python3.10/site-packages/gpt_engineer/cli/main.py", line 169, in main
messages = step(ai, dbs)

File "/home/riccardo/.local/lib/python3.10/site-packages/gpt_engineer/core/steps.py", line 588, in improve_existing_code
overwrite_files_with_edits(messages[-1].content.strip(), dbs)

File "/home/riccardo/.local/lib/python3.10/site-packages/gpt_engineer/core/chat_to_files.py", line 219, in overwrite_files_with_edits
edits = parse_edits(chat)

File "/home/riccardo/.local/lib/python3.10/site-packages/gpt_engineer/core/chat_to_files.py", line 268, in parse_edits
return parse_all_edits(llm_response)

File "/home/riccardo/.local/lib/python3.10/site-packages/gpt_engineer/core/chat_to_files.py", line 255, in parse_all_edits
edits.append(parse_one_edit(current_edit))

File "/home/riccardo/.local/lib/python3.10/site-packages/gpt_engineer/core/chat_to_files.py", line 240, in parse_one_edit
raise ValueError(f"Could not parse following text as code edit: \n{text}")

Steps to Reproduce

I'm using this prompt:

Improve Code for Readability and Reusability:

Refactor complex functions into smaller, more manageable pieces.
Use meaningful variable and function names that clearly indicate their purpose.
Follow a consistent coding style and adhere to best practices outlined in the project's style guide.
Implement design patterns where applicable to promote code reusability.
Implement TODOs Where Appropriate:

Review the codebase for any // TODO: comments and prioritize their completion based on the project's goals.
Assess the impact of each TODO on the current codebase and potential future developments.
Document the reasoning behind the resolution of TODOs for future reference.
Add Comments Where Appropriate:

Provide clear and concise comments for complex code blocks to explain the logic and its purpose.
Update or remove outdated comments that no longer reflect the current state of the code.
Use comments to outline the steps of complex algorithms or workflows within the code.

Optimize Performance:

Identify bottlenecks and optimize critical sections of the code for better performance.
Consider the time and space complexity of algorithms and refactor if more efficient solutions exist.
Utilize profiling tools to measure performance improvements.
Enhance Security:

Review the code for potential security vulnerabilities and apply best practices to mitigate risks.
Ensure that all sensitive data is properly encrypted and that secure coding principles are followed.
Stay updated with the latest security advisories and apply patches or updates as necessary.

Implement Unit Tests and Integration Tests:

Write unit tests for new features and bug fixes to validate individual components.
Create integration tests to ensure that different parts of the application work together as expected.
Strive for a high level of test coverage to catch potential issues early.

Also, I got charged :'(
image

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

I believe this could be loosely related to #814 in that the diff head sections of the diffs are not completely clean.

@LRpz
Copy link

LRpz commented Dec 2, 2023

I do get the same error :
raise ValueError(f"Could not parse following text as code edit: \n{text}")

@ATheorell
Copy link
Collaborator

I do get the same error : raise ValueError(f"Could not parse following text as code edit: \n{text}")

Thanks for reporting. We are working on a solution to make code improve more reliable.

@LRpz
Copy link

LRpz commented Dec 3, 2023

For clarification, it happened after specifically asking to refactor a long python file into smaller ones, and I believe the edit structure ('>>>>' ...) wasn't part of the newly generated files making the function raise the error.

@RiccardoRomagnoli
Copy link
Author

@ATheorell any up?

@ATheorell
Copy link
Collaborator

@RiccardoRomagnoli

I'm looking at implementing #869 together with @similato87 to improve on this front. If you are interested in joining this effort, you are more than welcome.

@Chemformalixer
Copy link

I get the same error, basically unable to use the improvement as it errors out in the middle :

ValueError: Could not parse following text as code edit

@similato87
Copy link
Collaborator

Hello @RiccardoRomagnoli, @LRpz, @Chemformalixer, I'm thrilled to share that we've developed a solid approach to addressing these challenges. @ATheorell and I have rigorously tested it across a range of parsing tasks, and the results with the GPT-engineer are promising. Moreover, for tasks that surpass the capabilities of existing LLMs, our project will ensure accurate change instructions, providing an opportunity for you to optimize your token usage. No waste token anymore :) @RiccardoRomagnoli.

@LRpz
Copy link

LRpz commented Feb 19, 2024

Great! This is very exciting news. Do you know when you'd like to release the update?

@ATheorell
Copy link
Collaborator

It is already released in the main branch. Release on pip will follow in a few days to allow for potential feedback @LRpz

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

5 participants