Skip to content

Extending nirmala

nirmala owns the generic engine; your application owns its domain. Everything domain-specific is a hook, so an application can depend on nirmala entirely and keep only its own logic and configuration.

Hook Shape
passwords= a list, fn(document) -> [str], or an object with .passwords_for(document)
Normalizers(by_field={...}, by_type={...}) fn(value, ctx) or fn(value); None disables a default
postprocessors=[...] fn(record: dict, document_text: str) -> dict
rules= @rule, NLRule, load_rules(...), or a Rule subclass
events= fn(event, data) or an object with .emit(event, data)
llm=, vision_llm=, Judge(llm=...) any LLMClient

NormalizeContext gives a normalizer the field name, the document_text, the whole record and the field annotation, so it can look at neighbouring fields.

Events: extract.started, extract.text, extract.vision, extract.finished, select.finished, decide.finished. A failing sink is logged and never breaks extraction.

See examples/custom_hooks.py.