Autogenerate files and folders using ChatGPT API
Project description
CodeGenPT
Autogenerate files using ChatGPT API.
Installation
pip install codegenpt
Usage
CodeGenPT looks for .codegenpt
files within the source tree and generate files using its instructions.
Example: hello_world.py.codegenpt
Create a hello world program
Then:
$ codegenpt helloworld.py.codegenpt
⏳ Generating file: helloworld.py
🍺 File generated: helloworld.py
🍻 Success
Will generate a file named helloworld.py
:
print("hello world");
The actual content of the file will be generated by ChatGPT, so it will vary at each run.
You can also recursevily generate all files within a directory:
$ codegenpt -R .
🔎 Searching files...
⏳ Generating file: helloworld.py
🍺 File generated: helloworld.py
⏳ Generating file: README.md
🍺 File generated: README.md
⏳ Generating file: tests/tests.py
🍺 File generated: tests/tests.py
🍻 Success
Setup
CodeGenPT expects an environment variable called OPEN_API_KEY
.
- Get an Open AI API Key
- Add the key to your
OPEN_API_KEY
environment variable:
- If you use
bash
:echo 'export OPENAI_API_KEY={your api key}' >> ~/.bash_profile && source ~/.bash_profile
- If yu use
zsh
:echo 'export OPENAI_API_KEY={your api key}' >> ~/.zshenv && source ~/.zshenv
Commands
Commands are special instructions you can use to instruct the generation process.
All codegenpt commands are placed in a single line in the format:
@command_name args...
@include
Includes one or more files on the context.
Included files can be referenced using @filename.ext
in the generation instructions
Example:
names.txt
:
Diego
Alberto
Daniel
random_name.js.codegenpt
:
@include assets/names.txt
Read @names.txt and write a function that returns one of the names
random_name.js
:
function getRandomName() {
const names = [
'Diego',
'Alberto',
'Daniel'
];
const randomIndex = Math.floor(Math.random() * names.length);
return names[randomIndex];
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file codegenpt-0.4.0.tar.gz
.
File metadata
- Download URL: codegenpt-0.4.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebe0725a073a6fc82e752772eba2a057f100e827d44db7cdd4cc448c38c3ca5e |
|
MD5 | 52471572d90bd1be6594e93ed2001aff |
|
BLAKE2b-256 | ac89a34194006983510cfe71909edb6588d2e799d7fb42d2ada867616c5f564d |
File details
Details for the file codegenpt-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: codegenpt-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71fd1c012b0e2f2318e971965b0ebab296a36244a725ad0d6c4db7b4f5bdeffc |
|
MD5 | d302357b6875e1cfb0657e9b756d6fb5 |
|
BLAKE2b-256 | 9d8afcc4591f3caa699260f7860c1ec64bf1154473d687fba6814da948acd6c7 |