Skip to main content

Write code using OpenAI's Codex model

Project description

Codeit

Codeit is a command-line tool that generates code from text prompts using OpenAI's Codex model. With Codeit, you can quickly and easily generate code snippets in a variety of languages without having to write any code yourself.

Installation

To install Codeit, you will need to have Python 3 and pip installed on your system. Then, you can use pip to install the Codeit package from PyPI:

pip install git+https://github.com/supervised/codeit

Usage

The main function in Codeit is codeit.code, which takes the following keywords:

  • prompt (required): A string containing the text prompt with the instructions for Codex.
  • lang (optional): The language to generate code in. The default is Python.
  • max_tokens (optional): An integer specifying the maximum number of output tokens.
  • best_of (optional): An integer specifying the number of completions to generate server-side and return the "best" (the one with the highest log probability per token). The default is 3.
  • save (optional): The name of the output file to save the code snippet to.

Here's an example of how to use the code function to generate a Python code snippet and save it to a file:

from codeit import code

prompt = "Write a function that takes a list of integers and returns the sum of the even numbers in the list."
code(prompt, lang='python', max_tokens=1000, save='output.py')

This will generate a Python code snippet, followed by an explanation, with up to 1000 tokens and save it to a file called output.py.

Example output:

def sum_even(list):
    sum = 0
    for i in list:
        if i % 2 == 0:
            sum += i
    return sum

print(sum_even([1,2,3,4,5,6,7,8,9,10]))

# The function takes a list of integers and returns the sum of the even numbers in the list.
# The function first creates a variable called sum and sets it equal to 0.
# The function then loops through the list and checks if the number is even.
# If the number is even, the function adds it to the sum variable.
# The function then returns the sum variable.
# The function is then called and the list is passed as an argument.
# The function returns the sum of the even numbers in the list.

Supported Languages

Codeit currently supports code generation for the following languages:

  • Python
  • HTML
  • C++
  • Java
  • JavaScript
  • C#
  • Go
  • Ruby
  • Swift
  • PHP

This list is not exhaustive and may be updated in the future as the Codex model continues to evolve.

Limitations

Codeit is powered by OpenAI's Codex model, which is a powerful tool for generating code from text prompts. However, it is not perfect and may not always produce accurate or complete code snippets. It is important to carefully review the generated code before using it in any production systems.

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

writecode-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file writecode-0.1.0.tar.gz.

File metadata

  • Download URL: writecode-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for writecode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a97be03373ac312a1926eecb3817d40a40374780af357cd35cb4c3dbcd1e5641
MD5 23585eec6b3611d54369c8136392dda9
BLAKE2b-256 0f32e6b2360b183c3af4075c34659498457b45657e5e13893e4fdef0fd9a1be5

See more details on using hashes here.

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