Python CLI and GUI clients for OpenAI's ChatGPT. Simple, no arguments required to get started.
Note: Prefer your distribution packages if possible.
For the CLI client:
pip install openai richFor the GUI client (Tkinter is often part of the standard Python installation):
pip install openai tkinterweb mistletoe pygmentsExpects .api_key file in the repo directory with your OpenAI API key. The filename is
in .gitignore already.
Conversations are automatically saved as JSON files in ~/.chatgpt-gui/. Override the
location with the CHATGPT_GUI_DATA_DIR environment variable:
export CHATGPT_GUI_DATA_DIR=/path/to/your/data./cli.pyQuit with q, x, exit, quit, Ctrl+C, or Ctrl+D.
| Flag | Description |
|---|---|
-m, --multiline |
Multiline input mode — type your message, then enter SEND to submit |
-b, --batch-mode |
Non-interactive mode for pipes and redirection |
-M, --model |
Select a specific model |
-w, --web-search |
Enable web search with source extraction |
-p, --prepend |
Prepend a file's contents to the first message |
-i, --image |
Image file to include |
-f, --file |
Document(s) to include |
-vf, --vectorize-file |
Document(s) to upload to a vector store for semantic file search |
-d, --debug |
Pretty-print raw API responses to stderr |
-l, --list-known |
List models with known pricing |
-L, --list-all |
List all available models |
-lf, --list-files |
List uploaded files |
-lv, --list-vector-stores |
List vector stores |
./cli.py -b <<< "Tell a joke" > joke.txt
./cli.py -b < prompt.txt > output.txt
./cli.py -b --prepend summarize_prompt.txt < article.txt
./cli.py -b -f report.pdf <<< "Summarize this document"
./cli.py -b -f cv.pdf job.pdf <<< "Is this candidate a good fit?"
./cli.py -b -vf contracts/*.pdf <<< "Which contracts mention arbitration?"
./cli.py -vf docs/*.pdf # interactive Q&A session across a document collectionThe tool is quite powerful with guake drop-down terminal and alias like this:
alias gpt='$HOME/projects/chatgpt-gui/cli.py'More useful example to review patch of PR for currently checked out branch in the current
directory (expects gh client installed):
alias review='gh pr diff --patch | gpt -b -p $HOME/.pr-review'The .pr-review file contains:
Summarize and review the following patch:
./gui.pyBrowse past conversations and chat interactively with full Markdown rendering and syntax highlighting.
- Resizable panes — drag the separators between panels to adjust layout
- Sortable conversation list — click the column header to toggle sort order
- Keyboard shortcuts —
Enterto send,Shift+Enterfor a new line
whisper.py— transcribe audio using OpenAI's Whisper APIdale.py— generate images using DALL-E 3delete-file.py— delete one or more uploaded files by ID
./delete-file.py FILE_ID [FILE_ID ...]To run tests, install pytest:
pip3 install pytest
To run tests in parallel, install also pytest-xdist extension:
pip3 install pytest-xdist
Format, lint, and test with:
make format
make lint
make xtest # Remove x for sequential testRun a single test suite:
python -m pytest tests/e2e_test.py::TestBatchMode -vRun a single test case:
python -m pytest tests/e2e_test.py::TestBatchMode::test_batch_basic -vContributions are welcome! Please feel free to submit a pull request.
If you encounter any issues or have any questions, please open an issue on GitHub.