A simple command-line interface for ChatGPT API.
- 🌟 Streaming output!
- 💡 One-shot mode to get a quick answer
- 🤖 Interactive mode to have a conversation
![screenshot](https://private-user-images.githubusercontent.com/10192522/255422982-68ee10a1-942d-47b1-8d13-2d5cef70b649.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQ3NzA0MDQsIm5iZiI6MTcxNDc3MDEwNCwicGF0aCI6Ii8xMDE5MjUyMi8yNTU0MjI5ODItNjhlZTEwYTEtOTQyZC00N2IxLThkMTMtMmQ1Y2VmNzBiNjQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTAzVDIxMDE0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZmZDBhZTQ4MWM4MGIxMmI2YWE3ZmI3N2IzNWU0NzNlOTg1NjlhMGE3MjBjYjk2ZGRiMjdiYWYwOTQ1N2QyMDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Zo_oXx0aOQJ0Ymy-iL6AckJOA5-sjPLn_U1vYUrHmg0)
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)
heygpt "please translate this poem to English:
> 床前明月光,
> 疑是地上霜。
> 举头望明月,
> 低头思故乡。"
You may even compose heygpt
with other CLI tools via pipes:
$ echo "It's late. I should go to bed" | heygpt | cowsay
______________________________________
/ Goodnight! Sleep well and have sweet \
\ dreams. /
--------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
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
heygpt
will load configurations from $HOME/.heygpt.toml
. You may also set API keys and base URL here. Example:
model = "gpt-4"
api_base_url = "https://some.openai.mirror/v1"
api_key = "your api key"