Crates.io | gptrs |
lib.rs | gptrs |
version | 0.1.2 |
source | src |
created_at | 2023-03-06 22:18:49.373165 |
updated_at | 2023-03-07 21:29:04.816899 |
description | A cli built on top of OpenAI that can generate code and output to a file |
homepage | |
repository | https://github.com/lyledean1/openai-gptrs |
max_upload_size | |
id | 803042 |
size | 57,350 |
A OpenAI Code generation cli.
This sends requests to the OpenAI API, parsers the output and then generates code into a file.
This is mainly a small project to help myself learn Rust and get familiar with the OpenAI API, some of the initial code was generated using the help of ChatGPT!
gptrs completion --prompt=<PROMPT> --input=<PATH/TO/FILE> --output=</PATH/TO/OUTPUT>
Run the command to generate a Python file with a Fibonacci sequence as following
gptrs completion --prompt="generate a fibonacci sequence in Python" --output=./fibonacci.py
Which generates a file in Python:
Then run a command to refactor the code in this file and output a new file below:
gptrs completion --prompt="Refactor this code" --input=./fibonacci.py --output=./fibonacci_refactor.py
You can also set different models and temperatures
gptrs completion --prompt="Write unit tests for this fibonacci function in Python" --input=./fibonacci_refactor.py --output=./fibonacci_tests.py --model=code-davinci-002 --temperature=0
This assumes you have an OpenAI Developer Account
After generating the token, set the env variable
export OPENAI_API_KEY={API_KEY}
cargo install gptrs