Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,11 +104,34 @@ async def generate(image_id: str):
|
|
| 104 |
}
|
| 105 |
|
| 106 |
prompt = f"""
|
|
|
|
|
|
|
| 107 |
Extract expense details from the OCR text below:
|
| 108 |
|
|
|
|
| 109 |
{full_text}
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
"""
|
| 113 |
|
| 114 |
try:
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
prompt = f"""
|
| 107 |
+
You are an expense extraction AI.
|
| 108 |
+
|
| 109 |
Extract expense details from the OCR text below:
|
| 110 |
|
| 111 |
+
\"\"\"
|
| 112 |
{full_text}
|
| 113 |
+
\"\"\"
|
| 114 |
+
|
| 115 |
+
### Labeling Rules:
|
| 116 |
+
1. Detect the business/merchant name from the text (e.g., KFC, Starbucks, Ying Thai Kitchen).
|
| 117 |
+
2. If items are food or restaurant-related → label must be: "<Business Name> Restaurant".
|
| 118 |
+
3. If it's a store/retail → "<Business Name> Store".
|
| 119 |
+
4. If unclear, infer the closest meaningful category.
|
| 120 |
+
|
| 121 |
+
### Notes Format:
|
| 122 |
+
Always generate notes EXACTLY in this format:
|
| 123 |
+
"Spent <total_amount> on <label> on <date>."
|
| 124 |
+
|
| 125 |
+
### Required Output:
|
| 126 |
+
Return structured JSON (via schema) with:
|
| 127 |
+
- total_amount
|
| 128 |
+
- label (following rules above)
|
| 129 |
+
- date
|
| 130 |
+
- time
|
| 131 |
+
- payment_type
|
| 132 |
+
- notes
|
| 133 |
+
|
| 134 |
+
Fill **every** field with the best possible inference.
|
| 135 |
"""
|
| 136 |
|
| 137 |
try:
|