Skip to main content

A CLI tool for refactoring Python code using OpenAI's text-davinci-003 model

Project description

Codegpt

0.1.5

A tool for using GPT just a little quicker. A nearly truly automated footgun. Learn how to revert with git before trying please.

Posting about progress here:

Twitter Follow

Getting Started

pip install codegpt --upgrade

And set your openapi API key as an environment variable like they recommend: In their docs here

Windows users can also use setx like:

$ setx OPENAI_SECRET_KEY=<YOUR_API_KEY>

from an admin console.

Be careful! But try this:

Usage To try Codegpt, you can run the following command:

codegpt todo list <filename>

This will prompt you for a description of what needs to be done and build a .todo file for the filename provided. You can ask it to do whatever, even if you aren't sure how to do it (But search to validate its plans, it might bullshit you!). Make sure to mention a technical requirement if you have one, like using a certain module or library. GPT-3 can be pretty lazy if you don't get specific.

When you start to see good results, you can take the gloves off with:

codegpt todo do <filename>

Which will attempt to DO the todo list with GPT3's help. Results will be mixed. Backup your code first.

Or use the gen command to generate docs.

codegpt gen docs <filename>

For more advanced (brave? foolhardy?) users, you can use the codegpt unsafe command, which allows you to:

Change variable names to be more readable

codegpt unsafe varnames <filename>

Add comments to your code automatically

codegpt unsafe comment <filename>

Edit any file

codegpt unsafe edit <filename> "Break this up into smaller functions where you can. Add google style docstrings. Feel free to rewrite any code doesn't make sense."

Keep in mind that using GPT-3 for code generation is paid, with a cost of 2 cents per 1,000 tokens.

Just like with a Jr Dev, it's best to break up your tasks into smaller pieces to improve the results.

Propose endpoints as issues, I've got a few ideas:

  • Write tests for file
  • Generate SQL query from table spec files
  • Generate new file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codegpt-0.1.6.tar.gz (24.8 kB view hashes)

Uploaded Source

Built Distribution

codegpt-0.1.6-py3-none-any.whl (22.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page