1 unstable release
0.1.0 | Jun 2, 2023 |
---|
#75 in #chatgpt
14KB
251 lines
daberu
A simple command-line tool for conversing with ChatGPT.
"daberu" is a Japanese translation of "chatting".
$ daberu -h
ChatGPT client tool that reads your message from stdin and writes the response to stdout
Usage: daberu [OPTIONS] --api-key <OPENAI_API_KEY>
Options:
--api-key <OPENAI_API_KEY> OpenAI API key [env: OPENAI_API_KEY]
--log <LOG_FILE_PATH> Log file path to save the conversation history. If the file already exists, the history will be considered in the next conversation
--model <MODEL> ChatGPT model name [env: CHATGPT_MODEL=] [default: gpt-3.5-turbo] [possible values: gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301]
--system <SYSTEM_MESSAGE> If specified, the system role message will be added to the beginning of the conversation [env: CHATGPT_SYSTEM_MESSAGE=]
--verbose If specified, HTTP request and response body JSONs are printed to stderr
-h, --help Print help
-V, --version Print version
Installation
$ cargo install daberu
Usage Examle
$ export OPENAI_API_KEY="YOUR API KEY"
// Conversation without history.
$ echo hi | daberu
Hello! How can I assist you today?
// Conversation with history.
$ echo "Translate to Japanese: 'hi'" | daberu --log chat.log
こんにちは
$ echo "Next, translate to Spanish" | daberu --log chat.log
hola
$ jq . chat.log
[
{
"role": "user",
"content": "Translate to Japanese: 'hi'\n"
},
{
"role": "assistant",
"content": "こんにちは"
},
{
"role": "user",
"content": "Next, translate to Spanish\n"
},
{
"role": "assistant",
"content": "hola"
}
]
References
Dependencies
~3.5–5MB
~122K SLoC