A command-line interface for interacting with the ChatGPT API from OpenAI

Related tags

Command-line rust
Overview

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.

Comments
  • Do not send a request if the message is empty

    Do not send a request if the message is empty

    The below should show an error or message instead of the current behaviour:

    $ echo "" | cligpt
    I'm sorry, I am an AI language model and I do not understand what you are trying to communicate. Please provide more information or context for me to assist you better.
    
    opened by schneiderfelipe 1
  • Customize chat settings

    Customize chat settings

    cligpt should allow users to customize the chat settings, such as the number of responses to generate ~and the temperature parameter for generating responses~ (done in #8).

    opened by schneiderfelipe 1
  • Improve README.md

    Improve README.md

    • [x] Make the list of common use cases more practical
    • [x] Review usage examples
    • [ ] Add a terminal recording
    • [ ] Send modifications to main.rs

    Fix #18.

    opened by schneiderfelipe 0
  • Single chat management

    Single chat management

    • [x] Send message to chat
    • [x] Show current chat state
    • [x] Truncate chat to the most current topic in the conversation (uses a heuristic and embeddings)
    • [x] Store the chat somewhere safe

    EDIT: multiple chats will be left to a future PR.

    Fix #2.

    opened by schneiderfelipe 0
  • Make options more flexible

    Make options more flexible

    Ref. 🐦

    • [x] Support setting temperature
      • [x] Validate temperature
    • [x] Support setting model
    • [x] (Loosely) validate API key
    opened by schneiderfelipe 0
  • Accept context as positional parameters and also from the standard input

    Accept context as positional parameters and also from the standard input

    This allows the following:

    $ echo "(a nice one)." | cligpt Tell me a joke
    Why did the tomato turn red?
    
    Because it saw the salad dressing!
    

    What ChatGPT sees is

    Tell me a joke (a nice one).
    

    That is, positional arguments come before the standard input, and everything is single-space joined.

    opened by schneiderfelipe 0
  • Support Babbage

    Support Babbage

    This seems to be the only text completion model that makes sense supporting, as it costs 25% the price of GPT-3.5 Turbo.

    In particular, it makes no sense to support Curie or DaVinci, as they cost the same or more, and seem to perform more poorly than GPT-3.5 Turbo:

               model  prompt  completion  comparison  order
    7  Ada Embedding  0.0004      0.0004        0.20      0
    3            Ada  0.0004      0.0004        0.20      1
    4        Babbage  0.0005      0.0005        0.25      2
    5          Curie  0.0020      0.0020        1.00      3
    6        Davinci  0.0200      0.0200       10.00      4
    2  GPT-3.5 Turbo  0.0020      0.0020        1.00      5
    0       GPT-4 8K  0.0300      0.0600       30.00      6
    1      GPT-4 32K  0.0600      0.1200       60.00      7
    
    opened by schneiderfelipe 0
Releases(v0.3.0)
  • v0.3.0(Apr 4, 2023)

    🗨️ cligpt now manages chat! Context is saved between runs, and you can see the current session with cligpt show.

    cligpt recording

    Breaking changes

    What's Changed

    • No empty or all-whitespace strings by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/12
    • Single chat management by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/13
    • Improve README.md by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/14 and https://github.com/schneiderfelipe/cligpt/pull/19

    Full Changelog: https://github.com/schneiderfelipe/cligpt/compare/v0.2.0...v0.3.0

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Mar 28, 2023)

    Version v0.2.0 of cligpt 🎂, a command-line interface for interacting with the ChatGPT API from OpenAI.

    This version improves error handling, provides support for positional arguments as context , together with standard input, to be sent to ChatGPT, and makes it possible to choose models (cligpt supports GPT-4!) and sampling temperature with simple command-line options.

    Install with cargo install cligpt and don't forget to cligpt --help!.

    What's Changed

    • Accept context as positional parameters and also from the standard input by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/3
    • Create .github/FUNDING.yml by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/4
    • Improve error handling by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/6
    • Make options more flexible by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/8
    • Properly lock stdout and stdin by @schneiderfelipe in https://github.com/schneiderfelipe/cligpt/pull/9

    Full Changelog: https://github.com/schneiderfelipe/cligpt/compare/v0.1.0...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Mar 27, 2023)

    First release of cligpt 🎈

    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 from your terminal. Simply provide your OpenAI API key and the message you want to generate, and cligpt will handle the rest.

    This application started as a joke, namely, whether ChatGPT could help create an interface for itself, for the command-line. I described the process so far in a series of tweets.

    Full Changelog: https://github.com/schneiderfelipe/cligpt/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Felipe S. S. Schneider
A computational chemist and software developer. Formerly @geem-lab (@UFSC).
Felipe S. S. Schneider
ChatGPT-rs is a lightweight ChatGPT client with a graphical user interface, written in Rust

ChatGPT-rs is a lightweight ChatGPT client with a graphical user interface, written in Rust. It allows you to chat with OpenAI's GPT models through a simple and intuitive interface.

null 7 Apr 2, 2023
All in One AI Chat Tool( GPT-4 / GPT-3.5 /OpenAI API/Azure OpenAI)

WeChatAI Create All in One personal AI chat assistant English | 中文介绍 This project is not for reward and profit, only used for personal Screenshot Supp

null 38 Apr 25, 2023
Rust-based CLI library for OpenAI ChatGPT API

This is a Rust library that provides a CLI (command-line interface) for easy and convenient access to the OpenAI ChatGPT API. The library offers a simple and straightforward way to integrate the ChatGPT API into your Rust-based applications.

bigduu 10 Mar 9, 2023
A simple common-line interface for ChatGPT API.

heygpt A simple common-line interface for ChatGPT API. ?? Streaming output! ?? One-shot mode to get a quick answer ?? Interactive mode to have a conve

Eric Fu 88 Apr 17, 2023
ChatGPT-Code-Review is a Rust application that uses the OpenAI GPT-3.5 language model to review code

ChatGPT-Code-Review is a Rust application that uses the OpenAI GPT-3.5 language model to review code. It accepts a local path to a folder containing code, and generates a review for each file in the folder and its subdirectories.

Greg P. 15 Apr 22, 2023
SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

Gabriel Michaliszen 4 May 9, 2023
chatgpt from the command line 🤖💬

Talk to ChatGPT from your terminal. Quickstart First you'll need to install the CLI: cargo install chatgpt-cli Then, you'll need to make sure your ca

Juan Gonzalez 9 Mar 23, 2023
Koi is a simple tool built to let you use ChatGPT through the command line

Koi is a simple tool built to let you use ChatGPT through the command line. It adds the ability to let ChatGPT run commands on your computer in order to help you out, or to help you out with complicated tasks.

Shivam Sharma 9 Mar 28, 2023
a command-line tool that transforms a Git repository into a minimal format for ChatGPT queries

gprepo /dʒiːpiːˈɹi:pi:oʊ/ a command-line tool that transforms a Git repository into a minimal format for ChatGPT queries. Features Excludes LICENSE an

null 6 Apr 20, 2023
A simple command-line tool for conversing with ChatGPT

daberu A simple command-line tool for conversing with ChatGPT. "daberu" is a Japanese translation of "chatting". $ daberu -h ChatGPT client tool that

Takeru Ohta 4 Jun 4, 2023
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
A high-level, ergonomic crate for interacting with the UploadThing API

utapi-rs A high-level, ergonomic Rust crate for interacting with the Uploadthing API. Why? If you're using Rust and want to use Uploadthing for file u

Ivan Leon 4 Feb 2, 2024
A Rust client for OpenAI's API

libopenai - Rust client to interact with OpenAI's API Rust client for OpenAI's API, written with tokio and reqwest How to use To add libopenai to your

Alex 9 Mar 31, 2023
A simple Rust library for OpenAI API, free from complex async operations and redundant dependencies.

OpenAI API for Rust A community-maintained library provides a simple and convenient way to interact with the OpenAI API. No complex async and redundan

null 6 Apr 4, 2023
Experimental extension that brings OpenAI API to your PostgreSQL to run queries in human language.

Postgres <> ChatGPT Experimental PostgreSQL extension that enables the use of OpenAI GPT API inside PostgreSQL, allowing for queries to be written usi

CloudQuery 315 Apr 10, 2023
A CLI tool you can pipe code and then ask for changes, add documentation, etc, using the OpenAI API.

AiBro This is your own little coding bro, immersed in the world of AI, crypto, and all other types of over hyped tech trends. You can pipe it code and

Josh Bainbridge 5 Sep 5, 2023
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
Crunch is a command-line interface (CLI) to claim staking rewards every X hours for Substrate-based chains

crunch · crunch is a command-line interface (CLI) to claim staking rewards every X hours for Substrate-based chains. Why use crunch To automate payout

null 39 Dec 8, 2022