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 oneretrieve 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.
Step 3 — Ask, and see which file answered
Step 4 — The document stays a first-class object
Evals
- Upload one file you know the answers in. Ask three questions from it.
- Ask something the file does not cover. Empty is correct.
- Check
document_idresolves on every answer you would act on. - 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
tagson upload if later reads will be scoped, or the document is invisible to every scoped query.
The script
Complete and runnable:document_qa.py.