Skip to content

tommyjtl/termchat

Repository files navigation

TermChat

License: MIT unstable

A minimal GPT chat client in the terminal. A toy experiment with OpenAI's GPT API.

All code have only tested on macOS, not guaranteed to work on other platforms.

Prerequisites

export OPENAI_API_KEY=<your key>
python -m termchat-venv
source termchat-venv/bin/activate
pip install -r requirements.txt
# Optional, for PDF OCR if you want multi-language support
# Read more here: https://github.com/ocrmypdf/OCRmyPDF#languages
brew install tesseract-lang

Running

Usage: python script.py [OPTIONS]

Options:
  -c, --load-character FILE     Specify a character file location.
  --stream                      Enable streaming mode.
  -e, --load-engine TYPE        Specify an engine type, default is `gpt-3.5-turbo`.
  --tts                         Enable text-to-speech.
  -q, --question                Ask a question to the chatbot and get an answer directly.
  --help                        Show this message and exit.

Chat with GPT

Default Assistant

python chat.py
🎬 Example usage
chat1.mp4

Specifiy a personality

python chat.py -c <character>
🎬 Example usage
chat2.mp4

On-demand Terminal Q&A

python chat.py -q
🎬 Example usage
Screen.Recording.2023-07-10.at.14.11.55.mov

Chat with PDF

# Normal usage
python pdf.py -f <file>

# Add --ocr if your PDF doesn't have text layer, default OCR language is English
python pdf.py -f <file> --ocr

# Add --ocr-lang to specify OCR language
# For <lang>, use 3-digit ISO 639-2 Code, see more here: https://github.com/tesseract-ocr/tessdata
python pdf.py -f <file> --ocr --ocr-lang <lang>
🎬 Example usage
Screen.Recording.2023-07-10.at.14.08.57.mov

Acknowledgments

About

Chat with GPT in the terminal.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages