Seth0330 commited on
Commit
0b2c1fd
·
verified ·
1 Parent(s): e47273e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -107,22 +107,25 @@ def extract_text_from_unstract(uploaded_file, status_box=None):
107
 
108
  def build_prompt(doc_text, checklist):
109
  return f"""
110
- You are a careful, expert document validation agent for mortgage workflows.
111
 
112
- Analyze the following extracted document text and this checklist JSON:
113
- {json.dumps(checklist)}
114
 
115
- First, **determine what document you are reading** (e.g., Driver's License, Passport, Bank Statement, etc.) as precisely as possible, based on content, layout, and terms.
116
 
117
- **DO NOT** attempt to "force match" or guess a checklist match if you are not sure. If the detected document type does NOT correspond (even loosely) to any checklist item, set "checklist_matched": false and recommend rejection. If it matches, set "checklist_matched": true.
 
 
 
118
 
119
- Extract the expiry date if found (or set as null/empty), and if present, check if it is expired compared to the current date: 21st June 2025.
 
120
 
121
- Assess if the document looks genuine (as much as possible from the text), and provide a confidence score (0-100).
122
 
123
  Respond with this JSON:
124
  {{
125
- "document_type": "...", // Your best judgment (e.g. Driver's License)
126
  "expiry_date": "...", // ISO format if possible
127
  "is_expired": true/false,
128
  "looks_genuine": true/false,
 
107
 
108
  def build_prompt(doc_text, checklist):
109
  return f"""
110
+ You are a careful, expert document validation agent for mortgage and finance workflows.
111
 
112
+ Before you answer, do this: Carefully scan the document for ANY evidence of regional/provincial or country-specific card types (such as "Ontario Health Card", "Medicare Card", "Insurance Card", "SIN", "Driver's License", "Passport", etc.)—be as specific as possible using visible card titles, authority names, or issuer logos.
 
113
 
114
+ If you see terms like "Health Card", "Medicare", "Medical Insurance", "OHIP", or any explicit health system/insurance terms, classify it as a health card (e.g. "Ontario Health Card"). Do NOT call it "Identification Card" if a more specific name is visible, even if it is a form of ID.
115
 
116
+ Checklist for precision:
117
+ - Prefer the **most specific** document type (e.g. "Ontario Health Card" over just "Identification Card" or "Provincial ID").
118
+ - If there is any ambiguity, include relevant keywords from the card (like "Health", "Medicare", "OHIP", "SIN", "Social Insurance", "Driver", etc.) in the output type.
119
+ - If still not sure, show your best guess but include all possible hints from the document text.
120
 
121
+ Analyze the following extracted document text and this checklist JSON:
122
+ {json.dumps(checklist)}
123
 
124
+ Follow all prior instructions.
125
 
126
  Respond with this JSON:
127
  {{
128
+ "document_type": "...", // e.g. Ontario Health Card, BC Services Card
129
  "expiry_date": "...", // ISO format if possible
130
  "is_expired": true/false,
131
  "looks_genuine": true/false,