Crates.io | cgip |
lib.rs | cgip |
version | 0.2.11 |
source | src |
created_at | 2023-05-14 22:11:44.706826 |
updated_at | 2024-06-22 15:36:18.369557 |
description | Terminal client for interacting with Chat GPT that allows you to build and manipulate contexts |
homepage | |
repository | https://github.com/divanvisagie/chat-gipity |
max_upload_size | |
id | 864508 |
size | 442,395 |
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.
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
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.
cargo install cgip
If you don't have the tap, add it with:
brew tap divanvisagie/homebrew-tap
Install cgip with brew:
brew install cgip
Download this repository and then install the cgip
command using:
sudo make install
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
.
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.
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.
On ubuntu, some additional packages are required to build the deb package.
sudo apt-get install build-essential dh-make debhelper devscripts