Crates.io | cligpt |
lib.rs | cligpt |
version | 0.3.0 |
source | src |
created_at | 2023-03-27 18:22:38.175263 |
updated_at | 2023-04-04 19:12:30.472521 |
description | A command-line interface to talk to ChatGPT |
homepage | |
repository | https://github.com/schneiderfelipe/cligpt |
max_upload_size | |
id | 822368 |
size | 9,494,043 |
cligpt
is a command-line interface for interacting
with the ChatGPT
API from OpenAI
.
With cligpt
,
you can quickly and easily generate text by sending messages to ChatGPT
from your terminal.
Simply provide your OpenAI
API key and the message you want to generate,
and cligpt
will handle the rest.
cligpt
is written in Rust and uses the
clap
and
async-openai
crates
to provide a user-friendly interface for the ChatGPT
API.
Keep reading in order to learn how to install and
use cligpt
.
--model=gpt35
(ChatGPT
,
gpt-3.5-turbo
, default)--model=gpt4
(GPT-4, gpt-4
)Before installing cligpt
,
you need to make sure you have
Rust (version 1.65.0 or later)
and Cargo,
the package manager for Rust,
installed.
Once you have Rust and Cargo installed,
you can install cligpt
from crates.io using Cargo:
cargo install cligpt
This will download the necessary dependencies,
compile the cligpt
binary,
and install it in your system.
Once the installation is complete,
you can run cligpt
by typing cligpt
in your terminal.
That's it!
Alternatively,
you can install cligpt
directly from the GitHub repository
using Cargo by running:
cargo install --git=https://github.com/schneiderfelipe/cligpt.git
You can also build cligpt
from source by cloning the GitHub repository
and running cargo build
:
git clone https://github.com/schneiderfelipe/cligpt.git
cd cligpt
cargo build --release
After building,
the binary will be located at target/release/cligpt
.
Alternatively,
you can install the binary directly instead of just building it.
Just run cargo install --path=.
instead of cargo build --release
.
To use cligpt
,
you need to provide your
OpenAI
API key
and the message you want to generate.
You can provide the API key using the -k
or --api-key
option,
or by setting the OPENAI_API_KEY
environment variable.
Here's an example usage:
$ echo 'Hello, ChatGPT!' | cligpt --api-key YOUR_API_KEY
Hello there, how may I assist you today?
This will send the message 'Hello, ChatGPT!'
to the ChatGPT
API using
your API key and print the generated text to your terminal.
You can also specify additional options to customize the text generation, such as temperature, and the language model to use.
For example, you can set the temperature to 0.9 and use GPT-4:
$ echo 'Hello, ChatGPT!' | cligpt --temperature 0.9 --model gpt4
Hello! How can I help you today? If you have any questions or need assistance, feel free to ask.
In the example above, the API key will be read from the environment.
cligpt
supports receiving input only from the standard input:
$ echo "Repeat this message exactly how you read it" | cligpt
Repeat this message exactly how you read it.
cligpt
also stores a single chat session,
which can be viewed using
cligpt show
.
For example:
$ echo 'What is the capital of France?' | cligpt
The capital of France is Paris.
$ cligpt show
user:
What is the capital of France?
assistant:
The capital of France is Paris.
You can continue a conversation using the stored chat session:
$ echo "What is the city's population?" | cligpt
As of 2021, the population of Paris is estimated to be around 2.2 million people. However, the population of the greater Paris metropolitan area, which includes surrounding suburbs and municipalities, is estimated to be around 12 million people.
$ cligpt show
user:
What is the capital of France?
assistant:
The capital of France is Paris.
user:
What is the city's population?
assistant:
As of 2021, the population of Paris is estimated to be around 2.2 million people. However, the population of the greater Paris metropolitan area, which includes surrounding suburbs and municipalities, is estimated to be around 12 million people.
Chat context is managed by truncating the chat in some situations where we're confident we're only deleting irrelevant information. This is a conservative approach, so it might sometimes fail. If you notice issues with the chat context, please file an issue so we can address it.
For more information on available options,
run cligpt --help
.
Contributions to cligpt
are welcome!
If you find a bug,
have a feature request,
or want to contribute code,
please open an issue
or a pull request
on the GitHub repository.
cligpt
is released under the MIT License.