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 do <filename>

This will prompt you for a description of what needs to be done and give you the option to edit the todo list before refactoring the code.

Or use the gen command to generate docs.

codegpt gen docs <filename>

For more advanced users, you can use the codegpt unsafe command, which allows you to:

Change variable names

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.5.tar.gz (19.5 kB view hashes)

Uploaded Source

Built Distribution

codegpt-0.1.5-py3-none-any.whl (22.2 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