Giter VIP home page Giter VIP logo

gptui's Introduction

GPTui

GPTui is a fairly simple TUI for interacting with the OpenAI Chat Completions API.

Why does this exist?

I prefer the question-and-answer style of interaction with LLMS for programming assistance (as opposed to something like Copilot's autocomplete), and I wanted to make an interface designed with that in mind, that could also slot into my existing CLI/TUI based workflow. If you're a fellow vim/tmux/alacritty enjoyer, consider giving it a shot!

Features

  • Token streaming for that cool ChatGPT vibe
  • Optionally provide your API key at compile time, so you don't need to futz with environment variables later
  • Configure custom prompts and other settings in a TOML config file
  • Chat history is saved to a local Sqlite database for later
  • Syntax highlighting in code blocks
  • Copy code block content to your system clipboard
  • Optionally compose messages in your favorite text editor (ctrl-e to open)
  • All in 100% safe, blazingly fast rust! (blazing-fastness may vary based on network conditions)

Authentication

You'll need an OpenAI API key to get started. Anecdotally, GPTui is pretty cheap, even with heavy usage, since it's all text and doesn't use any of the multi-modal bells and whistles of the API. You can provide your API key in one of two ways:

  • As an environment variable: The program will look for an OPENAI_API_KEY environment variable at runtime by default; you can change the name of this variable in config.toml (see below for more on that.)
  • Provided at compile time:, If you build with the comptime-key feature enabled, the value of OPENAI_API_KEY will be read and compiled into the binary itself. This means you don't have to keep the key in the environment, but if you change your key you'll need to recompile.

Config

When first run, a commented config.toml file will be generated wherever config files belong on your platform (on Linux it's $XDG_CONFIG_HOME).

CLI

Start a new conversation thread
Usage: gpt new [OPTIONS]

Options:
  -p, --prompt <PROMPT>  Prompt to use
  -h, --help             Print help
Resume a previous conversation
Usage: gpt resume <INDEX>

Arguments:
  <INDEX>  

Options:
  -h, --help  Print help
Delete a conversation thread permanently
Usage: gpt delete <INDEX>

Arguments:
  <INDEX>  

Options:
  -h, --help  Print help

List all saved threads
Usage: gpt list

Options:
  -h, --help  Print help
Delete all conversation threads
Usage: gpt clear

Options:
  -h, --help  Print help

Key Bindings

  • Alt-Enter: submit message
  • Ctrl-e: Open the message buffer in an external editor ($EDITOR if available, a safe default for the platform if not). Save and quit the editor window when you're done to return.
  • Ctrl-w: Enter copy mode
    • In copy mode, enter the number of a code block and press Enter to copy its contents to the system clipboard.
  • Esc: Exit copy mode
  • Up/Down: Scroll the chat history
  • Ctrl-c: Exit the program

Roadmap/Wishlist

  • External editor support
  • Syntax highlighting
  • Copy code blocks to clipboard on:
    • Windows
    • Linux (X11)
    • Linux (Wayland) (partially working)
    • MacOS (I can't test this without a Mac, but I think it has a good chance of working already)
  • Document key bindings in the UI itself
  • Replace CLI for selecting a thread with a TUI screen?

gptui's People

Contributors

keagud avatar

Stargazers

 avatar Aaron Tsui avatar

Watchers

 avatar

gptui's Issues

Sqlite connection stays open when terminal emulator is closed

Platform: Debian 12 WSL in Windows 11 (Windows Terminal)

When the host terminal emulator is closed, the process continues to run detached, spiking CPU usage on its host core to 100%.
Inspecting /proc shows the file descriptor for the Sqlite connection remains open.

Sending SIGINT manually to the process triggers the same behavior. SIGTERM works as expected with the db connection properly closed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.