Optai is a python based command-line tool designed to optimize and enhance your python repositories by rewriting your functions in a cleaner and more optimised way. It helps improve the readability, performance, and maintainability of Python code by applying various transformations.
This is based on the OpenAI LLM and requires you to have an API key.
- Automatically optimize and clean Python code in a given repository.
- Improve variable naming, formatting, and code structure.
- Easily integrate with your Python projects for code enhancement.
-
Clone the Python Code Optimizer repository:
git clone [email protected]:IlluvatarEru/optai.git
-
Install requirements:
pip install -r requirements.txt
-
Add your OpenAI key and organisation to the
.env
file:echo 'export OPEN_AI_KEY="YOUR_KEY"' >> .env echo 'export OPEN_AI_ORG="YOUR_ORGA"'>> .env
-
Add Optai to
bashrc
:OPTAI_PATH=$(pwd) echo 'alias optai="$OPTAI_PATH/optai.bash"' >> ~/.bashrc echo 'export OPTAI_PATH=$OPTAI_PATH'>> ~/.bashrc source ~/.bashrc
-
Run on a target repo:
optai "path_to_repo"
Flags:
- You can add the flag
--opti-only
to ask it to just optimize the performance of the code rather than to also improve the variable naming, formatting etc. - You can add the flag
--file=<file_name>
to ask it to only process a single file
We plan on:
- enabling this repo to work on most languages
- rewriting it in rust so that it is faster
- improving the rewriting quality
- making it work with local models rather than only OpenAI