by anotherpaulg · 3y ago · 0 comments
But keep in mind, this should be easy to do from the command line with a number of tools as long as you have a gpt-4 api key. I would probably trust gpt-3.5-turbo with this task in a pinch, but I think there would be more risk of it disrupting the original code.
Here it is with aichat [1]:
$ curl -s https://raw.githubusercontent.com/leachim6/hello-world/main/p/Python%203.py | aichat --model="gpt-4" -p "emit this exact code, but with helpful comments; don't put any comments before a #!shebang line if present"
#!/usr/bin/env python3
# This is a simple Python script that prints "Hello World" to the console.
# The first line, called the shebang, tells the operating system how to execute the script.
# In this case, it specifies that the script should be run using the Python 3 interpreter.
# The print function is used to output text to the console.
# Here, it is used to print the string "Hello World".
print("Hello World")
Or with my own tool aider [2]: $ git clone https://github.com/leachim6/hello-world.git
$ cd hello-world
$ aider "p/Python 3.py"
Added p/Python 3.py to the chat
Using git repo: .git
> add helpful comments
p/Python 3.py
<<<<<<< ORIGINAL
#!/usr/bin/env python3
print("Hello World")
=======
#!/usr/bin/env python3
# This is a simple Python script that prints "Hello World" to the console
print("Hello World") # Print "Hello World" to the console
>>>>>>> UPDATED
Applied edit to p/Python 3.py
Commit aad4afc aider: Added helpful comments to Python script.
[1] https://github.com/sigoden/aichatIt notices if your local repo is dirty and asks if you'd like to commit before proceeding with the GPT chat. It will even provide a suggestion for the commit message.
You can run aider with --no-auto-commits if you don't want it to commit to the repo. This is similar to your suggested --dangerous flag.
I have considered various magic/automatic branching strategies. But I suspect they would be too confusing. And people probably have their own preferred git workflows. I feel like it's probably better to let folks explicitly manage their branches and PRs however they like.
My aider tool tries to make this easy by leveraging git. While it automatically commits the edits from GPT, it also provides in-chat commands like /diff and /undo. These commands let you quickly check exactly what edits GPT made, and undo them if they're not correct.
Aider will notify GPT if you /undo its changes, and GPT will probably ask why and then try again with your concerns in mind.
To manage a longer chat that includes a sequence of changes, you can also use your preferred standard git workflows like branches, PRs, etc.