cligpt

Crates.iocligpt
lib.rscligpt
version0.3.0
sourcesrc
created_at2023-03-27 18:22:38.175263
updated_at2023-04-04 19:12:30.472521
descriptionA command-line interface to talk to ChatGPT
homepage
repositoryhttps://github.com/schneiderfelipe/cligpt
max_upload_size
id822368
size9,494,043
Felipe S. S. Schneider (schneiderfelipe)

documentation

README

cligpt

dependency status

cligpt recording

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.

Available models

Common use cases

  • Generate creative writing ideas or brainstorm topics.
  • Get assistance with answering questions about specific subjects.
  • Draft emails or other professional writing pieces.
  • Summarize lengthy texts.
  • Translate text between different languages.

Installation

Requirements

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.

From crates.io (recommended)

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!

Directly from GitHub

Alternatively, you can install cligpt directly from the GitHub repository using Cargo by running:

cargo install --git=https://github.com/schneiderfelipe/cligpt.git

By cloning the GitHub repository

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.

Usage

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.

Contributing

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.

License

cligpt is released under the MIT License.

Commit count: 39

cargo fmt