breakpointsoftware/document-parser
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Drive Folder Scan (Unprocessed Files)
The app supports scanning one or more Google Drive folders and parsing only files that were not processed before.
Required environment variables
GOOGLE_SERVICE_ACCOUNT_JSONorGOOGLE_SERVICE_ACCOUNT_FILEGOOGLE_DRIVE_FOLDER_IDS: comma-separated Drive folder IDs
Optional:
FIREBASE_TRACK_PROCESSED: defaults totrueFIREBASE_TRACKER_COLLECTION: defaults toprocessed_filesFIREBASE_DOCUMENTS_COLLECTION: defaults toprocessed_documentsGOOGLE_DRIVE_FACTURAS_BASE_PATH: defaults toFacturasGOOGLE_DRIVE_INVOICE_ROOT_FOLDER_ID: optional Drive folder id used as root when creatingGOOGLE_DRIVE_FACTURAS_BASE_PATH
How it works
- Click Scan Drive folders in the UI.
- The app recursively scans configured Drive folders.
- Supported file types are downloaded to a temporary local folder (
.txt,.pdf,.docx,.jpg,.jpeg,.png). - Files already registered in Firebase are skipped.
- New files are parsed and appended to the same grid used by uploads.
Drive Orchestration (Status + modificationDate)
The orchestration script scans Drive, checks if a document was already processed, parses only new/modified documents, and saves parsed payload + lifecycle status in Firebase.
Before each document is persisted, the file is moved in Drive using this path rule:
Facturas/yyyyMMfor valid invoices wherefechacan be parsed.Facturas/Corruptedwhen required sheet data is missing orfechais not parseable.
You can change Facturas with GOOGLE_DRIVE_FACTURAS_BASE_PATH.
Status rules
Parsed: document was never processed before.Modified: document exists in Firebase but DrivemodifiedTimechanged.Sent: document was parsed and then sent to Google Sheets.
Run orchestration
python document_orchester.py --model gpt-4oSend parsed rows to Google Sheets and mark them as Sent:
python document_orchester.py --model gpt-4o --sendOptional flags:
--no-subfolders: scan only direct files in configured folders.--output <path>: save orchestration summary JSON to a file.
Public API Endpoint For Orchestrator
The Gradio app exposes a public API endpoint that internally calls the orchestrator flow.
Security:
- Set
ORCHESTRATOR_API_KEYin the server environment. - Every endpoint call must include that key in the payload.
Endpoint name:
orchestrate_drive_documents
Local URL example:
curl -X POST "http://localhost:7860/gradio_api/call/orchestrate_drive_documents" \
-H "Content-Type: application/json" \
-d '{"data": ["gpt-4o", true, false, "YOUR_API_KEY"]}'data argument order:
model(string)include_subfolders(boolean)send_to_sheet(boolean)api_key(string)
Response payload is the same summary produced by orchestrate_drive_documents in document_orchester.py.
When a row is missing required sheet data, it is written to a worksheet named corrupted data instead of the main sheet.
