Skip to main content

aidialog

aidialog provides the Dialog/Message model used by solveit and the fastai AI tooling ecosystem. An AI dialog is a Jupyter notebook whose cells are messages: notes, runnable code, and prompts with replies. Five modules build on each other:

  • aidialog.msg_parts: the canonical Msg/Part chat message model and its wire text form
  • aidialog.dialog: the core Dialog/Message model, including plain-text rendering of Jupyter outputs
  • aidialog.ipynb: reading and writing dialogs as .ipynb files
  • aidialog.hist: conversions between dialogs, chat histories, and formatted replies
  • aidialog.dlgskill: search and editing tools for dialogs and notebooks, registered as a pyskill

Provider session files (Claude Code transcripts, Codex rollouts) and conversation compaction live in llmsurgery.

The theory

A dialog is a conversation between a human, an AI, and an interpreter. Each message type addresses one of them and expects a certain kind of answer:

  • A prompt asks the AI a question and holds its reply.
  • A code message gives the interpreter source and holds its outputs.
  • A note is read by everyone and answered by nobody.
  • A raw message addresses no one. It is inert matter the conversation carries along.

A reply may itself contain runnable code with results, so a whole dialog can live inside one message. reply2dlg opens a reply up as a dialog and dlg2reply puts it back.

Dialogs and Jupyter notebooks both serialize to the ipynb format, but they are not the same thing. A notebook has cells. A dialog has messages. Messages can be prompts, which notebooks cannot express, and they make structure explicit that notebooks leave implicit. E.g a heading opens a section that runs to the next heading of the same level; an export directive marks the code that belongs to a module. The shared file format means the same tools read both. The word tells you which layer you are on. File-level tools such as fastcore.nbio and exhash speak of cells and notebooks. Everything in this library speaks of messages and dialogs.

The Dialog is the center of the library. Everything else is a projection of it. A storage projection must preserve everything that means something. What it does not understand it carries verbatim in metadata, and what is broken it heals rather than rejects. A transmission projection normalizes on purpose, and what it drops is written into its contract. A display projection only goes one way. The rule is to convert in, edit at the center, and project out. The function names say the same thing. Every converter has dlg on exactly one side.

projection contract in out
ipynb file storage, pragmatically lossless read_ipynb write_ipynb
Claude Code session storage sess2dlg dlg2sess
Codex thread storage (write-only so far) dlg2thread
canonical chat (Msg/Part) transmission, normalizing chat2dlg dlg2chat
hist (live call input) transmission, one-way dlg2hist
a prompt’s reply self-similar reply2dlg dlg2reply
XML views display, one-way view_dlg, msg2xml

The session codecs (in llmsurgery) route through chat on their way to the wire: ant’s dlg2msgs and oai’s dlg2items are each denorm_msgs(dlg2chat(...)).

Usage

Installation

Install latest from the GitHub repository:

$ pip install git+https://github.com/AnswerDotAI/aidialog.git

or from pypi:

$ pip install aidialog

Documentation

Documentation can be found hosted on this GitHub repository’s pages.

How to use

A quick taste - create a dialog, add a message, and view it as concise XML:

from aidialog.dlgskill import *
import tempfile
p = tempfile.mkdtemp() + '/demo.ipynb'
d = create_dlg(p, '## A tiny dialog', 'note')
add_msg('6*7', after=d.messages[0].id, dlg=p)
view_dlg(p)
<dialog name="demo"><markdown id="1d693c32">## A tiny dialog</markdown><code id="02048a43">6*7</code></dialog>

Command line

The flat commands expose dialog-aware reading and structural edits without a Python kernel:

aidialog-summary nbs/00_core.ipynb
aidialog-find nbs/00_core.ipynb 'read_csv' --context 1
aidialog-view nbs/00_core.ipynb ab12cd34 --out
aidialog-add nbs/00_core.ipynb --after ab12cd34 --msg-type code < new-cell.py
aidialog-del nbs/00_core.ipynb ab12cd34
aidialog-move nbs/00_core.ipynb ab12cd34,ef56ab78 --before 9012cdef

Message ID arguments are comma-separated where a command accepts several. Mutating commands accept --dry-run; run any command with --help for its full filters and display options.

Download files

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

Source Distribution

aidialog-0.0.25.tar.gz (58.1 kB view details)

Uploaded Source

Built Distribution

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

aidialog-0.0.25-py3-none-any.whl (59.0 kB view details)

Uploaded Python 3

File details

Details for the file aidialog-0.0.25.tar.gz.

File metadata

  • Download URL: aidialog-0.0.25.tar.gz
  • Upload date:
  • Size: 58.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for aidialog-0.0.25.tar.gz
Algorithm Hash digest
SHA256 cca8e40ae83749ba6ce158969120ee0a2852b7e75316bb30f3fcc18ae99ea878
MD5 3654e077db0272436329b037e873093e
BLAKE2b-256 ede4a35551343671c28a31365cc793c8ff47072e71501100b8ce1aee2e19b3ad

See more details on using hashes here.

File details

Details for the file aidialog-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: aidialog-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 59.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for aidialog-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 cb28c7bb57eebe851dac5b7027b89ba0faf330bb270c946cdf61c3a4c7976a4a
MD5 8d93dc6506c8406fe3687d457da89f25
BLAKE2b-256 58a4e1aab06e14e76fb16bf8c5f2c3e98249e211223abac68c56c5703bdd1bf9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

This release

0.0.25 This release

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page