Skip to content

tearingItUp786/chatgpt-tui

Repository files navigation

ChatGPT tui README

My first ever terminal UI! Everything is stored locally on sqlite and written in Go!

Technologies

  • Go
  • bubbletea: A Go framework for terminal user interfaces. It's a great framework that makes it easy to create TUIs in Go.
  • openai: OpenAI's REST Api
  • sqlite: A C library that provides a lightweight disk-based database that doesn't require a separate server process (perfect for terminal apps, in my opinion).
  • lipgloss: Style definitions for nice terminal layouts!
  • bubbles: Some general use components for Bubble Tea apps!

Installation

Please make sure that you expose a OPENAI_API_KEY inside of your environment; we require it to make api calls!

Set up your api key

export OPENAI_API_KEY="some-key" # you would want to export this in your .zshrc
brew tap tearingitup786/tearingitup786
brew install chatgpt-tui
chatgpt-tui

To get access to the release candidates, install command:

brew install rc-chatgpt-tui
rc-chatgpt-tui

Config

We provide a config.json file within your directory for easy access to essential settings. On most Macs, the path is ~/.chatgpt-tui/config.json. This file includes the URL used for network calls to the TUI, specified as chatGPTApiUrl: "https://api.openai.com". The url can be anything that follows OpenAI API standard ( ollama, lmstudio, etc) Additional fields:

  • systemMessage field is available for customizing system prompt messages.
  • defaultModel field sets the default model

Themes

You can change colorscheme using the colorScheme field. Possible options are Pink and Blue. Default colorscheme is Pink

Cache invalidation

Models list is cached for 14 days upon loading. If you need to invalidate cache use --purge-cache flag:

./chatgpt-tui --purge-cache

Demo

tui demo

Global Keybindings

  • Tab: *Change focus between panes. The currently focused pane will be highlighted with a pink border.
    • You can only change focus if Prompt Pane is not in insert mode
  • Ctrl+o: Toggles zen mode
  • Ctrl+c: Exit the program

Prompt Pane

  • i: Enters insert mode (you can now safely paste messages into the tui)
  • esc: Exit insert mode for the prompt

Chat Messages Pane

  • y: Copies the last message from ChatGPT into your clipboard.
  • Shift+y: Copies all messages from the ChatGPT session into your clipboard.
  • v: Enters navigation mode when chat pane is focused (allows to move accross the chat content lines)

Selection mode

selection demo

Selection mode allows to navigate the chat pane and select lines to copy. Supports basic vim-motions.

Navigation

  • j, k - go down and up a line
    • Multiline jumps like 3j (3 lines down), 99k (99 lines up) are also supported
  • d, u, Ctrl+d, Ctrl+u - go up or down half page
  • g - go to top
  • Shift+g - go to bottom

Selection

  • v, Shift+v or space to enter or quit line selection mode
  • y to copy selected text
  • Esc to quit selection or navigation modes

Settings Pane

  • m: Opens a model picker to change the model. (use j to go up and k to go down the list)
  • f: Opens an input dialog to change the frequency of updates.
  • t: Opens an input dialog to set the maximum number of tokens per message.

Sessions Pane

  • Ctrl+N: Creates a new session.
  • d: Deletes the currently selected session from the list.
  • e: Edit session name
  • Enter: Switches to the session that is currently selected.

Info pane

Information pane displays processing state of inference (IDLE, PROCESSING) as well as token stats for the current session:

  • IN: shows the total amount of input tokens LLM consumed per session
  • OUT: shows the total amount of output tokens LLM produced per session

Please refer to this guide as you navigate the TUI. Happy exploring!

Dev notes

The SQL db is stored in you your/home/directory/.chatgpt-tui, as well as the debug log. To enable debug mode, export DEBUG=1 before running the program.

Contributors

Taranveer (Taran) Bains
Taranveer (Taran) Bains

📖 🚧 👀 💻
TJ Miller
TJ Miller

📖 💻
BalanceBalls
BalanceBalls

📖 💻