Skip to main content

aihist

aihist turns dialog notebooks into input for a language model, and saved replies back into messages. A dialog is a Jupyter notebook in aidialog's format: notes, code, raw cells, and prompts whose replies are saved in the prompt cell's output. Solveit uses aihist through its gateway, rustygate, and Python programs use it directly.

aihist is a Rust crate with Python bindings. The crate needs no Python. The aihist Python package works with aidialog's Dialog, Message and Msg objects.

Install

pip install aihist

Model input

build gives a prompt's model input as Responses input items: the dialog messages above the prompt, each as a model reads it, then the prompt. Each earlier prompt is followed by its saved reply, read back into text, tool calls and tool results. A host can add example notebooks, CRAFT dialogs, $ values and warnings. The input fits 80% of the model's input window. Pinned messages always stay. Other messages are dropped oldest first, with cutoffs every ten messages in the original dialog and before and after any message whose input and text output exceed 20,000 characters combined. Pinned and skipped messages count toward those positions.

from aidialog.dialog import Dialog
from aihist import build

dlg = Dialog(name='demo')
dlg.mk_message('Distances are in metres.', msg_type='note')
p = dlg.mk_message('How far is 3 km?', msg_type='prompt')
items = build(dlg, p.id, dict(input_modalities=['text', 'image'], max_input_tokens=200_000))

The third argument says what the model reads, as fastllm's get_model_info or a model catalog entry gives it. fastllm's response_input turns the items into fastllm messages.

build estimates tokens by character class, calibrated against OpenAI's o200k tokenizer, and adds a margin for other providers' tokenizers. count_tokens gives the estimate for any text: count_tokens('def fetch_daily(lat, lon): pass') is 9.

Saved replies

A saved reply is Markdown, with each tool call and its result in a fenced json {.tool} block, and the turn's token use in a json {.usage} block. fmt2hist reads a reply into chat messages, parse_tools splits it at its tool blocks, and strip_tools removes them. set_result replaces one call's stored result and leaves the rest of the reply unchanged. Reply builds a reply as a model's stream arrives, and shows the text to display at each step.

Reply.add appends completed tool blocks after their pending rows. write_reply formats a completed turn's canonical assistant and tool messages through the same Rust writer. Saved history normally shortens tool results to 5,000 characters and string arguments to 25,000. Full or marked text bypasses this shortening, but not the practical 1MiB text ceiling, which also applies to set_result.

fmt_tools rewrites each tool and usage block in a reply as a folded ::: details div for display, using tool_md and usage_md.

Dialogs and chats

dlg2chat turns a dialog into chat messages, with each reply's tool calls as real parts, and chat2dlg turns chat messages back into a dialog. reply2dlg turns one reply into a dialog of notes and code that calls the tools, which dlg2reply turns back into the reply. hist_xml, to_media and to_parts give one message as a model reads it.

dlg2md writes a dialog as one Markdown document: notes as they are, code in python fences with its outputs in ::: output divs, and each prompt and its reply in ::: prompt and ::: reply divs. msg2md writes one message.

Metadata

Release files for aihist 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aihist 0.1.4
File Size Uploaded Provenance Actions
aihist-0.1.4.tar.gz 54.9 kB With provenance Details for aihist-0.1.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for aihist 0.1.4
File Actions
aihist-0.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details for aihist-0.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details for aihist-0.1.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.4-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for aihist-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
aihist-0.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for aihist-0.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details for aihist-0.1.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.4-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for aihist-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
aihist-0.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for aihist-0.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details for aihist-0.1.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.4-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for aihist-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
aihist-0.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for aihist-0.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details for aihist-0.1.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.4-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for aihist-0.1.4-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 19.7 MB

Release files / aihist-0.1.4.tar.gz

Download URL aihist-0.1.4.tar.gz
Size 54.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7452939c97f78049e301cd4dfe3f2ceb07b2f7fcb7a232304928f43edb3ad883
BLAKE2b-256 checksum
How to use checksums
44ae8c2a42f389485ab02e79340a29a251ed59aa12d357c7b5bafe913b2bb22e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL aihist-0.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.7 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
77e26b8edf0a52074589c8ee96f063bc1331592c223f3f20ecd4f809d7fa6933
BLAKE2b-256 checksum
How to use checksums
4fec552504ef3cf756cdf96cc1b7cf911f8cbddf2ac1ae513a51271dd5099612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL aihist-0.1.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.6 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4a985e14a51564c614ddd4e793ea4258792145060a946fc12feb6383050b4de3
BLAKE2b-256 checksum
How to use checksums
47556287581d9bd43ae2ad15b358418e4e6f21ad7e348dc59ec556d9b4faf1a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp313-cp313-macosx_11_0_arm64.whl

Download URL aihist-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0133fe0d4695e658d04fb50f41891f0213a1b52a2959cd9a36fab5903528c5ae
BLAKE2b-256 checksum
How to use checksums
8354232d6962adac7f4e728cf549a6618e8d41058e09148f422fa0b676aea358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL aihist-0.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
98826b6f66a63642466dc3ceede12a62cf61243e60d0d3423619f1b0facf7764
BLAKE2b-256 checksum
How to use checksums
5bd4c709f2dd9a1d6b5c06ae69b15c33226e8c1ea799d96627ee2cbbdd9aeba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL aihist-0.1.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.6 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
88452234bbcaa83fc1813d23ec8d6013322d801f1bb4000be9324e8e377ee6ff
BLAKE2b-256 checksum
How to use checksums
4f7e0ff6801a6ac786d3b23644cfa03d7ed17ba619bab9a75f9cb940c7f52a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp312-cp312-macosx_11_0_arm64.whl

Download URL aihist-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
807d0f42559d1df3a4a7e645016e5185dda8dd56864327cf6c929cd6d8f04067
BLAKE2b-256 checksum
How to use checksums
dd8dfdfe9eecd9ab0e13f8c7c0d4c0f0069ff3170b8c12d996a8a124cb2fbe31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL aihist-0.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.7 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
564b0d9d85d3b400e24b211b6c3256ecec090920c0611f5a62dd866c0941d91c
BLAKE2b-256 checksum
How to use checksums
c92cdd5d9be7c0174d5370b538faa30c515c375d8740b101b883ddc4c7116e34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL aihist-0.1.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.7 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
7b3628e33e08fc51c28f6115ef6e5f86a3e672a40717de5c4992d45199d41771
BLAKE2b-256 checksum
How to use checksums
205b7475f2464bf4af2fa144dfcdd4d2f146e0282a8abde663388520ea400e21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp311-cp311-macosx_11_0_arm64.whl

Download URL aihist-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
08e37d457f692d4ecdf2d80523795eb611b23b886cdd006027325f8fdafaca78
BLAKE2b-256 checksum
How to use checksums
95b4363b7fe31e2c7f171459731dd2fed4ea6808b304490bc59a7b785317ecd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL aihist-0.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
4658e58f903f50fdb37f61823cf604c18bb496e9bacfa73464cc634a5e146a61
BLAKE2b-256 checksum
How to use checksums
9ce28283533cadb7728d591faeca02e4fa0e790b264579cf14e32b5bcebd3c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL aihist-0.1.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.7 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
77657cf379062d72f980cb1c9c994222699f8da33de11cf4f4717f28f9299e9c
BLAKE2b-256 checksum
How to use checksums
96d90a9d74a36a37bda4f864a90a9904b9cfe19de90d8c9f1620a69fe9dd9bdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / aihist-0.1.4-cp310-cp310-macosx_11_0_arm64.whl

Download URL aihist-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c648631e1135af3f86edd2f1e515c90b483b9bad05b8b4dd0fe7f8764d4a8bcb
BLAKE2b-256 checksum
How to use checksums
de17bb774a3c633aef3e0b6de08f055f28355fbf6a16cbdbd2fb9cba4d0b4f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for aihist 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 13 files in this release have been uploaded with provenance metadata.

Select from 13 files

Attestation for aihist-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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