Chap is primarily developed on Linux with Python 3.11. Moderate effort will be made to support versions back to Python 3.9 (Debian oldstable).
If you want chap
available as a command, just install with pipx install chap
or pip install chap
.
Use a virtual environment unless you want it installed globally.
Use one of the following two methods to run chap
as a command, with the ability to edit the source files. You are welcome to submit valuable changes as a pull request.
pip install --editable .
This is an "editable install", as recommended by the Python Packaging Authority.
Change directory to the root of the chap
project.
Activate your virtual environment, then install chap
in development mode:
pip install --editable .
In this mode, you get the chap
command-line program installed, but you are able to edit the source files in the src
directory in place.
chap-dev.py
A simple shim script called chap-dev.py
is included to demonstrate how to load and run the chap
library without installing chap
in development mode. This method may be more familiar to some developers.
Change directory to the root of the chap
project.
Activate your virtual environment, then install requirements:
pip install -r requirements.txt
Run the shim script (with optional command flags as appropriate):
./chap-dev.py
In this mode, you can edit the source files in the src
directory in place, and the shim script will pick up the changes via the import
directive.
See CONTRIBUTING.md.
See CODE_OF_CONDUCT.md.
Put your OpenAI API key in the platform configuration directory for chap, e.g., on linux/unix systems at ~/.config/chap/openai_api_key
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
@FILE
argumentsIt's useful to set a bunch of related arguments together, for instance to fully
configure a back-end. This functionality is implemented via @FILE
arguments.
Before any other command-line argument parsing is performed, @FILE
arguments are expanded:
@FILE
argument is searched relative to the current directory@:FILE
argument is searched relative to the configuration directory (e.g., $HOME/.config/chap/presets)@
, double it: @@
@.
stops processing any further @FILE
arguments and leaves them unchanged.
The contents of an @FILE
are parsed according to shlex.split(comments=True)
.
Comments are supported.
A typical content might look like this:
# cfg/gpt-4o: Use more expensive gpt 4o and custom prompt
--backend openai-chatgpt
-B model:gpt-4o
-s :my-custom-system-message.txt
and you might use it with
chap @:cfg/gpt-4o ask what version of gpt is this
The interactive terminal mode is accessed via chap tui
.
There are a variety of keyboard shortcuts to be aware of:
Details of session handling & command-line 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:
Backends have settings such as URLs and where API keys are stored. use `chap --backend