pip install sirdas # requires Node.js 20+; the engine is the same one the CLI and MCP server use
pip install "sirdas[langchain]" # or [llamaindex]
The client runs sirdas … --json locally. It finds the executable in this order: SIRDAS_BIN, sirdas on PATH, npx -y sirdas@<version>.
Read anything
import sirdas
doc = sirdas.read("factura.pdf") # also .docx, .xlsx, .pptx, .html, .eml, .png…
doc["status"] # "ok" | raises sirdas.PasswordRequired
doc["document_type"] # "factura"
for f in doc["fields"]:
print(f["name"], f["value"], f["page"], f["bbox"]) # bbox: [x0, y0, x1, y1] in 0–1
doc["tables"], doc["form"], doc["documents"], doc["chunks"], doc["next_steps"]
Options: password=, anonymize=True, ocr=True, max_tokens=1500.
Other calls
| Call | Returns |
|---|---|
sirdas.convert(path) | {format, markdown, tables, warnings} |
sirdas.split_documents(path, output_dir=None) | {segments, files} |
sirdas.forms(path) | {fields, checkboxes} |
sirdas.classify(path) | {type, confidence, signals, runnerUp} |
sirdas.chunks(path, max_tokens=1500) | [{id, pages, section, text, tokens}] |
sirdas.tables(path) | tables |
sirdas.dataset(paths, out_dir, format="chat", split=True) | written files, incl. README.md dataset card |
sirdas.protect(path, password, output) / sirdas.unlock(path, output, password="") | output path |
LangChain and LlamaIndex
from sirdas.integrations import SirdasLoader, SirdasReader
docs = SirdasLoader("contrato.pdf", max_tokens=800).load() # langchain_core Documents
nodes = SirdasReader().load_data("historia.pdf") # llama_index Documents
Each chunk keeps id (stable content hash — use it as the vector id), pages, section and document_type in its metadata.
Fine-tuning dataset in one line
sirdas.dataset(["contratos/"], "ds/", format="alpaca") # train/validation/test.jsonl + README.md
from datasets import load_dataset
load_dataset("json", data_files={"train": "ds/train.jsonl", "test": "ds/test.jsonl"})