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
Feature request: Integration of Code Formatting and Linting Tools for the improve Function Workflow #1023
Comments
Hey! Sounds like a useful feature. I had some questions; I wonder whether it’s a good idea to run the linter if we can’t locate its config-file. ChatGPT has seen way more code than we have, so it probably has a pretty good idea of how to produce code with popular styling. So got-engineer selecting a default may just get in the way. One question is who should fix the errors that the linter can't fix itself, user or LLM? Or should we ignore them altogether and just focus on Some suggestions
|
@Styren Thanks for the insightful suggestions! Your idea of managing linter configs and the approach to handle non-auto-fixable errors are crucial. I'm inclined to let LLMs address these errors, while we should ensure users are informed about this process. The concept of toggling autolinting and introducing a flexible configuration system, perhaps through a .gpt directory or environment variables, is something we should pursue. While we haven't set up a config system yet, it's a direction worth exploring. |
I want to add some context here and I'll speak mainly for python, as I don't have experience with the linters in the other languages. First of all, for the cases where the linter fails, I agree with the previous comments. The reason this thing came up was that, particularly in improve mode, chat-gpt doesn't even get the indentation right. The LLM actually isn't that good at following PEP-8. Reason for this is probably that it has seen so much code which doesn't. The linter fixes the indentation problem in 100% of the cases I've seen. Whenever we can use a deterministic system, like a linter, which: is not random, is super fast, very reliable and very cheap, we should prefer that over using the LLM. I can honestly not think of a case where the LLM would right better style than the linter. Additionally, in many projects, like gpt-engineer, a standard linter is part of the CI-pipeline and I think this is how it should be. When gpt-engineer generates code from scratch, I really cannot see any reason why it should not be linted. In improve mode, I can imagine that linting could be a problem in rare cases. I would vote to have linting by default and the possibility to turn it off with some flag, for the few cases where people really don't want neat code or follow some outdated code standard. |
We have implemented this for https://gptengineer.app, and are in the process of adopting a I will present a proposal regarding this at the meeting later today :) |
Here's a teaser for my proposed [project]
base_dir = "./frontend" # base directory to operate in (for monorepos)
src_dir = "./src" # source directory (under the base directory) from which context will be retrieved
[run]
build = "npm run build"
test = "npm run test"
lint = "quick-lint-js"
format = "prettier"
[gptengineer-app] # this namespace is used for gptengineer.app
project_id = "..."
# we support multiple OpenAPI schemas, used as context for the LLM
[[gptengineer-app.openapi]] # an entry in a list of OpenAPI specs used by the project
url = "https://api.gptengineer.app/openapi.json" # schema for gptengineer.app itself See you at the meeting in ~1h! |
Policy and Info
Feature Description
I propose the integration of code formatting and linting tools into the workflow of our
improve
function. This would involve two key stages: pre-processing and post-processing. In the pre-processing stage, before the code is sent to LLMs for improvement, the code would be formatted and linted to ensure it adheres to standard coding practices and is free of syntax errors. In the post-processing stage, after the LLMs have applied changes, the code would again be subjected to formatting and linting to refine the improvements, rectify any introduced errors, and standardize the code style.Motivation/Application
The integration of these tools serves several purposes:
Pre-processing checks: By checking the code for errors before sending it to LLMs, we can reduce the computational load on LLMs, allowing them to focus more on the complexity of the tasks rather than correcting basic syntax errors. This not only enhances efficiency but also improves the quality of the improvements suggested by LLMs.
Post-processing refinement: After LLMs have applied their changes, a second round of formatting and linting can significantly enhance user experience by ensuring that the improvements adhere to standard coding practices, and any errors inadvertently introduced by LLMs are corrected. This step is crucial for maintaining code quality and readability, especially for dynamically typed languages where indentation and formatting are vital, like Python.
Suggested Tools:
These tools are widely recognized for their robustness and flexibility, making them suitable for integration into our existing workflow. This feature would not only streamline the development process but also significantly enhance the quality and reliability of code improvements generated through the
improve
function.The text was updated successfully, but these errors were encountered: