From a scanned PDF to a database and web application: AI agents in action
Processing historical sources with the Chronos AI agent system.
Case study: Paul Simson, Danziger Inventar 1531–1591. Mit einem Akten-Anhang, Munich and Leipzig, 1913. The digitised copy used in this project is available on the Internet Archive.
1. Project aims and stages
A scanned book makes a source readable, but it does not yet offer a convenient way to bring together all the entries concerning a person, place or period. The aim of this project is to turn the published inventory into a dataset quickly, retaining its connection to the printed volume while enabling questions that go beyond simply browsing a PDF, through advanced searching and filtering.
The PDF contains scans of a book published in 1913. Its author, Paul Simson, was a historian of Gdańsk. Although the PDF includes an OCR layer, this project was intended to demonstrate the capabilities of AI agent systems, so the text was read directly from the page images.
A historian working with an AI agent system might follow these stages:
PDF containing scans
→ page images imported from the PDF into Chronos
→ entries transcribed into JSON
→ fragments merged and transcriptions checked
→ dates, place names and Polish translations
→ index of people and places, linked to entries
→ SQLite database
→ application for browsing, filtering and searching
JSON is a text-based data format: a single entry can be an object containing fields such as date, text and entry_number, while the inventory as a whole can be an array of these objects. SQLite is a lightweight SQL database that stores data in a file and allows entries to be linked to people, places and pages. A web application will make these data available to readers through a browser, with search and filtering facilities.
2. The role of Chronos
Chronos is an AI agent system designed specifically to work with historians: extracting structured datasets from primary sources, adapting to heterogeneous documents and accumulating domain knowledge during the process. It was developed as part of The AI Historian, a project funded by Schmidt Sciences’ AI2050 initiative and carried out by specialists from Schmidt Sciences, the University of Oxford and the University of Adelaide. Technically, Chronos is an extension for the Visual Studio Code development environment, working with the pi agent (a standalone application that can be used outside Visual Studio Code is also under development; after checking its current state and testing it, I will describe its installation in a separate blog post). An LLM interprets the instructions and source material, while the agent can organise tasks and use additional tools. In this project, the outputs also include scripts that process files: merging entries, tidying metadata and sending text for translation. The historian guides the processing of the source using natural language—in this case, Polish.
The developers describe Chronos as a tool for working with historians to produce structured data. Their project website includes an example involving a Frankfurt merchants’ directory from 1812 and a map of the city from 1811, resulting in an interactive map. See the Chronos overview.

Alongside Visual Studio Code’s standard file explorer, the Chronos interface includes a viewer for source scans, a panel displaying the data extracted from the source, and a chat panel where the historian communicates with the agent.
3. Preparing the project and importing the PDF
Installation and the first session
To start using Chronos, install VS Code and Node.js according to the requirements in the current Chronos README. In VS Code’s Extensions view, search for Chronos — The AI Historian, published by AI-Historian. On first launch, the extension may offer to install the pi agent and the Chronos package.
Open the VS Code Command Palette with Ctrl+Shift+P and run:
- Chronos: Init Workspace — initialise a workspace in the project folder.
- Chronos: Import Sources — select the PDF containing the book scans.
- Chronos: Start Agent Session — open the Chronos workspace panel.
- In the Source field of the Chronos panel, select the imported source.
Importing creates page images. In this project, they are stored in sources/DANZIGER_INVENTAR_1531-1591/png/. It is also worth retaining the original PDF and recording the provenance of the digitised copy. See the getting-started instructions.
A standalone application that can be used outside VS Code is also under development. This should make installation and use more accessible to historians: chronos-desktop.
Understanding the project folder
| Location | Role in this project |
|---|---|
sources/ |
Images against which the transcription can be checked. |
data/DANZIGER_INVENTAR_1531-1591/ |
Page-level files, batches of entries and successive versions of the dataset. |
memory/ |
Notes on the source’s layout and instructions for the LLM. |
sessions/ |
Agent session logs. |
skills/ |
Instructions for recurring tasks. |
.chronos/ |
Chronos settings and supporting data; .env may contain API keys for LLM providers. |
*.py scripts |
Specific processing operations that can be inspected and run again. |
Preliminary work
Before asking the agent to process a source, it is worth becoming familiar with the book. The main part of Simson’s volume is an inventory of entries covering 1531–1592, which will be the main focus of processing. The index of people and places is also a valuable resource. Each entry has its own number; the inventory contains more than 10,000 entries in total.
4. Choosing a model and configuring Ollama Cloud
Model providers and the Chronos interface
Chronos is not tied to a particular LLM or AI service provider. Standard connections, for example to Anthropic, OpenAI or Google Gemini, can be configured through Log in / Connect AI Provider. Other providers and compatible API endpoints are added in the pi configuration. To read scans, a model must accept images; to operate as an agent, it must also support tool calls. See model configuration in pi.
The project used Gemini, one of the leading vision models, with good OCR/HTR reading quality. Models accessed through Ollama—inkling-2-small:cloud and kimi-k3.1-pro:cloud—were also used; these support text, images and tools. Cost matters when choosing a model: the strongest commercial models can be expensive in agent workflows, and processing a book of several hundred pages such as Simson’s may cost several hundred Polish złoty or more. Open-source models are less expensive; access may sometimes be available free of charge on academic institutions’ servers, or through an Ollama Cloud subscription.
Connecting through Ollama on your own computer
After installing and starting Ollama, run the following commands in a terminal:
ollama signin
ollama list
ollama run kimi-k3.1-pro:cloud
ollama run inkling-2-small:cloud
The first command signs you in, the second lists the models, and the third and fourth let you test responses from the specified models. If you are already signed in, you do not need to sign in again. Model availability and limits depend on the current service and your account.
When using Ollama, the connection follows this route:
Chronos → pi → http://localhost:11434/v1 → Ollama Cloud
Ollama runs on the laptop as an intermediary, but the :cloud model performs its computations in the cloud. The text or images included in the request are therefore sent there.
The pi model configuration file
Open ~/.pi/agent/models.json. The ~ symbol denotes the user’s home directory (the path may look different on Windows); in this project’s environment, it is /home/{user}/.pi/agent/models.json. This is a user-level pi configuration shared across that user’s projects. If the file already exists, add the provider to its existing providers section, retaining the other entries.
{
"providers": {
"ollama": {
"baseUrl": "http://localhost:11434/v1",
"api": "openai-completions",
"apiKey": "ollama",
"compat": {
"supportsStore": false,
"supportsDeveloperRole": false,
"supportsReasoningEffort": false,
"maxTokensField": "max_tokens"
},
"models": [
{
"id": "kimi-k3.1-pro:cloud",
"name": "Kimi K3.1 Pro (Ollama Cloud)",
"input": ["text", "image"],
"reasoning": true,
"contextWindow": 1048576
},
{
"id": "inkling-2-small:cloud",
"name": "inkling-2-small (Ollama Cloud)",
"input": ["text", "image"],
"reasoning": true,
"contextWindow": 1048576
}
]
}
}
}
openai-completions specifies the communication protocol, while baseUrl identifies the destination for requests. The compat settings limit the parameters pi sends to the server. The input field declares that the model accepts images; check this capability in the model’s documentation, as not all models are multimodal.
Reload VS Code using Developer: Reload Window, start a Chronos session and select a model under the ollama provider. For routine analysis, you can use the model identified as inkling-2-small:cloud or one of the Chinese open-source models. First test the chat, then try extracting data from a single page.
5. The first prompt and reading a single page
After importing the scans from the PDF, the project began with a simple instruction:
Read the inventory text and divide it into entries. The inventory starts at scan page_0029.png and ends at page_0859.png; a supplementary list also runs from page_0859.png to page_0861.png. Entries are marked by dates, the year appears at the beginning of the page, and the entry numbers appear at the end of each entry on the right, following a square bracket. In the supplementary list, the year is given alongside the date. Save the processing results in JSON format. For now, read only the first page.
This instruction gives the model information about the structure of the printed page: a date begins an entry, the year has to be read from the heading, and the number at the end helps identify the record’s boundary. Starting with a single page allows these assumptions to be assessed before they are applied to hundreds of scans.
The agent saved 13 entries in the file for the first page. The following example shows the basic structure of the first record:
{
"year": "1531",
"date": "Jan. 16.",
"text": "Jan. 16. — Danzig an die Markgrafen von Brandenburg und Herzoge von Mecklenburg: fordert Schadenersatz für die in ihren Gebieten überfallenen Danziger. — Miss. 11, 647—649. 
After the first attempt, all 13 records were compared with the scan: entry boundaries, dates, personal names, place names, archival references and final entry numbers. The Data tab in the Chronos panel makes browsing easier, but it is also worth opening the file itself. A misread number or omitted passage is easier to correct before extending the task.
An example of a corrective instruction:
Compare all the records with scan 29. List discrepancies and uncertain cases. Retain the original transcription and save corrections in a new version of the file. Do not modernise German spelling or archival references.
6. Processing further pages and merging entries
Entries spanning page boundaries
The first entry on a page may continue the text from the previous page. The date appears at the beginning of an entry, while its identifying number appears only at the end. Simply splitting the material by page would therefore create two apparent records.
In this project, the agent introduced the working flags is_continuation and is_incomplete. The merge_entries_*.py scripts, also created by the agent, joined the fragments, while chronos_page could become a list, such as [50, 51]. This allowed the process to recognise that a list of pages refers to a single source entry spread across several images, rather than several independent entries.
An example of an expanded instruction:
Read the specified pages into separate JSON files. Set
is_continuation: trueif the first fragment continues the previous page, andis_incomplete: trueif the last entry is cut off. Usenullfor a missing number or date. Do not guess missing passages. When merging, retain all the scan numbers inchronos_page.
Page batches and expert tasks
Because the first page had been read reasonably accurately, work could proceed to the whole collection. Given the size of the volume, this had to be done in batches: the agent was instructed through the chat to process successive groups of 30–50 or 100 pages, then merge the results into one large JSON file.

Chronos’s task and task_batch tools can analyse individual pages or batches of pages. Expert activity can be followed in the interface. For tasks requiring confirmation, check the proposed scope before approving them in the chat. Once processing was complete, the results were merged using a script. See Chronos tools.
Errors could occur during processing, for example in communication with the LLM. The agent was nevertheless able to notice errors and gaps and suggest reprocessing or scripts to repair the problems.
Project memory
Findings about the source’s layout and other important information can be saved in notes for the agent. When resuming work, you can ask it to read the notes and check the output files. These notes make it easier to return to the project. For example:
Save the rules for identifying entries, the method for merging continuations and the last verified range in the project memory. Distinguish completed operations from planned ones. Identify the input and output files and any unresolved issues.
The agent often suggests saving information relevant to processing that has emerged during its conversation with the historian.
7. Completing the inventory transcription
The complete Danziger_Inventar_1531_1591.json file contains more than 10,400 records. However, these do not yet include all the data a historian might need. An additional prompt therefore requested place fields, since some entries were associated with a particular location, and an ISO-format date field to facilitate sorting and filtering in the database. Reviewing the data in the Data tab also revealed a need for certain corrections.

Separating dates from places
After extraction, place names were found in the date field, for example in Jan. 27, Gottorp.. The agent was asked to move them to a separate place field without removing the information from text.

Entry no. 3 includes date: "Jan. 27.", place: "Gottorp" and iso_date: "1531-01-27". place was interpreted as the location associated with the dating or issuing of the document. It is not a list of all the places mentioned in the entry: Gdańsk appearing as the sender or Słupsk as the addressee does not automatically justify filling this field. Such relationships require a separate data model.
ISO dates without losing historical information
A value such as 1531-01-16 makes sorting and filtering easier. However, not all dates in the source are that precise. The inventory includes months without a day, date ranges and expressions such as “before 23 June”. It is worth retaining both the original wording and its interpretation.
The script prepared by the Chronos agent used the first day of the month or year for incomplete dates. This gave the record a sortable value, but it introduces the risk of false precision. For example, the source’s [Juli.] was stored as 1531-07-01. This must not be treated as a statement that the document was produced on 1 July.
An example instruction for the agent:
Check
iso_dateagainst the source’s dating. For incomplete or approximate dates, date ranges and double dates, propose fields that preserve this information. Do not replace a missing day with an asserted date on the first day of the month. Prepare a report of the proposed changes before recalculating the whole dataset.
Polish place names
The additional place_pl field is intended to facilitate searching in Polish, while place retains the form read from the printed text. Assigning a Polish name is itself a proposed identification that requires checking, especially for ambiguous names and historical variants. Here the model relied on its own knowledge, although external services could also be used.
An example prompt:
Compile a list of unique
placevalues. Separate probable place names from dates and text fragments that have been extracted incorrectly. Suggest Polish equivalents; for ambiguous cases, give your reasoning and leave them marked for review. Retain the original name.
Not every place has a distinct Polish name. Nor can every historical name be identified with a present-day settlement without further investigation. The future database may also need name variants and relationships between them.
Translation into text_pl
Another task the Chronos agent could carry out using the language model was translating the text field into Polish. text remains the basis for comparison with the German printed source, while text_pl helps with reading and searching.
Add a Polish translation in
text_pl, retainingtext. Do not omit dating, uncertainty markers, numbers or archival references. Do not expand uncertain abbreviations without marking the expansion. First translate a sample of 25 entries and identify cases that require a decision on terminology.

Translation scripts were created for Gemini and inkling-2-small, although most of the material was translated by the smaller open-source model because of cost. The script processed batches of 25 entries sequentially, so as not to overload the model with too much text at once, and saved results so that work could resume after a failure. Once all the batches had been translated, the results were merged with the main JSON file. The translation quality was satisfactory for browsing and searching for information, but it certainly requires expert revision.
8. The index of people and places
The index is a separate part of the book: it contains headwords, name variants, subentries and cross-references. Reading it can help link scattered mentions, but it does not replace the historian’s identification of people and places.
Work on the index can begin by asking the agent to process a representative sample covering a person, a place, a headword with variants and a long list of references:
Read a sample of the index (page_1077.png). Preserve column order, the hierarchy of headwords and the original reference strings. Separate the headword, name variants, description, subentries and references to other headwords. Distinguish references to entries from references to pages. Do not merge people or places solely because their names are similar. Save the result as JSON and compare it with the scan.
The following fictional example structure illustrates a possible format; it is not a transcription of an actual headword in Simson’s book:
{
"index_id": "idx-demo-001",
"label_original": "Example place",
"entity_type": "place",
"name_variants": [],
"references_raw": "12–14. S. 841.",
"references": [
{"kind": "entry", "number_raw": "12–14", "numbers": ["12", "13", "14"]},
{"kind": "printed_page", "number_raw": "841"}
],
"see_also": [],
"parent_index_id": null,
"review_status": "unreviewed"
}
After assessing the transcription quality, you can refine the prompt and instruct the agent in the chat to process the entire index and save it to indeks.json.
9. The next stage: an SQLite database
The JSON files are temporary working files; the historian’s aim is to obtain a database. SQLite is a convenient format that can readily be used by a web application. The first task for Chronos was to propose a structure and demonstrate importing a small sample.
The data model proposed by the agent:
| Table | Contents |
|---|---|
entries |
An internal entry ID, the number in the printed source, German text, translation, dating and review status. |
pages |
The scan number, printed page number, image path and section of the volume. |
entry_pages |
Links between entries and pages, including entries spanning more than one page. |
index_items |
Headwords, subentries, original wording and the structure of the index. |
index_references |
Original reference strings, their types and their matching status against entries or pages. |
entities and entity_names |
Verified people and places and their name variants. |
entry_entities |
Links between an entry and a person or place, with roles such as addressee, sender, place of issue or mention. |
processing_runs |
The operation date, model, prompt or prompt ID, and the version of the input file. |
An example instruction:
Propose an SQLite database for the entries, pages and index. Show the schema and import a sample of 20 records, including an entry spanning more than one page and an incomplete date. Retain the original numbers and texts. The import must report errors, inconsistent references and skipped records. Running it again must not create duplicates. Do not replace an existing database without retaining a version of it.
The final instruction should explicitly require full-text search support using FTS5.

10. An application for browsing the data
The ultimate aim of the Chronos agent’s work—and the historian’s main expectation—was a web application that would make the data easy to browse, search and filter. The first step is to ask the agent to prepare a design:
Prepare a design for a fairly simple web application using Python and Flask. It should have two main tabs: an inventory with a searchable and filterable list of entries, and an index that can also be searched and filtered. Entry numbers associated with an index item should be clickable and display the corresponding entries. An additional feature could link each entry to its PNG scan, with a link or button to display it on request. Save the application design in a Markdown file in the project directory.
You can also point the agent towards existing applications as examples of style and functionality. Here, the database of Lithuanian parliamentarians was used as a reference.
After creating the application, the agent can run it locally and provide a link in the chat:

11. Documentation
The final instruction for the project might be:
Save a report on the current state of the project. Identify the last verified version of the data, completed operations, known errors and the next step. Do not describe the dataset as complete unless the source ranges and numbering have been verified. Update the project memory, maintaining the distinction between results, hypotheses and plans. Prepare documentation for the database and web application to help the IT department deploy it on a server. Also specify which files I need to send so that the IT department receives a complete set of files and data. Save the documentation in Markdown files.
The finished application uses a database created by processing the scans with the Chronos agent.


The entire process, from downloading the PDF to running the database application for the first time, took one working day, including time spent learning the system and writing this blog post. The system is not error-free, and working in a development environment may present an obstacle for some historians. As noted earlier, however, the developers are working on a standalone desktop version. This example involved scans of a printed book, but manuscripts can be processed in a similar way if the chosen model can read the relevant handwriting. The approach and its potential for historical research are certainly interesting and promising. Further examples can be found on the developers’ blog.
The source code of the application generated during this work is available in the GitHub repository.