Core Features
RAG Enforcement
Ensure AI responses are grounded in your source documents and prevent hallucinations.
Overview
RAG Enforcement governs the chunks your retriever returns before they reach the model: it checks each chunk came from an approved source, scans it for PII, and applies your content policy.
Source Allowlisting
Reject chunks from unapproved sources
PII Screening
Detect and redact PII in retrieved text
Content Policy
Block chunks that violate your policy
Validating Retrieved Chunks
RAG enforcement runs server-side, in the Tork cloud. You send the chunks your retriever returned and Tork checks each one against your configured source allowlist, PII rules and content policy before they reach the model.
The cloud client class TorkClient ships in @torknetwork/sdk (npm) — a different package from the on-device tork-governance family, whose only entry class is Tork. There is no Python cloud client, so from Python call the REST endpoint directly with a Bearer token.
Chunk-Level Analysis
Every chunk comes back with the outcome of each check that ran against it:
Source Rules and Config
Which sources are allowed is configured as source rules. Rules are matched by priority; the first match wins, and defaultAction decides what happens to a chunk no rule matched.
Per-request behaviour is set with the optional config object on a validate call:
Best Practice: Validate retrieved chunks before they enter the prompt, not after the model has answered — once unapproved text is in the context window, the response is already derived from it.