No description
Find a file
2023-10-07 09:29:33 +01:00
.github/workflows let's see what codeql sees 2023-03-13 17:20:47 -05:00
LICENSES let's see what codeql sees 2023-03-13 17:20:47 -05:00
src/chap Add huggingface back-end 2023-09-29 10:14:05 -05:00
.gitignore ignore dist directory 2023-03-12 10:36:50 -05:00
.pre-commit-config.yaml Add backend option help 2023-09-24 10:56:28 -05:00
.pylintrc Move chap commands to a subfolder 2023-03-13 14:46:15 -05:00
chap.gif update the screncast 2023-04-04 15:08:28 -05:00
chap.gif.license add a (slightly wonky) screencast 2023-03-12 10:06:59 -05:00
chap.py this script allows python -mchap in top-level to work 2023-10-07 08:19:25 +01:00
pyproject.toml Dynamically load requirements.txt in pyproject.toml 2023-10-02 03:57:58 -05:00
README.md fix markdown 2023-10-07 09:29:33 +01:00
requirements-dev.txt Dynamically load requirements.txt in pyproject.toml 2023-10-02 03:57:58 -05:00
requirements.txt Dynamically load requirements.txt in pyproject.toml 2023-10-02 03:57:58 -05:00

Test Release chap PyPI

chap - A Python interface to chatgpt and other LLMs, including a terminal user interface (tui)

Chap screencast

System requirements

Chap is developed on Linux with Python 3.11. Due to use of the list[int] style of type hints, it is known not to work on 3.8 and older; the target minimum Python version is 3.9 (debian oldstable).

Installation

Install with e.g., pipx install chap, or pip install chap in a virtual environment.

Installation for development

Install in developer mode e.g., with pip install -e .. In this mode, you get the "chap" commandline program installed but can edit the source files in place. This is the recommended practice per PyPA.

A shim script chap.py is included so that the older development style of pip install -r requirements.txt + python chap.py (or ./chap.py) functions as well.

Configuration

Put your OpenAI API key in the platform configuration directory for chap, e.g., on linux/unix systems at ~/.config/chap/openai_api_key

Commandline usage

  • chap ask "What advice would you give a 20th century human visiting the 21st century for the first time?"

  • chap render --last / chap cat --last

  • chap import chatgpt-style-chatlog.json (for files from pionxzh/chatgpt-exporter)

  • chap grep needle

Interactive terminal usage

  • chap tui

Sessions & Commandline Parameters

Details of session handling & commandline arguments are in flux.

By default, a new session is created. It is saved to the user's state directory (e.g., ~/.local/state/chap on linux/unix systems).

You can specify the session filename for a new session with -n or to re-open an existing session with -s. Or, you can continue the last session with --last.

You can set the "system message" with the -S flag.

You can select the text generating backend with the -b flag:

Environment variables

The backend can be set with CHAP_BACKEND. Backend settings can be set with CHAP_<backend_name>_<parameter_name>, with backend_name and parameter_name all in caps. For instance, CHAP_LLAMA_CPP_URL=http://server.local:8080/completion changes the default server URL for the llama_cpp back-end.

Importing from ChatGPT

The userscript https://github.com/pionxzh/chatgpt-exporter can export chat logs from chat.openai.com in a json format. This format is different than chap's, especially since chap currently only represents a single branch of conversation in one log. You can use the chap import command to import all the branches of a chatgpt-style chatlog in json format into a series of chap-style chat logs.