Skip to content

Repository files navigation

TermQ

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 termq-venv
source termq-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

Config setup

On first run, termq creates this config layout automatically:

~/.config/termq/
  characters/   # built-in presets copied from the package
  history/      # chat_history-YYYYMMDD-HHMMSS.json files

You can pass either a preset name (for example -c hal9000) or a full path to a custom character file.

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

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages