Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,26 +128,36 @@ Extract expense details from the OCR text below:
|
|
| 128 |
{full_text}
|
| 129 |
\"\"\"
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
### Labeling Rules:
|
| 132 |
1. Detect the business/merchant name from the text (e.g., KFC, Starbucks, Ying Thai Kitchen).
|
| 133 |
2. If items are food or restaurant-related β label must be: "<Business Name> Restaurant".
|
| 134 |
3. If it's a store/retail β "<Business Name> Store".
|
| 135 |
4. If unclear, infer the closest meaningful category.
|
|
|
|
| 136 |
|
| 137 |
### Notes Format:
|
| 138 |
Always generate notes EXACTLY in this format:
|
| 139 |
"Spent <total_amount> on <label> on <date>."
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
### Required Output:
|
| 142 |
Return structured JSON (via schema) with:
|
| 143 |
-
- total_amount
|
| 144 |
-
- label
|
| 145 |
-
- date
|
| 146 |
-
- time
|
| 147 |
-
- payment_type
|
| 148 |
-
- notes
|
| 149 |
-
|
| 150 |
-
Fill **every** field with the
|
| 151 |
"""
|
| 152 |
|
| 153 |
try:
|
|
|
|
| 128 |
{full_text}
|
| 129 |
\"\"\"
|
| 130 |
|
| 131 |
+
### STRICT INFORMATION RULES:
|
| 132 |
+
- Do NOT create or guess any information that does not exist in the extracted text.
|
| 133 |
+
- If any field (date, time, payment_type, total_amount) is not clearly present in the text, set its value to "unknown".
|
| 134 |
+
- Only infer the label category (Restaurant, Store, etc.) based on business name and item types.
|
| 135 |
+
|
| 136 |
### Labeling Rules:
|
| 137 |
1. Detect the business/merchant name from the text (e.g., KFC, Starbucks, Ying Thai Kitchen).
|
| 138 |
2. If items are food or restaurant-related β label must be: "<Business Name> Restaurant".
|
| 139 |
3. If it's a store/retail β "<Business Name> Store".
|
| 140 |
4. If unclear, infer the closest meaningful category.
|
| 141 |
+
5. If business name is not found β label = "unknown".
|
| 142 |
|
| 143 |
### Notes Format:
|
| 144 |
Always generate notes EXACTLY in this format:
|
| 145 |
"Spent <total_amount> on <label> on <date>."
|
| 146 |
|
| 147 |
+
- If <total_amount> is unknown β use "unknown"
|
| 148 |
+
- If <label> is unknown β use "unknown"
|
| 149 |
+
- If <date> is unknown β use "unknown"
|
| 150 |
+
|
| 151 |
### Required Output:
|
| 152 |
Return structured JSON (via schema) with:
|
| 153 |
+
- total_amount (if missing β "unknown")
|
| 154 |
+
- label (if missing β "unknown")
|
| 155 |
+
- date (if missing β "unknown")
|
| 156 |
+
- time (if missing β "unknown")
|
| 157 |
+
- payment_type (if missing β "unknown")
|
| 158 |
+
- notes (follow the provided format)
|
| 159 |
+
|
| 160 |
+
Fill **every** field ONLY with information found in the extracted text or "unknown".
|
| 161 |
"""
|
| 162 |
|
| 163 |
try:
|