Skip to content

Bulk & batch ingest

Ingest handles one source at a time. To bring in a whole corpus today, loop — and because the loop is keyed on a content hash, it is safe to re-run: unchanged documents do no work, so a crashed or interrupted bulk run just resumes where it left off. Python gets that hash check from the store’s manifest; Go and JavaScript have no store on the plain go get / npm install surface, so they compute the same hash themselves with euid.Checksum / sha256Hex.

from pathlib import Path
def run(root):
ingested = skipped = 0
for path in sorted(Path(root).rglob("*.txt")):
r = rag.ingest(str(path), document_id=path.stem)
if r.status == "ingested":
ingested += 1
else: # "unchanged" — content hash matched, no work done
skipped += 1
print(f"{ingested} ingested, {skipped} unchanged")
run("corpus") # 2 ingested, 0 unchanged
run("corpus") # 0 ingested, 2 unchanged ← re-run is free

This is the “resumable by construction” pattern: content-hash idempotency is the same mechanism a job queue would use for dedup, so re-running the loop is your retry.

print(rag.ask("How many days of annual leave?").evidence.decision) # answered

For a site, crawl() does a same-domain breadth-first walk, ingesting each page:

results = rag.crawl("https://docs.example.com", max_pages=200, max_depth=4)