This script is designed to improve a given piece of JavaScript code using the OpenAI GPT-3 language model. This is a Python script that allows you to send your code to OpenAI to improve it using the OpenAI API. Your code should contain comments and other instructions that OpenAI will take into consideration while improving your code.
- Clone the repository or download the script file.
- Install the required packages by running
pip install -r requirements.txt
. - Save you openai key (see section below).
- Find the path to your file to improve. Eg:
index.js
. If you want, you can include comments and instructions in your code. - Run the Python script
improve_code.py
(see usage below) - The improved code will be saved and you find a backup of your existing code named:
index.js.bck
.
To run the script, simply call the Python interpreter with the script file as the argument:
python3 improve_code.py --filename index.js --system-message-file system_message.txt
The script will update your code and the original code will be backed up with a .bck suffix.
To set the OpenAI API key from the command line, simply run:
python3 config.py --key <your API key>
You can also use the --print
flag to display the current configuration:
python3 config.py --print
- Python 3.6 or later
openai==0.10.2
python-dotenv==0.19.1
This tool is licensed under the MIT License. See the LICENSE file for more information.