Giter Site home page Giter Site logo

codegenpt's Introduction

CodeGenPT

Version Python Version Support

Autogenerate files or entire projects using ChatGPT API.

Installation

pip install codegenpt

Usage

CodeGenPT looks for .codegenpt files and generate files using its instructions.

Generating individual files

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 use codegenpt -R . to recursively look for all .codegenpt files and generate them.

Generate entire directories or projects

You can create entire directories or projects using a .dir.codegenpt file. Example: tictactoe.dir.codegenpt

Create a tic-tac-toe game using html, js and css.

Then:

$ codegenpt tic-tac-toe.dir.codegenpt
โณ Generating directory: tic-tac-toe
๐Ÿบ File generated: tic-tac-toe/style.css
๐Ÿบ File generated: tic-tac-toe/index.html
๐Ÿบ File generated: tic-tac-toe/game.js
๐Ÿป Success

Will create a folder called tic-tac-toe and generate all needed files.

Setup

CodeGenPT expects an environment variable called OPEN_API_KEY.

  1. Get an Open AI API Key
  2. 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];
}

codegenpt's People

Contributors

diegoquinteiro avatar

Stargazers

 avatar

Watchers

 avatar  avatar

codegenpt's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.