Documents
The Documents resource handles file upload and processing. Upload PDFs, text files, and other documents to extract knowledge and add it to your graph.
client.documents.upload()POST /v1/documents/uploadUpload a document for processing. Returns a job ID to track progress.
Parameters
filestr | Path | bytes | BinaryIORequiredThe file to upload. Can be a file path, bytes, or file-like object.
group_idstrRequiredThe group ID to associate the document with.
filenamestrOptionalOverride filename (useful when passing bytes or file objects).
Returns
UploadDocumentResponse with job_id, filename, status, and message.
Example
1from memoair import MemoAir23client = MemoAir()45# Upload a PDF6job = client.documents.upload(7 file="company_handbook.pdf",8 group_id="org:acme",9)1011print(f"Job ID: {job.job_id}")12print(f"Status: {job.status}")client.documents.get_status()GET /v1/documents/jobs/{job_id}Check the processing status of an uploaded document.
Returns
JobStatusResponse with:
job_id,filenamestatus: JobStatus- Current processing stageprogress: int- Percentage complete (0-100)episode_count- Number of chunks createdis_complete(),is_success()- Helper methods
Job Status Values
QUEUEDWaiting to be processedPARSINGExtracting text from documentENRICHINGExtracting facts and entitiesINGESTINGAdding to knowledge graphCOMPLETESuccessfully processedERRORProcessing failed1status = client.documents.get_status(job_id="job-123")23print(f"Status: {status.status}")4print(f"Progress: {status.progress}%")56if status.is_complete():7 if status.is_success():8 print(f"Created {status.episode_count} chunks")9 else:10 print(f"Error: {status.error_message}")client.documents.wait_for_completion()GET /v1/documents/jobs/{job_id}/waitBlock until a document finishes processing. Polls status internally.
Parameters
job_idstrRequiredThe job ID returned from upload().
poll_intervalfloatOptionalDefault: 1.0Seconds between status checks.
timeoutfloatOptionalMaximum seconds to wait. None = wait forever.
Example
1from memoair import MemoAir23client = MemoAir()45# Upload and wait for completion6job = client.documents.upload(7 file="handbook.pdf",8 group_id="org:acme",9)1011# Block until done (with timeout)12try:13 status = client.documents.wait_for_completion(14 job_id=job.job_id,15 timeout=300, # 5 minutes max16 )1718 if status.is_success():19 print(f"Document processed: {status.episode_count} chunks")20 else:21 print(f"Processing failed: {status.error_message}")2223except TimeoutError:24 print("Document processing timed out")client.documents.list_jobs()GET /v1/documents/jobsList all document processing jobs, optionally filtered by status.
1# List all jobs2jobs = client.documents.list_jobs(limit=20)34# Filter by status5processing = client.documents.list_jobs(status="PARSING")6completed = client.documents.list_jobs(status="COMPLETE")78for job in jobs.jobs:9 print(f"{job.filename}: {job.status}")client.documents.history()GET /v1/documents/history/{group_id}List all processed documents for a group.
1# Get document history for an organization2docs = client.documents.history(3 group_id="org:acme",4 limit=50,5)67print(f"Total documents: {docs.total}")8for doc in docs.documents:9 print(f"- {doc.filename} ({doc.created_at})")