A simple common-line interface for ChatGPT API.

Overview

heygpt

A simple common-line interface for ChatGPT API.

  • 🌟 Streaming output!
  • 💡 One-shot mode to get a quick answer
  • 🤖 Interactive mode to have a conversation

screenshot

Demo (YouTube)

Quickstart

Install latest release version to $HOME/.cargo/bin/ via cargo:

cargo install heygpt

You'll need a OpenAI API key (you can get one here), and you'll need to export your API Key as an environment variable:

You can also set a OpenAI API base environment variable, just like openai-python

export OPENAI_API_KEY=<your api key>
# export OPENAI_API_BASE="https://api.openai.com/v1"

Then you can start an interactive conversation with ChatGPT:

heygpt

OR use the one-shot mode by providing a prompt:

heygpt how to record screen on mac

You can also compose prompt with bash tricks like

heygpt read the code and tell me what it is doing: $(cat src/main.rs)
heygpt read the code diff and write a commit message: $(git diff)

You may need write prompt in multiple lines:

heygpt "please translate this poem to English:
> 床前明月光,
> 疑是地上霜。
> 举头望明月,
> 低头思故乡。"

Advanced

Commands in interactive mode

Enter \? to see available commands:

user => \?
Available commands:
  \?, \help: Show this help
  \b, \back: Retract and back to the last user message
  \h, \history: View current conversation history
Comments
  •  assistant => Error: EventSource stream error: Invalid status code: 400 Bad Request exit 1

    assistant => Error: EventSource stream error: Invalid status code: 400 Bad Request exit 1

    Thanks for this awesome project and it works super fast and lightweight. Just found an error occurs several times as below and subject: "assistant => Error: EventSource stream error: Invalid status code: 400 Bad Request exit 1" and the program will be quit after the above error, the way to solve it is just launch the program again.

    btw: My network is stable and confirmed no problem when the error occurred.

    opened by deadjoe 4
  • Doesn't work with command result substitution as expected

    Doesn't work with command result substitution as expected

    Hello! Thank you for tool! Try to to work with command result (example below contains command from README), it doesn't work as expected. heygpt try ti explain bash command instead of command result

    image
    opened by ravecat 1
  • Support system prompt

    Support system prompt

    1. One-shot mode
    $ heygpt --system="You are a helpful assistant." "Who won the world series in 2020?"
    The Los Angeles Dodgers won the World Series in 2020.
    
    1. Interactive mode:
    $ heygpt --system
    system => You are a helpful assistant.
    user => Who won the world series in 2020?
    assistant => The Los Angeles Dodgers won the World Series in 2020, beating the Tampa Bay Rays in six games.
    user =>
    
    1. Interactive mode provided system prompt:
    $ heygpt --system="You are a helpful assistant."
    user => Who won the world series in 2020?
    assistant => The Los Angeles Dodgers won the World Series in 2020, claiming their first championship title since 1988.
    user =>
    
    opened by fuyufjh 0
  • Interactive mode is glitchy on windows regarding whitespace, there's a 10 space wide gap

    Interactive mode is glitchy on windows regarding whitespace, there's a 10 space wide gap

    When I start it on Windows in interactive mode, there is a bunch of whitespace between > and my cursor: image

    When I start typing, it appends the chars at the cursor but when I press backspace at some point, it "un-indents" the prompt, but now there is a gap in the middle of the prompt! image

    When I type more, it appends at the end, but when I press backspace again, it shifts the whitespace gap to be directly before the cursor. This gap seems to be always 10 spaces wide: image

    Also initially: image

    opened by Boscop 0
  • Could not compile 'tokio' and 'futures-util' during installation.

    Could not compile 'tokio' and 'futures-util' during installation.

    Hi! I have tried to install heygpt with the provided instruction on Mac OS X Monterey 12.6. I never worked with Rust before, so I installed it using the instruction here. I tried to install heygpt in my user directory. After several packages downloaded and compiled, I got an error

    error: could not compile `tokio`
    
    Caused by:
      process didn't exit successfully: `rustc --crate-name tokio --edition=2021 /Users/markovivl/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.27.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=68 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="bytes"' --cfg 'feature="default"' --cfg 'feature="fs"' --cfg 'feature="io-util"' --cfg 'feature="libc"' --cfg 'feature="macros"' --cfg 'feature="mio"' --cfg 'feature="net"' --cfg 'feature="rt"' --cfg 'feature="socket2"' --cfg 'feature="sync"' --cfg 'feature="time"' --cfg 'feature="tokio-macros"' -C metadata=a88c4d269f76a536 -C extra-filename=-a88c4d269f76a536 --out-dir /var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps -L dependency=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps --extern bytes=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libbytes-457a94e2651dd7fa.rmeta --extern libc=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/liblibc-b57044baa5c73053.rmeta --extern mio=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libmio-6db8df63c1758cee.rmeta --extern pin_project_lite=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libpin_project_lite-5e5abf9a6042fdb7.rmeta --extern socket2=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libsocket2-1097afa61ce4f787.rmeta --extern tokio_macros=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libtokio_macros-4f5bbd4a25938c82.dylib --cap-lints allow` (signal: 9, SIGKILL: kill)
    warning: build failed, waiting for other jobs to finish...
    

    And another one

    error: could not compile `futures-util`
    
    Caused by:
      process didn't exit successfully: `rustc --crate-name futures_util --edition=2018 /Users/markovivl/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=68 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="alloc"' --cfg 'feature="async-await"' --cfg 'feature="async-await-macro"' --cfg 'feature="channel"' --cfg 'feature="futures-channel"' --cfg 'feature="futures-io"' --cfg 'feature="futures-macro"' --cfg 'feature="futures-sink"' --cfg 'feature="io"' --cfg 'feature="memchr"' --cfg 'feature="sink"' --cfg 'feature="slab"' --cfg 'feature="std"' -C metadata=dcec59d26a5bc913 -C extra-filename=-dcec59d26a5bc913 --out-dir /var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps -L dependency=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps --extern futures_channel=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libfutures_channel-be318e1b4de7f831.rmeta --extern futures_core=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libfutures_core-c4a22a57b33b01bb.rmeta --extern futures_io=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libfutures_io-6575827260aa6f9c.rmeta --extern futures_macro=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libfutures_macro-06726670cfedfc00.dylib --extern futures_sink=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libfutures_sink-9965e8a6da7c04c2.rmeta --extern futures_task=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libfutures_task-cc11e44101c03dee.rmeta --extern memchr=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libmemchr-848d3714c5fd2ab7.rmeta --extern pin_project_lite=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libpin_project_lite-5e5abf9a6042fdb7.rmeta --extern pin_utils=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libpin_utils-9fc140aebbff8f37.rmeta --extern slab=/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2/release/deps/libslab-be7a4faf69b2ca30.rmeta --cap-lints allow` (signal: 9, SIGKILL: kill)
    error: failed to compile `heygpt v0.3.0`, intermediate artifacts can be found at `/var/folders/5j/13jy1dkd6nl1sk7fssjxc_jc0000gn/T/cargo-installnHtKO2`
    

    After that the installation crashed. Quick googling did not help me to identify the problem.

    opened by markovivl 0
Releases(v0.3.0)
Owner
Eric Fu
Database system developer
Eric Fu
A command-line interface for interacting with the ChatGPT API from OpenAI

cligpt cligpt is a command-line interface for interacting with the ChatGPT API from OpenAI. With cligpt, you can quickly and easily generate text by s

Felipe S. S. Schneider 6 Apr 4, 2023
This is a simple command-line interface tool that allows you to interact with ChatGPT from OpenAI or Azure.

HeyGPT This is a simple command-line interface tool that allows you to interact with ChatGPT from OpenAI or Azure. You can use it to: Chat with ChatGP

Philip 5 Mar 28, 2023
Koi is a simple tool built to let you use ChatGPT through the command line

Koi is a simple tool built to let you use ChatGPT through the command line. It adds the ability to let ChatGPT run commands on your computer in order to help you out, or to help you out with complicated tasks.

Shivam Sharma 9 Mar 28, 2023
A simple command-line tool for conversing with ChatGPT

daberu A simple command-line tool for conversing with ChatGPT. "daberu" is a Japanese translation of "chatting". $ daberu -h ChatGPT client tool that

Takeru Ohta 4 Jun 4, 2023
Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're working with files or directories, this tool simplifies common file operations with ease.

Rust FileOps Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're w

Harikesh Ranjan Sinha 5 May 2, 2024
SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

Gabriel Michaliszen 4 May 9, 2023
chatgpt from the command line 🤖💬

Talk to ChatGPT from your terminal. Quickstart First you'll need to install the CLI: cargo install chatgpt-cli Then, you'll need to make sure your ca

Juan Gonzalez 9 Mar 23, 2023
a command-line tool that transforms a Git repository into a minimal format for ChatGPT queries

gprepo /dʒiːpiːˈɹi:pi:oʊ/ a command-line tool that transforms a Git repository into a minimal format for ChatGPT queries. Features Excludes LICENSE an

null 6 Apr 20, 2023
Rust-based CLI library for OpenAI ChatGPT API

This is a Rust library that provides a CLI (command-line interface) for easy and convenient access to the OpenAI ChatGPT API. The library offers a simple and straightforward way to integrate the ChatGPT API into your Rust-based applications.

bigduu 10 Mar 9, 2023
A tool for chatting using the ChatGPT API, written in Rust CLI.

ChatGPT CLI A tool for chatting using the ChatGPT API, written in Rust CLI. You can use this tool to chat, just by setting your API Key. You can modif

null 6 Apr 5, 2023
Provide free GPT-3.5 API service by reverse engineering the login-free ChatGPT website.

ChatGPT Free API Provide free GPT-3.5 API service by reverse engineering the login-free ChatGPT website. Note: This service requires the IP to be able

null 21 May 5, 2024
A common library and set of test cases for transforming OSM tags to lane specifications

osm2lanes See discussion for context. This repo is currently just for starting this experiment. No license chosen yet. Structure data tests.json—tests

A/B Street 29 Nov 16, 2022
Rust-clippy - A bunch of lints to catch common mistakes and improve your Rust code

Clippy A collection of lints to catch common mistakes and improve your Rust code. There are over 450 lints included in this crate! Lints are divided i

The Rust Programming Language 8.7k Dec 31, 2022
This repo contains crates that are used to create the micro services and keep shared code in a common place.

MyEmma Helper Crates This repo contains crates that can are reused over different services. These crate are used in projects at MyEmma. But these crat

MyEmma 1 Jan 14, 2022
Work in progress NCBI's Common Tree alternative in the terminal

Lomanai Usage lomanai --species 'Mus musculus' --species 'Homo sapiens' #> Mammalia #> ++Rodentia #> | \-Mus musculus #> \+Primates #> \-Homo sapien

Jean Manguy 3 Dec 20, 2022
A library to provide abstractions to access common utilities when developing Dioxus applications.

?? Dioxus Standard Library ?? A platform agnostic library for supercharging your productivity with Dioxus. dioxus-std is a Dioxus standard library tha

Miles Murgaw 5 Nov 9, 2022
Universal Windows library for discovering common render engines functions. Supports DirectX9 (D3D9), DirectX10 (D3D10), DirectX11 (D3D11), DirectX12 (D3D12).

Shroud Universal library for discovering common render engines functions. Supports DirectX9 (D3D9), DirectX10 (D3D10), DirectX11 (D3D11), DirectX12 (D

Chase 6 Dec 10, 2022
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022