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
Release files for rakam-systems-documents 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rakam_systems_documents-0.1.1.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rakam_systems_documents-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.6 kB
Release files / rakam_systems_documents-0.1.1.tar.gz
| Download URL | rakam_systems_documents-0.1.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f672220f714fc71ad80d4b69a616668e5290b7d3c7001dfcb65b5cc5d648a73
|
|
BLAKE2b-256 checksum How to use checksums |
b9ca0e420f8c6d4d8a385d11ae9130a0817b61f148b5607b3cf2b18a8e4857f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / rakam_systems_documents-0.1.1-py3-none-any.whl
| Download URL | rakam_systems_documents-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4b0c27df5bbed4e066a6e447ccfb2282e45017fe9d794bcae31c3b28a588fb4
|
|
BLAKE2b-256 checksum How to use checksums |
ab75f8c6ad21272fb7b30872862606b197a2ae2b465f9decc0dc6c1f4e4bc697
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|