Skip to main content

A minimal GPT chat client in the terminal

Project description

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

https://github.com/tommyjtl/termchat/assets/1622557/fb5d111b-42fb-4899-aeb6-c97202847a6f

Specifiy a personality

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

https://github.com/tommyjtl/termchat/assets/1622557/9d4ae7d7-d62b-4e28-b428-6b676d3780aa

On-demand Terminal Q&A

python chat.py -q
🎬 Example usage

https://github.com/tommyjtl/termchat/assets/1622557/8b25b39f-3145-4ad8-886e-a39e3d165b9f

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

https://github.com/tommyjtl/termchat/assets/1622557/40162508-3263-406b-bb7e-27558ae8d618

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termq-0.1.6.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

termq-0.1.6-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file termq-0.1.6.tar.gz.

File metadata

  • Download URL: termq-0.1.6.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for termq-0.1.6.tar.gz
Algorithm Hash digest
SHA256 13bf6ed2261952e4c258ca8f320e761886cb8904fbfba234c3a61f0094eae298
MD5 41f8fb542a66b2f5871fcaab1bcd664f
BLAKE2b-256 600caff9c1d98d5030763c3ed434914848c840866300dc4b956cbc3cb3af8bed

See more details on using hashes here.

File details

Details for the file termq-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: termq-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for termq-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d9ed59c3ff358b227d1d047050a285f35c79a767c0edb5ab1e0ff716e95817aa
MD5 faa42e43aaeb519fc1f74f108bf918ef
BLAKE2b-256 4e81ab7576e62f0861e96641b63e0af16d56aaa869a33b872dacf63128b0aa80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page