A command-line tool that converts source code into pseudocode using OpenAI's GPT models.
- Python 3.6+
- OpenAI API key
- Clone this repository
- Install dependencies:
pip install -r requirements.txt- Set up your environment variables:
- Copy
.env.exampleto.env:cp .env.example .env
- Edit
.envand add your OpenAI API key:OPENAI_API_KEY=your_actual_api_key_here
- Copy
Basic usage (uses GPT-3.5 Turbo by default):
python pseudogen.py path/to/source/file.pyRead source from URL:
python pseudogen.py https://raw.githubusercontent.com/user/repo/main/file.pySave output to a file:
python pseudogen.py path/to/source/file.py -o output.txtUse a specific model:
python pseudogen.py path/to/source/file.py --model gpt-4-1106-previewList available models:
python pseudogen.py --list-modelssource: Path to the source code file or URL (required)--output,-o: Output file path (optional, defaults to stdout)--model,-m: Model to use for generation (optional, defaults to gpt-3.5-turbo-1106)--list-models: List available models and exit
gpt-3.5-turbo-1106: Latest GPT-3.5 Turbo - Fast and cost-effective (default)gpt-4-1106-preview: Latest GPT-4 Turbo - Most capable and up-to-date modelgpt-4: Standard GPT-4 - Highly capable model with 8k contextgpt-4-32k: GPT-4 32k - Extended context version of GPT-4
Convert Python code using GPT-4 Turbo:
python pseudogen.py example.py --model gpt-4-1106-previewConvert code from GitHub using GPT-3.5 Turbo:
python pseudogen.py https://raw.githubusercontent.com/user/repo/main/script.py -m gpt-3.5-turbo-1106Save pseudocode to a file using GPT-3.5 Turbo:
python pseudogen.py example.py -m gpt-3.5-turbo-1106 -o pseudocode.txt