rairo commited on
Commit
555ec41
·
verified ·
1 Parent(s): 21ac85d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -1
main.py CHANGED
@@ -55,7 +55,23 @@ def check_daily_reset(user_ref):
55
  except Exception as e:
56
  print(f"Reset error: {str(e)}")
57
  return False
58
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  # ========================================
60
  # Authentication Endpoints
61
  # ========================================
 
55
  except Exception as e:
56
  print(f"Reset error: {str(e)}")
57
  return False
58
+
59
+ # Process receipt image
60
+ def process_receipt(model, image):
61
+ prompt = """Analyze this image and determine if it's a receipt. If it is a receipt, extract:
62
+ - Total amount (as float)
63
+ - List of items purchased (array of strings)
64
+ - Date of transaction (DD/MM/YYYY format)
65
+ - Receipt number (as string)
66
+ Return JSON format with keys: is_receipt (boolean), total, items, date, receipt_number.
67
+ If not a receipt, return {"is_receipt": false}"""
68
+
69
+ try:
70
+ response = model.generate_content([prompt, image])
71
+ return response.text
72
+ except Exception as e:
73
+ st.error(f"Gemini error: {str(e)}")
74
+ return "{}"
75
  # ========================================
76
  # Authentication Endpoints
77
  # ========================================