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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file codegpt-0.1.6.tar.gz.

File metadata

  • Download URL: codegpt-0.1.6.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Windows/10

File hashes

Hashes for codegpt-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5166fc496d06a7b003ae0419ec2212e7889282022f14a2a057f336fc07b65ffc
MD5 e7af43680ad304fdf40de9acfe10bc73
BLAKE2b-256 d999729ce9fa47e8f5600b414940d9bf1e67354dd2a7071aa4a47149d2278a6a

See more details on using hashes here.

File details

Details for the file codegpt-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: codegpt-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Windows/10

File hashes

Hashes for codegpt-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ecc006ff6c86af375f53f74e45fe6d953957f656581f1ce4294d772ca7d92379
MD5 d7aadfb28b3889a0b261c35b8efb2956
BLAKE2b-256 77c53505c26d8d8cc33a0e14b359472c0692059048138f4bb4bc0eeb5ef056bd

See more details on using hashes here.

Supported by

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