github-actions[bot]
commited on
Commit
·
a736bf4
1
Parent(s):
dd98afc
Sync from GitHub: 3363d9befffa58a6417f0f97bfce1803aadacf1e
Browse files- inference.py +19 -22
inference.py
CHANGED
|
@@ -65,19 +65,11 @@ Output rules:
|
|
| 65 |
|
| 66 |
# Two-step Chain of Thought prompts (reasoning mode) - OPTIMIZED FOR SPEED
|
| 67 |
REASONING_PROMPT = """
|
| 68 |
-
Analyze this Indian tractor invoice and share your observations about extracting these
|
| 69 |
-
|
| 70 |
-
2. model_name
|
| 71 |
-
3. horse_power
|
| 72 |
-
4. asset_cost
|
| 73 |
|
| 74 |
Think through each field:
|
| 75 |
|
| 76 |
-
DEALER NAME:
|
| 77 |
-
- Where do you see the dealer/company name? Describe location and appearance,generally it is at top middle
|
| 78 |
-
- What language is it in? Any spelling issues?
|
| 79 |
-
- Write what you observe exactly as you see it
|
| 80 |
-
|
| 81 |
MODEL NAME:
|
| 82 |
- How is the model presented? (checkbox list, handwritten field, printed text)
|
| 83 |
- If checkboxes exist, which one is marked/selected?
|
|
@@ -89,21 +81,18 @@ HORSE POWER:
|
|
| 89 |
- Is it explicit (like "49 HP") or in a checkbox list?
|
| 90 |
- If checkboxes, which HP value is selected?
|
| 91 |
- What exact text shows the HP?
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
- Where is the final total amount located?
|
| 95 |
-
- Which number is the final amount after all taxes?
|
| 96 |
-
- What is the exact amount with currency symbol as shown?
|
| 97 |
|
| 98 |
Express your observations naturally. Be specific about what you see and any uncertainties.
|
| 99 |
"""
|
| 100 |
|
| 101 |
|
| 102 |
EXTRACTION_WITH_CONTEXT_PROMPT = """
|
| 103 |
-
Based on
|
| 104 |
{reasoning_output}
|
| 105 |
|
| 106 |
-
Extract these fields:
|
| 107 |
|
| 108 |
{{
|
| 109 |
"dealer_name": string,
|
|
@@ -112,11 +101,19 @@ Extract these fields:
|
|
| 112 |
"asset_cost": number
|
| 113 |
}}
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
Output ONLY valid JSON, no markdown.
|
| 122 |
"""
|
|
|
|
| 65 |
|
| 66 |
# Two-step Chain of Thought prompts (reasoning mode) - OPTIMIZED FOR SPEED
|
| 67 |
REASONING_PROMPT = """
|
| 68 |
+
Analyze this Indian tractor invoice and share your observations about extracting these 2 fields:
|
| 69 |
+
'model name' and its corresponding 'Horse Power'
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
Think through each field:
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
MODEL NAME:
|
| 74 |
- How is the model presented? (checkbox list, handwritten field, printed text)
|
| 75 |
- If checkboxes exist, which one is marked/selected?
|
|
|
|
| 81 |
- Is it explicit (like "49 HP") or in a checkbox list?
|
| 82 |
- If checkboxes, which HP value is selected?
|
| 83 |
- What exact text shows the HP?
|
| 84 |
+
- Horse power must come ONLY from explicit HP text, never from model numbers.
|
| 85 |
+
- Horse power may appear as "HP", handwritten like "49 HP", "63hp", "HP-30".
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
Express your observations naturally. Be specific about what you see and any uncertainties.
|
| 88 |
"""
|
| 89 |
|
| 90 |
|
| 91 |
EXTRACTION_WITH_CONTEXT_PROMPT = """
|
| 92 |
+
Based on the image and following analysis regarding 'model':
|
| 93 |
{reasoning_output}
|
| 94 |
|
| 95 |
+
Extract these fields from image and analysis:
|
| 96 |
|
| 97 |
{{
|
| 98 |
"dealer_name": string,
|
|
|
|
| 101 |
"asset_cost": number
|
| 102 |
}}
|
| 103 |
|
| 104 |
+
Critical rules:
|
| 105 |
+
|
| 106 |
+
- Dealer name must be copied exactly from the image in the original language and spelling.
|
| 107 |
+
- Model name must be copied exactly from the image without translation.
|
| 108 |
+
- HP: Number only (e.g., "49 HP" → 49). Use selected checkbox if applicable
|
| 109 |
+
- ASSET COST: Final total as number (remove ₹, commas: "1,50,000" → 150000)
|
| 110 |
+
- Checkboxes: Extract only marked options
|
| 111 |
+
|
| 112 |
+
Extraction hints:
|
| 113 |
+
- Asset cost is the total amount, usually the largest number on the page, the total amount after TAX, final price or final cost.
|
| 114 |
+
- Dealer name is usually at the top header or company name.
|
| 115 |
+
- Model name often appears near words like Model, Tractor, Variant.
|
| 116 |
+
- If handwriting is unclear, make your best reasonable interpretation of the characters — but preserve language.
|
| 117 |
|
| 118 |
Output ONLY valid JSON, no markdown.
|
| 119 |
"""
|