Skip to main content

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 message
  • checkout() for changing the checkout message.
  • push() for dumping to a Remote (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 a chit.Chat object from a json file
  • sensible indexing and slicing
  • rm() for removing a branch or commit
  • mv() for renaming a branch
  • show() for showing a particular message (by commit ID, or any form of indexing)
  • find() for finding in conversation history
  • log() for creating simple tree or forum style visualizations of the chat
  • gui() 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
from chit.import_claude import import_claude
chat = import_claude("claude.json")

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 ^N input
  • make pushing and cloning preserve as much as possible
  • autosave feature
  • fix html visualization issue
  • fix claude imports
  • cleanup this repo
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chitgpt-1.8.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chitgpt-1.8.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file chitgpt-1.8.0.tar.gz.

File metadata

  • Download URL: chitgpt-1.8.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for chitgpt-1.8.0.tar.gz
Algorithm Hash digest
SHA256 3b6facde28846e547237b014aa4bf9e9418c687443c2fed8918ce11a10aee11e
MD5 301e0a080c7e239a37bfcd7016916921
BLAKE2b-256 cfbea4914070abea5d9e76c7e78d15bfd38c0560c864a283266410d7e6a00dc2

See more details on using hashes here.

File details

Details for the file chitgpt-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: chitgpt-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for chitgpt-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 466c109010bab49e75404c4028e896016b2f028470ddf8933256ff391e32f56d
MD5 20649259e8dc62005c489fd3157389fb
BLAKE2b-256 88b96d5ee2b9e8fc03a4d44760d6a8686e18f7d8f665cd1ec4a748701069c06f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page