Generic document preparation: any source -> PreparedContent (markdown + structured rows + provenance)
Project description
rakam-systems-documents
Generic document preparation: turn any source document into clean, structured, provenance-tagged content the rest of the stack can reason over.
from rakam_systems_documents import prepare, MistralOCRProvider
pc = prepare(raw_bytes, mime="application/pdf", filename="invoice.pdf",
ocr=MistralOCRProvider()) # ocr optional; native PDFs skip it
pc.markdown # what a model reads
pc.rows # structured rows (tabular sources), header-keyed + provenance
pc.provenance # page/sheet/row refs
pc.provider # pdf_text | mistral_ocr | docling_ocr | tabular | text | none
What it is (and isn't)
One job: bytes -> PreparedContent. Format dispatch, parse/decode, hybrid-OCR
routing, provenance normalization, truncation. A pure function — the only I/O is the
injected OCR provider.
Not its job: storage, chunking, embedding, indexing, async/status, or any business meaning (extraction, matching, classification). Those belong to the caller — the library gives every caller one document→content primitive so none reimplements parsing/OCR.
Formats
| Source | Handling |
|---|---|
| Native PDF | pymupdf4llm → markdown (text layer, exact, no egress) |
| Scanned PDF / image | hybrid gate → OCR provider (see below) |
| Excel / CSV | openpyxl / csv → markdown table + structured rows + (sheet,row) provenance |
| Email / text | rfc822 + multi-encoding decode (binary rejected) |
OCR is pluggable
Native-text PDFs never hit OCR. Scanned pages / images route to an OCRProvider:
MistralOCRProvider(default) — the Mistral hosted OCR API (/v1/ocr). NeedsMISTRAL_API_KEY.DoclingOCRProvider— on-prem, no egress. Requires the optional extra:pip install rakam-systems-documents[docling].
A missing/unavailable engine degrades gracefully (native text still works; a scan yields
provider="none" + a help hint, never an exception).
Install
pip install rakam-systems-documents # Mistral OCR path
pip install rakam-systems-documents[docling] # + on-prem OCR
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rakam_systems_documents-0.1.0.tar.gz.
File metadata
- Download URL: rakam_systems_documents-0.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73aaec32f6d8817dc5069e95e9234f4c6c33a13bcc893bd00e1f28976f136388
|
|
| MD5 |
87609b0a927b17b9035d898cdece21ec
|
|
| BLAKE2b-256 |
0c6e0935784c707147b185bc85bd72e5ec8db35c35d55733c046009ae3b83120
|
File details
Details for the file rakam_systems_documents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rakam_systems_documents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab8debd890aceb7744f8aad5b1ce1c12226001754aaad1482492c065b358750f
|
|
| MD5 |
7b86153a04fcc05717cc4f9660f26351
|
|
| BLAKE2b-256 |
9d44aa75e6009ac31145688ab51dc4e02bedfa0f69812921a41dcc8f7478973a
|