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. 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 media is 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 python fences with its outputs in ::: output divs, and each prompt and its reply in ::: prompt and ::: reply divs. msg2md writes one message.

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.5

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.5
File Size Uploaded Provenance Actions
aihist-0.1.5.tar.gz 67.0 kB With provenance Details for aihist-0.1.5.tar.gz

Built distributions (wheels)

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

Total release size: 35.6 MB

Release files / aihist-0.1.5.tar.gz

Download URL aihist-0.1.5.tar.gz
Size 67.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e54734a9ecfc4364effdaffcac1e265ba55ac28dacbc23640779b7beda753eac
BLAKE2b-256 checksum
How to use checksums
e52ee3f1d56c4d0fe562b83a5f917d404ff5a7694e108410aedd7d7feb8b7197
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
f3f42d094bd9d1d286d9ceff3af4ffc5a43c493ea847e462682f2937cc8d5864
BLAKE2b-256 checksum
How to use checksums
32b59253dd8dbf6a69c960ee1138edb90e5cd58e2c02623dd2889e340549e93f
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.0 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
795e8e3428be0c6e43762055340d31e6c9fd41c631b23258d5233f2509391bd0
BLAKE2b-256 checksum
How to use checksums
f8fb237fe3a4101aca8391fb86f9074d6d848094658ac079ef73dff5d3efd86c
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
f7ab420b2b324f8864e4716f10cdf7e27baa29ac87d80927d3c7ac5cbf18a659
BLAKE2b-256 checksum
How to use checksums
9ab2c81c147145f020849de4cf6a595982b86d0692b50a2e099dc87516dc3ff1
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
10ee8178ceb6ae9ae997eef9f66a25e2859dfca0a6773e53e085ab5da29938a7
BLAKE2b-256 checksum
How to use checksums
2c58afac9406b3bf31926f54f2778288a96d22c0c17bb8398ad226178e3ff56f
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.0 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
06a182347fb9ebb71a0637c7932c0fbd54f543086cadeb3f66cf2c9dcb115aad
BLAKE2b-256 checksum
How to use checksums
a65007412ce35150014a3ccdf9c275f6c008c3912a3a2417cd6578b573e326f2
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
ca21e4d51d7f6cc4e2ddfc803968260e5e33fcfac6dd412bffc5c43c3db3babe
BLAKE2b-256 checksum
How to use checksums
daad09bf18389bb34a0a978ea80050edcd0020bf9141762f0c1523a44bc23c05
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
885e6bbfb45d0ff693ad2848edfe982c331df69633a654bf0ab4dc85d3e233b3
BLAKE2b-256 checksum
How to use checksums
dcc69c41147e5d82d898f41fd17f29f4176618a55c2489fd24fa0b925db3b903
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.0 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
81f5cfd80c859116be51f10157e1d4827fb8269113bbf944d934f562d165870c
BLAKE2b-256 checksum
How to use checksums
4cc8d03f1c761b8db746af4f29e638ab9ce29cb684cb154171bf4375f2a02774
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
af28ecc4f105f17c145017b7560fd47d3235fbbd989c69501006c6d7812756f2
BLAKE2b-256 checksum
How to use checksums
7fdd4057fa434d9fcbefd46916b460e642b9680e1e3ba04f844bcb0ce1d94657
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
971d0de08ee32228e39083d997a37d599330f67d069587a8478b0d528816227f
BLAKE2b-256 checksum
How to use checksums
dd8b955d555da5962a2b6b07f0a1dab7048dc05875fcf0cd141f70d321080cb2
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.0 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4ca41002d5cbfb5bc4f2bc61771d970692c9f808645b279b8bc75faec842bdbb
BLAKE2b-256 checksum
How to use checksums
26f63b9741db0190aed8b3b48dfe529823b568ccd683133f9918b409d8b5c2e8
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 5, 2026.

Transparency log

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

Download URL aihist-0.1.5-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
99d5eacab2b8811222a4fb02f5c8ba0fed83f1c88fb8a185df9022a9f5086db0
BLAKE2b-256 checksum
How to use checksums
18d22d4b9cb095fe66b5051ba72352bcd5a4f99386d7a145c98c55ceb6b0b0ab
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 5, 2026.

Transparency log

Security for aihist 0.1.5

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.5.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 5, 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