Introducing heygpt
heygpt
is an easy-to-use command-line interface designed for the ChatGPT API. This tool is perfect for anyone who wants to interact with ChatGPT directly from their terminal and is equipped with several features that enhance user experience.
Key Features
- Streaming Output:
heygpt
offers real-time streaming responses, providing immediate feedback as you interact with ChatGPT. - One-shot Mode: This feature allows users to get quick answers by submitting a single prompt, making it incredibly efficient for obtaining straightforward responses.
- Interactive Mode: With this mode, users can engage in an ongoing conversation with ChatGPT, similar to a chat experience.
A demonstration video showing how heygpt
works is available on YouTube.
Getting Started
To begin using heygpt
, you'll need to install the latest release version using cargo, which places the executable in your $HOME/.cargo/bin/
directory:
cargo install heygpt
Before you start, an OpenAI API key is necessary. You can procure one from OpenAI's API keys page. Once you have your key, export it as an environment variable:
export OPENAI_API_KEY=<your api key>
You may also optionally set an OpenAI API base URL:
# export OPENAI_API_BASE="https://api.openai.com/v1"
How to Use heygpt
Starting a conversation with ChatGPT is straightforward. Simply enter:
heygpt
For one-shot mode, you can provide a prompt directly:
heygpt how to record screen on mac
Advanced users can compose complex prompts by leveraging bash commands. Here are a few examples:
-
To have ChatGPT analyze code:
heygpt read the code and tell me what it is doing: $(cat src/main.rs)
-
To generate a commit message from your code changes:
heygpt read the code diff and write a commit message: $(git diff)
-
To translate a poem into English:
heygpt "please translate this poem to English: > 床前明月光, > 疑是地上霜。 > 举头望明月, > 低头思故乡。"
heygpt
can also be integrated with other command-line tools via pipes, enhancing its utility.
Advanced Usage
Interactive Mode Commands
While in interactive mode, users can access various commands by entering \?
:
user => \?
Available commands:
\?, \help: Show this help
\b, \back: Retract and back to the last user message
\h, \history: View current conversation history
Configuration
heygpt
supports configuration via a file located at $HOME/.heygpt.toml
. Within this file, users can set their preferred API model, base URL, and API key:
model = "gpt-4"
api_base_url = "https://some.openai.mirror/v1"
api_key = "your api key"
This makes heygpt
highly adaptable to different working environments and user preferences.
heygpt
seamlessly connects users to ChatGPT, offering a simplified yet powerful command-line experience that accommodates both quick queries and detailed, conversational exchanges.