#chatgpt #chat-client #terminal #language #session #context #language-model

app cgip

Terminal client for interacting with Chat GPT that allows you to build and manipulate contexts

17 releases

0.2.8 Jun 9, 2024
0.2.7 Jun 2, 2024
0.2.6 May 26, 2024
0.2.1 Sep 27, 2023
0.1.2 May 28, 2023

#57 in Machine learning

Download history 11/week @ 2024-02-26 6/week @ 2024-03-11 21/week @ 2024-04-01 160/week @ 2024-04-29 162/week @ 2024-05-06 130/week @ 2024-05-13 144/week @ 2024-05-20 142/week @ 2024-05-27 110/week @ 2024-06-03 151/week @ 2024-06-10

558 downloads per month

GPL-2.0 license

350KB
961 lines

Chat Gipity

crates.io

Chat Gipity is a command line client for ChatGPT. It allows you to chat with your chosen model of ChatGPT in a terminal and even pipe output into it. The default model is GPT-4.

Logo

For example, say you wanted to debug your Rust program that doesn't compile and want ChatGPT to explain the error in depth, you can pipe the output through Chat Gipity to help you debug like this, which would directly use the build error output as the prompt:

cargo build 2>&1 | cgip

This would result in something like the following

 cargo build 2>&1 | cgip 'give me a short summary of the kind of error this is'
The error you're encountering is a **lifetime error** in Rust, specifically an issue with **borrowed values not living long enough**.
**borrowed values not living long enough**.

Another usage is reading from a file. In this example, we read from a file and ask ChatGPT to convert that file to another programming language:

"convert this to python" -f src/main.rs 

Installation

chat-gipity is designed to be run on POSIX compliant systems, you have mutliple options for installing released versions depending on your system. All systems should be able to install from source or from cargo, but a homebrew tap is also available as well as a debian package attacked to the github releases.

Install from crates.io with cargo

cargo install cgip 

Install via homebrew

If you don't have the tap, add it with:

brew tap divanvisagie/homebrew-tap 

Install cgip with brew:

brew install cgip

Manual Installation

Download this repository and then install the cgip command using:

sudo make install 

Set up API Key

Next, set up your OpenAI key by exporting it as OPENAI_API_KEY:

export OPENAI_API_KEY=your_key_here 

You can now pipe data to cgip. Remember to use 2>&1 to convert stderr to stdout if you are debugging, as it can only read stdin.

Session management

The session feature allows for continuous chat session management and shell integration. To enable session caching in your terminal, you need to provide the environment variable CGIP_SESSION_NAME. The uniqueness of your session is dependant on the value of this variable.

This can be done by generating a session id for cgip to use in your .bashrc or .zshrc:

export CGIP_SESSION_NAME=$(uuid)

The user has control over how unique their session is, for example to have a new session for every new terminal opened you can use uuid:

export CGIP_SESSION_NAME=$(uuid) 

However if you want the session to work across terminals you may do something like us the date as a session id instead:

export CGIP_SESSION_NAME=$(date -I)

This implementation allows users to decide how they want to manage their sessions and gives full control for them to have complex session management if required without cluttering cgip with session management features.

Session Subcommand Usage

The session subcommand provides options for managing the current session context, you can use it to either view or clear the session, this can sometimes be useful if the context has become too long, or if the LLM has become confused by the context.

Development Setup

Ubuntu

On ubuntu, some additional packages are required to build the deb package.

sudo apt-get install build-essential dh-make debhelper devscripts 

Dependencies

~21–37MB
~463K SLoC