Add your description here
Project description
chit
chit is a git-analogous system for managing LLM chat conversations in a Jupyter notebook. Install as pip install chitgpt.
The chit.Chat class has methods:
commit()for adding new messages (either user or assistant). For creating an assistant message, the message path leading from the root to the current checked-out message is sent to the LLM.branch()for creating a new branch at the current checked-out messagecheckout()for changing the checkout message.push()for dumping to aRemote(a json file + an html gui visualization) -- note that this will not preserve chat settings like the list of tools.clone()a classmethod for initializing achit.Chatobject from a json file- sensible indexing and slicing
rm()for removing a branch or commitmv()for renaming a branchshow()for showing a particular message (by commit ID, or any form of indexing)find()for finding in conversation historylog()for creating simple tree or forum style visualizations of the chatgui()for creating a (non-interactive) html gui output of the conversation similar to a classic LLM interface
See example.ipynb for some demonstration, as well as example2.ipynb where we re-clone an earlier chat and play with it, and example3.ipynb for demonstrations with tool-calling.
models
Change the model by directly modifying the model attribute e.g.
chat.model = "openrouter/anthropic/claude-3.7-sonnet"
We use litellm for the LLM completions, so use their model naming conventions (very useful comprehensive list here).
images
Vision is supported, including images from the clipboard like so: chat.commit("Analyze this image.", image_path = '^V').
tool use
Change tools by modifying the tools attribute (which is a list of functions):
chat.tools.append(web_search)
Here web_search should be a Python function with either (1) a json attribute in the OpenAI specification or (2) a numpy-style docstring, which lets us automatically calculate the json attribute using litellm.utils.function_to_dict.
Tool-calling is not compatible with streaming. If your chat has tools, you can pass chat.commit(enable_tools=False) to temporarily disable tools for that AI call and enable streaming.
alternative input methods
One convenient util is chit.read(), which makes it convenient to paste local file contents into your prompt, i.e.
import chit
from chit import read
chat = chit.Chat()
chat.commit(
f"""
Analyze and review the folowing code:
{read("chit/chit.py")}
"""
)
chat.commit()
Another useful thing you may like to do is use Jupyter's built-in text areas to input your text, e.g. to avoid syntax conflicts (like having to escape quotes manually):
import chit
from chit import textput
chat = chit.Chat()
prompt = textput()
# ... write your prompt in the text area that appears,
# no need to worry about clicking any submit buttons,
# it's dynamic ...
#
# ... then in a new cell ...
chat.commit(prompt.value)
chat.commit()
A more traditional way to do this is to type your prompts in a temporary text file (rather than within a jupyter notebook or python file). We do support this; you can do so by typing your message as ^N:
import chit
chat = chit.Chat()
chat.commit("^N") # opens up a temporary file in VS Code
chat.commit()
And can also specify a specific editor like ^N/code (which runs code /tmp/whatever.txt) or ``^N/gnome-terminal$vim(which runsgnome-terminal -- vim /tmp/whatever.txt`). However `^N` is currently quite broken and unreliable, especially in a Jupyter notebook -- it does not work with the `terminal$editor` setup at all, and is unreliable even with `code`. I recommend just using jupyter text areas for now.
indexing
chit.Chat objects support indexing (and slicing) by:
- commit IDs, i.e.
chat['1adca2f6'] - negative integers, i.e. where
chat[-1]is the currently checked-out message and you traverse backward from there - lists, i.e.
chat[["master", "master"]]to do forward traversal from the currently checked-out message, specifying the branch to choose at each step - nonnegative integers, i.e. where
chat[0]is the system message and you traverse forward along the master branch
This also applies to e.g. rm().
settings
Apart from the chit.Chat initialization arguments, we have:
DEFAULT_MODEL
# default: "openrouter/anthropic/claude-3.5-sonnet"
# default model to initialize chit.Chat objects with
chit.config.VERBOSE
# default: True
# enables informational print statements from chit apart from chat responses
# (e.g. telling you how many tool calls are expected to be calculated)
chit.config.FORCE
# default: False
# disables asking for confirmation before removing commits and branches
chit.config.AUTOSAVE
# default: True
# automatically pushes to the Remote, if one is set, after every commit or other change
chit.config.EDITOR
# default: "code"
# default text editor to use for user input if user message is `^N` with no further suffix:
# `editor-name` for gui editors, e.g. `^N/code`.
# `terminal-name$editor-name` for terminal editors, e.g. `^N/gnome-terminal$vim`.
# `$jupyter` to take input from a text area in the Jupyter notebook, i.e. `^N/$jupyter`.
# can be overriden in commit by giving
imports
We have a (probably very rudimentary) importer function for Claude exports, used as follows:
import chit
chat = chit.Chat.migrate("claude_export.json", format="claude")
Here is how you get a Claude export (for a particular chat) -- do not use the default Claude data dump in account settings (this does not preserve tree structure); instead load the Claude chat with Chrome Dev Tools > Network open and find the correct resource.
TODO
- improve
^Ninput - make pushing and cloning preserve as much as possible
- autosave feature
- fix html visualization issue
- fix claude imports -- or maybe it's actually an issue with the visualization, let's see
- cleanup this repo
- Implement better way to do Jupyter notebook inputs based on: [1], [2] -- maybe the user should preface a markdown block with some name, and we automatically maintain a dict of such names to their following texts, and then send the prompt as
chat.commit('^J/name')or something. - html gui improvements
- i3-like gui
- forum-like gui
- footer saying made with chit
- global dropdown to select a branch; they should be shown with indentations reflecting their nesting
- add imports from chatgpt, deepseek, xai, gemini, various LLM frontends etc. (only claude currently implemented)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chitgpt-1.11.0.tar.gz.
File metadata
- Download URL: chitgpt-1.11.0.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
518e108a600d9d2d91d834ad0afc0b046247b2d45cdeeafd72fe969eac1255d3
|
|
| MD5 |
7ca2bf814bad447226ef5cf6e9130bcd
|
|
| BLAKE2b-256 |
44662e67d8e130ac1b05f0569226958528c06bccb5d5b7959e49e7d914208736
|
File details
Details for the file chitgpt-1.11.0-py3-none-any.whl.
File metadata
- Download URL: chitgpt-1.11.0-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9626832251457cc9a40ea16312c9283971e1654fe9cf1e4459b3a9a8a8d20c05
|
|
| MD5 |
d7bdb67b30c8fb094a136c723ec9b79a
|
|
| BLAKE2b-256 |
ede1d79808b8f64d4d0a068018b6762e1d3b7d395f57d9d5c2efa6b5d1a5b65f
|