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.

Markdown embeds such as ![chart](chart.png#ai) in notes and prompts include linked images, PDFs, audio or video when the model supports them. Known text files, including Markdown, Quarto, plain text, JSON and TOML, supply UTF-8 text context instead of media parts. Text files exceeding the existing 1MiB text limit produce an unavailable notice; originals remain accessible to tools. Unmarked external embeds and saved replies are not expanded. Notebook attachments and code outputs retain their normal media handling. Python loads HTTP(S) URLs, base64 data URLs and ordinary filesystem paths relative to the dialog; absolute paths keep their normal meaning. Rustygate maps /static/ to its served root and applies its file restrictions. Linked files are not included in the token estimate.

The Rust core loads linked media while building the retained context. Rust hosts pass media::Context { http, root, path } to async input::build. path is the notebook filename; root is the gateway's served root, or None for ordinary filesystem paths. Python uses the same core through synchronous bindings with a shared I/O runtime. Media paths accept strings or PathLike objects. Neither path changes the notebook.

references returns sorted unique vars, commands and tools from the prompt's prefit context. An explicitly addressed prompt contributes even when skipped. The host evaluates variables and supplies tool schemas. cell_turn returns one message's canonical parts and normalized saved reply; input::group_turns groups these contributions through each reply without fitting or shortening call IDs. dlg2hist, dlg2chat and chat2dlg remain Python APIs for full transcripts, including the final saved reply.

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 language fences with its outputs in ::: output divs, and each prompt and its reply in ::: prompt and ::: reply divs. msg2md writes one message. Both accept language='python' and inline stored attachments referenced by notes, prompts and replies; ordinary file links remain links.

msg2text(m, part='input') gives the source, or part='output' gives text output with prompt tools removed. msgs2py(msgs) writes nbdev-marked code; full=True includes all code, commenting notes, prompts, replies and outputs. These conversions read saved messages without fetching linked files or changing the dialog.

reply2dlg and dlg2reply retain Python code-cell editing and use the native reply parser, output renderer and writer. dlg2reply applies the same saved-history shortening and text ceiling as write_reply.

Metadata

Release files for aihist 0.1.9

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.9
File Size Uploaded Provenance Actions
aihist-0.1.9.tar.gz 69.3 kB With provenance Details for aihist-0.1.9.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for aihist 0.1.9
File Actions
aihist-0.1.9-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.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.9-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.9-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.9-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for aihist-0.1.9-cp313-cp313-macosx_11_0_arm64.whl
aihist-0.1.9-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.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.9-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.9-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.9-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for aihist-0.1.9-cp312-cp312-macosx_11_0_arm64.whl
aihist-0.1.9-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.9-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.9-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.9-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.9-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for aihist-0.1.9-cp311-cp311-macosx_11_0_arm64.whl
aihist-0.1.9-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.9-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aihist-0.1.9-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.9-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aihist-0.1.9-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for aihist-0.1.9-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 36.2 MB

Release files / aihist-0.1.9.tar.gz

Download URL aihist-0.1.9.tar.gz
Size 69.3 kB
Tags Source
SHA-256 checksum
How to use checksums
029fc86a764d08e1c3f126e1e9d9a7084038f31697b8d2de02c7adec12a190ae
BLAKE2b-256 checksum
How to use checksums
2e9f22b1df3033141b3603057d567482ed95963f8129519f4ab6b96f170d7a13
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
68a97ec2d5ffbebdbd1cbb6306e521ac25b176eaf4a31a98dbd24bc79c42640d
BLAKE2b-256 checksum
How to use checksums
b6f1e9da83aa943fd30261f4e2effa42ec5d6eb48c9d9f83bd70ea121b313645
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.1 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
8ecf713a170df1c8924ee8422f922f942b04021900020bcc757b066afd41092e
BLAKE2b-256 checksum
How to use checksums
2b5698ed6440f48815babfd6bde4729afe5641ffbf01384c30fd9a6325753114
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp313-cp313-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5040befcacc031dcea0331e33cce7104b87098b36cc34a1d456653dfd990b5ca
BLAKE2b-256 checksum
How to use checksums
69b7ce24eac68183c5bace3623d51bf137cb33962468e99e40c36510d98b2ddb
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9f5cd43c520b57c2e0e6c0429d1a673dd6ad786206647bc8e5f177b40e8c2683
BLAKE2b-256 checksum
How to use checksums
05caff57fca9e233c061121ce6604b45e1a2574c7fee1a49a3986b56bf2ec2d1
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.1 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
6c8efc1a21876849d8f87c81f0f85b2fc77ba9d00a23906428fcb0ee0c21a059
BLAKE2b-256 checksum
How to use checksums
26f2f40da8b7f7ca8bfb2dd5a14b1f42fc4f853d9a2fa2ea3ea69da46f2ed84b
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp312-cp312-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5ee568bcea475a3f2b44c08ba2da5c55e11ac67a0adf844865498277a2269cf3
BLAKE2b-256 checksum
How to use checksums
6935eb9feaab670cc4331c1e1b8bd5ed71cb092497af0d73c6e36cbe3dead4a3
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5a7788169f3d8b322e407082453bdaefb93978e8a51d7be16d15c02c7972585e
BLAKE2b-256 checksum
How to use checksums
4570bb28fbd98dd0364f7717e538ea90ec825ad562f54778d023d9a2b459d27d
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.1 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
0b131e4f3904a3d685908cd24ba8dbf114ac5ad81b540c4c8dc9b542bf1a11c4
BLAKE2b-256 checksum
How to use checksums
2e13a193c54defe38f8722476d82d7ea7a59a320740502f0fe2454ff1e0660ee
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp311-cp311-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b6dc8ad34b9431ebb2b0e0441c584a4dc71f7bd7d7b3fa170f2057cbc14fd7d6
BLAKE2b-256 checksum
How to use checksums
405c4f20add429090326463972b0e1e2dbba4bc7cd9fa58bba187feea6890829
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7f2864d29d8c0fb09e084af959c94e7f8779decfa3ccb42c71e8399cde68b9b4
BLAKE2b-256 checksum
How to use checksums
dee67f0737215c1bfbe9066617927a734c651a738247a8e124313dde583310fe
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
cfa4b36f0be2a241fb0791073679c5474f5c01361c7385147c9703713775e69b
BLAKE2b-256 checksum
How to use checksums
8860db7fddae21d74916e91a66ca7f7330c28f61ff574c1f830c7740f4929bbe
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 18, 2026.

Transparency log

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

Download URL aihist-0.1.9-cp310-cp310-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2b9ad9114efb0852b1f853d5f548d99bf2c930919ac3275b25f8f36351c49558
BLAKE2b-256 checksum
How to use checksums
4ddb24c2b1b0cff43562c5091bace047ddb27d7a6564fa2725ffc946ef38a757
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 18, 2026.

Transparency log

Security for aihist 0.1.9

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.9.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 18, 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