Skip to content

Commit

Permalink
docs(README.md): finish the work of #14 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiderfelipe authored Apr 4, 2023
1 parent bf20355 commit 78e6106
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 30 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![dependency status](https://deps.rs/repo/github/schneiderfelipe/cligpt/status.svg)](https://deps.rs/repo/github/schneiderfelipe/cligpt)

![cligpt recording](cligpt.gif)

`cligpt` is a command-line interface for interacting
with the `ChatGPT` API from `OpenAI`.
With `cligpt`,
Expand All @@ -16,11 +18,13 @@ and
[`async-openai`](https://github.com/64bit/async-openai) crates
to provide a user-friendly interface for the `ChatGPT` API.

**Keep reading in order to learn how to [install](#installation) and [use](#usage) `cligpt`.**
**Keep reading in order to learn how to [install](#installation) and
[use](#usage) `cligpt`.**

## Available models

- `--model=gpt35` ([ChatGPT](https://openai.com/blog/introducing-chatgpt-and-whisper-apis), [`gpt-3.5-turbo`](https://platform.openai.com/docs/guides/chat), default)
- `--model=gpt35` ([`ChatGPT`](https://openai.com/blog/introducing-chatgpt-and-whisper-apis),
[`gpt-3.5-turbo`](https://platform.openai.com/docs/guides/chat), default)
- `--model=gpt4` ([GPT-4](https://openai.com/product/gpt-4), [`gpt-4`](https://platform.openai.com/docs/guides/chat))

## Common use cases
Expand Down Expand Up @@ -56,7 +60,7 @@ 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!*
_That's it!_

### Directly from [GitHub](https://github.com/schneiderfelipe/cligpt)

Expand Down Expand Up @@ -127,7 +131,10 @@ $ 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:
`cligpt` also stores a single chat session,
which can be viewed using
`cligpt show`.
For example:

```console
$ echo 'What is the capital of France?' | cligpt
Expand Down Expand Up @@ -161,7 +168,12 @@ 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](https://github.com/schneiderfelipe/cligpt/issues/new) so we can address it.
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](https://github.com/schneiderfelipe/cligpt/issues/new) so we can address it.

For more information on available options,
run `cligpt --help`.
Expand Down
Binary file added cligpt.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 76 additions & 25 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! [![dependency status](https://deps.rs/repo/github/schneiderfelipe/cligpt/status.svg)](https://deps.rs/repo/github/schneiderfelipe/cligpt)
//!
//! ![cligpt recording](cligpt.gif)
//!
//! `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 prompts to `ChatGPT`
//! 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.
Expand All @@ -13,10 +15,23 @@
//! and
//! [`async-openai`](https://github.com/64bit/async-openai) crates
//! to provide a user-friendly interface for the `ChatGPT` API.
//! It's perfect for developers who want
//! to quickly prototype text generation applications
//! or for anyone who wants to experiment with the power of the `ChatGPT` API
//! from the comfort of their terminal.
//!
//! **Keep reading in order to learn how to [install](#installation) and
//! [use](#usage) `cligpt`.**
//!
//! # Available models
//!
//! - `--model=gpt35` ([`ChatGPT`](https://openai.com/blog/introducing-chatgpt-and-whisper-apis),
//! [`gpt-3.5-turbo`](https://platform.openai.com/docs/guides/chat), default)
//! - `--model=gpt4` ([GPT-4](https://openai.com/product/gpt-4), [`gpt-4`](https://platform.openai.com/docs/guides/chat))
//!
//! # 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
//!
Expand All @@ -43,6 +58,7 @@
//! 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](https://github.com/schneiderfelipe/cligpt)
//!
Expand Down Expand Up @@ -83,8 +99,9 @@
//!
//! Here's an example usage:
//!
//! ```bash
//! cligpt --api-key YOUR_API_KEY 'Hello, ChatGPT!'
//! ```console
//! $ 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
Expand All @@ -97,33 +114,67 @@
//! For example,
//! you can set the temperature to 0.9 and use GPT-4:
//!
//! ```bash
//! cligpt --temperature 0.9 --model gpt4 'Hello, ChatGPT!'
//! ```console
//! $ 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.
//!
//! For more information on available options,
//! run `cligpt --help`.
//! `cligpt` supports receiving input only from the standard input:
//!
//! ```console
//! $ echo "Repeat this message exactly how you read it" | cligpt
//! Repeat this message exactly how you read it.
//! ```
//!
//! # Design decisions
//! `cligpt` also stores a single chat session,
//! which can be viewed using
//! `cligpt show`.
//! For example:
//!
//! The primary goal of `cligpt` is to provide a user-friendly experience.
//! For this reason,
//! it is designed to generate only a single response,
//! whose maximum length is determined by the
//! [`OpenAI` API endpoint](https://platform.openai.com/docs/api-reference/chat/create#chat/create-max_tokens).
//! ```console
//! $ echo 'What is the capital of France?' | cligpt
//! The capital of France is Paris.
//!
//! As a command-line application,
//! `cligpt` allows for the use of
//! [pipes and redirections](https://askubuntu.com/q/172982/361183)
//! to load and save prompts and generated text,
//! making such features of limited use in `cligpt`.
//! $ cligpt show
//! user:
//! What is the capital of France?
//!
//! Lastly,
//! `cligpt` only supports the
//! [chat completion endpoint](https://platform.openai.com/docs/api-reference/chat/create#chat/create-model).
//! assistant:
//! The capital of France is Paris.
//! ```
//!
//! You can continue a conversation using the stored chat session:
//!
//! ```console
//! $ 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](https://github.com/schneiderfelipe/cligpt/issues/new) so we can address it.
//!
//! For more information on available options,
//! run `cligpt --help`.
//!
//! # Contributing
//!
Expand Down

0 comments on commit 78e6106

Please sign in to comment.