Skip to main content
← All use cases

The scenario

Half of what your agent should know is in files — a policy, a spec, a handbook. You do not want a second retrieval system for them, and you do not want to pre-chunk anything. Uploads land in the same space as recorded memories, so one retrieve answers from both.

Step 1 — Upload

file takes a path, raw bytes, or a file object. PDF, DOCX, PPTX, XLSX, HTML, TXT/MD/CSV, images, MP3/WAV audio and MP4/MOV/WEBM/MKV video are all read into text.

Step 2 — Wait for it to be searchable

Ingestion is asynchronous. The upload returns job ids; completed means that file is searchable.
In production use webhooks instead of a loop.

Step 3 — Ask, and see which file answered

Step 4 — The document stays a first-class object

Deleting a document removes every memory extracted from it in one call — which is what makes “remove that outdated policy” a single operation rather than a hunt.

Evals

  1. Upload one file you know the answers in. Ask three questions from it.
  2. Ask something the file does not cover. Empty is correct.
  3. Check document_id resolves on every answer you would act on.
  4. Delete the document and re-ask. Everything from it should be gone.

Guardrails

  • A question asked seconds after upload may legitimately find nothing. Wait for completed; do not treat the gap as a bug.
  • Per-file limits apply — 25 MB generally, 64 MB for video, with request totals above that. One oversized file rejects the whole request.
  • Uploads take scope too. Pass tags on upload if later reads will be scoped, or the document is invisible to every scoped query.

The script

Complete and runnable: document_qa.py.