Metadata-Version: 2.5
Name: sirdas
Version: 0.5.1
Summary: Local document parsing for AI agents and ML: PDF, Word, Excel, PowerPoint, HTML, email and scans to Markdown, cited fields, chunks and datasets. Nothing is uploaded.
Project-URL: Homepage, https://www.sirdaspdf.com
Project-URL: Documentation, https://www.sirdaspdf.com/docs/agents/python.md
Author: Sırdaş
License-Expression: MIT
Keywords: ai-agents,anonymization,dataset,document-parsing,fine-tuning,langchain,llamaindex,llm,local-first,ocr,pdf,rag
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing
Requires-Python: >=3.9
Provides-Extra: crewai
Requires-Dist: crewai>=0.80; extra == 'crewai'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == 'langchain'
Provides-Extra: llamaindex
Requires-Dist: llama-index-core>=0.10; extra == 'llamaindex'
Description-Content-Type: text/markdown

# sirdas (Python)

Local document parsing for AI agents and machine learning. PDF (including scans), Word, Excel, PowerPoint, OpenDocument, EPUB, HTML, CSV, email and images become Markdown, **fields cited with page and position**, tables, form fields, cited chunks and training datasets. **Nothing is uploaded**: it runs on your machine.

```bash
pip install sirdas          # needs Node.js 20+ (the engine is shared with the CLI and MCP server)
```

```python
import sirdas

doc = sirdas.read("factura.pdf")                 # one call does it all
doc["document_type"]                             # "factura"
{f["name"]: f["value"] for f in doc["fields"]}   # número, CUFE, NIT, IVA, total… each with page, evidence and bbox
doc["next_steps"]                                # what to do next

sirdas.convert("informe.docx")["markdown"]
sirdas.split_documents("lote-escaneado.pdf", output_dir="separados/")
sirdas.forms("formulario.pdf")                   # filled fields and checkboxes
sirdas.dataset(["a.pdf", "b.docx"], "ds/", format="alpaca")   # + Hugging Face dataset card
```

LangChain and LlamaIndex:

```python
from sirdas.integrations import SirdasLoader, SirdasReader
docs = SirdasLoader("contrato.pdf").load()              # langchain Documents, stable ids
nodes = SirdasReader().load_data("historia.pdf")        # llama_index Documents
```

KYB and lending (from 0.5.0): review a company's package and check whether a file
changed. A failed check or a fingerprint that does not match is a result you read,
not an exception.

```python
r = sirdas.package("applications/acme", profile="lending")
r["summary"]                                     # {"pass": 7, "fail": 1, "missing": 0, "info": 2}
[c for c in r["checks"] if c["status"] == "fail"]  # each with file, page and the exact line
sirdas.fingerprint("statement.pdf", expected="9253ac6e…")["match"]   # same file, byte for byte?
```

CrewAI (`pip install "sirdas[crewai]"`): four tools that run locally and hand the
agent cited, anonymized text.

```python
from crewai import Agent
from sirdas.integrations import crewai_tools
underwriter = Agent(role="Underwriter", goal="Review loan packages", backstory="…",
                    tools=crewai_tools())   # read · ask a folder · extract a batch · review a KYB package
```

LangChain agents (`langchain>=1`): LangChain's `PIIMiddleware` keeps the
strategy (`redact`, `mask`, `hash`, `block`); Sırdaş's detector adds SSNs, EINs,
labelled names, MRNs, account and ID numbers. Checked against `langchain==1.4.9`:
the model receives `Patient Name: [REDACTED_PERSON]`, and an SSN raises
`PIIDetectionError` before the call. Redaction there is one-way; for the round
trip use the Gateway.

```python
from langchain.agents import create_agent
from langchain.agents.middleware import PIIMiddleware
from sirdas.integrations import langchain_pii_detector

agent = create_agent("openai:gpt-5", middleware=[
    PIIMiddleware("ssn", detector=langchain_pii_detector(types=["SSN"]), strategy="block"),
    PIIMiddleware("sirdas", detector=langchain_pii_detector(), strategy="redact"),
])
sirdas.find_pii("SSN: 123-45-6789")   # [{"type": "SSN", "value": "123-45-6789", "start": 5, "end": 16}]
```

Personal data is anonymized by default (`anonymize=False` to keep it). Password-protected PDFs raise `PasswordRequired`; pass `password=`.

Docs: https://www.sirdaspdf.com/docs/agents/python.md
