feat: batch multi-template filling with single LLM extraction. Closes…#241
Open
utkarshqz wants to merge 2 commits intofireform-core:mainfrom
Open
feat: batch multi-template filling with single LLM extraction. Closes…#241utkarshqz wants to merge 2 commits intofireform-core:mainfrom
utkarshqz wants to merge 2 commits intofireform-core:mainfrom
Conversation
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
POST /forms/fill/batch— the core multi-agency filing endpoint that closes #156.A single incident transcript now fills Police, Fire, and Ambulance PDFs simultaneously in one request. The key architectural decision is that LLM extraction runs exactly once for the entire batch. Fields from all requested templates are merged into a dynamic superset, extracted in a single Ollama call, then split back to each template deterministically using Python. No hardcoded field categories. No redundant LLM calls. Works with any PDF structure natively.
Also adds PDF path validation on template load, permanently fixing the stale path bug (#235) that caused silent
500errors after re-cloning the repository.How the single-pass extraction works:
Files changed:
api/routes/forms.py— addedPOST /forms/fill/batch, added PDF path validation toPOST /forms/fillapi/schemas/forms.py— addedBatchFormFill,BatchResultItem,BatchFormFillResponseschemasapi/db/repositories.py— addedget_formandget_all_templateshelperssrc/filler.py— addedfill_form_with_data()for deterministic PDF filling from pre-extracted dicttests/conftest.py— addeddb_session,tmp_pdf,clean_dbfixturestests/test_forms.py— updated 503 test, added 404 path validation testFixes #156
Fixes #235
Addresses #206
Addresses #236
Type of change
How Has This Been Tested?
The existing test suite was extended and all tests pass locally.
New tests added:
test_fill_form_pdf_not_on_disk_returns_404— verifies path validation returns clear 404test_fill_form_ollama_down_returns_503— updated to use realtmp_pdffixture so path validation passes before Ollama mock firesManual testing steps:
ollama serveuvicorn api.main:app --reloadPOST /templates/createdownload_urlvaluesTest Configuration:
Test results:
Checklist: