feat: Gemini engine module and configuration (#129) #133
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Relates to #129
Milestone 4: Gemini Engine Module and Configuration
Create standalone Gemini 2.5 Flash module in the Python OCR service for maintenance schedule extraction.
Files
ocr/app/engines/gemini_engine.py(NEW)ocr/app/config.pyocr/requirements.txtdocker-compose.ymldocker-compose.staging.ymldocker-compose.prod.ymlRequirements
GeminiEngineclass (standalone, NOT extending OcrEngine) withextract_maintenance()methodGenerativeModel("gemini-2.5-flash")withgenerate_content()response_mime_type="application/json"andresponse_schemafor guaranteed JSON structureGOOGLE_APPLICATION_CREDENTIALS)VERTEX_AI_PROJECT,VERTEX_AI_LOCATION,GEMINI_MODELgoogle-cloud-aiplatform>=1.40.0to requirements.txtAcceptance Criteria
Tests
ocr/tests/test_gemini_engine.py(NEW)Milestone: Gemini Engine Module and Configuration
Phase: Execution | Agent: Feature Agent | Status: PASS
Changes Made
New Files:
ocr/app/engines/gemini_engine.py- StandaloneGeminiEngineclass withextract_maintenance(pdf_bytes)methodocr/tests/test_gemini_engine.py- 18 unit tests (all passing)Modified Files:
ocr/app/config.py- Addedvertex_ai_project,vertex_ai_location,gemini_modelsettingsocr/requirements.txt- Addedgoogle-cloud-aiplatform>=1.40.0docker-compose.yml- AddedVERTEX_AI_PROJECT,VERTEX_AI_LOCATION,GEMINI_MODELenv vars to mvp-ocrdocker-compose.staging.yml- Same env vars addeddocker-compose.prod.yml- Same env vars addedImplementation Details
GeminiEngineis standalone (NOT extendingOcrEngineABC) since Gemini does semantic document understanding, not traditional OCRGenerativeModelandgenerate_content()withresponse_mime_type="application/json"andresponse_schemafor guaranteed JSON structureextract_maintenance()callGOOGLE_APPLICATION_CREDENTIALS)MaintenanceExtractionResultwith list ofMaintenanceItemdataclasses (camelCase from API mapped to snake_case Python)Test Results
Test scenarios covered:
Acceptance Criteria Status
Verdict: PASS | Next: Ready for PR / Quality Review