Update app.py
Browse files
app.py
CHANGED
|
@@ -1725,7 +1725,6 @@ with gr.Blocks(
|
|
| 1725 |
Most people pick wrong and lose <strong>$400+ per year</strong>.<br>
|
| 1726 |
Our AI agent makes the optimal choice in <strong>2 seconds</strong>.<br>
|
| 1727 |
Powered by OpenAI <strong>GPT-4 + Gemini + Modal</strong><br>
|
| 1728 |
-
Your AI-powered rewards optimization assistant
|
| 1729 |
</p>
|
| 1730 |
|
| 1731 |
<div class="impact-stats">
|
|
@@ -3134,6 +3133,62 @@ with gr.Blocks(
|
|
| 3134 |
receipt_output = gr.Markdown(value="📸 Upload a receipt to get started")
|
| 3135 |
receipt_chart = gr.Plot()
|
| 3136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3137 |
def analyze_receipt_with_vision(image_path, user_id):
|
| 3138 |
"""Extract transaction data from receipt using GPT-4 Vision"""
|
| 3139 |
|
|
|
|
| 1725 |
Most people pick wrong and lose <strong>$400+ per year</strong>.<br>
|
| 1726 |
Our AI agent makes the optimal choice in <strong>2 seconds</strong>.<br>
|
| 1727 |
Powered by OpenAI <strong>GPT-4 + Gemini + Modal</strong><br>
|
|
|
|
| 1728 |
</p>
|
| 1729 |
|
| 1730 |
<div class="impact-stats">
|
|
|
|
| 3133 |
receipt_output = gr.Markdown(value="📸 Upload a receipt to get started")
|
| 3134 |
receipt_chart = gr.Plot()
|
| 3135 |
|
| 3136 |
+
|
| 3137 |
+
def generate_card_alternatives(category, amount, primary_card):
|
| 3138 |
+
"""Generate alternative card recommendations based on category"""
|
| 3139 |
+
|
| 3140 |
+
# Define fallback alternatives by category
|
| 3141 |
+
category_alternatives = {
|
| 3142 |
+
"Wholesale Club": [
|
| 3143 |
+
{"card": "Citi Double Cash", "rewards": amount * 0.02, "rate": "2% cashback", "note": "Works everywhere"},
|
| 3144 |
+
{"card": "Chase Freedom Unlimited", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Good backup option"},
|
| 3145 |
+
{"card": "Capital One Quicksilver", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "No annual fee"}
|
| 3146 |
+
],
|
| 3147 |
+
"Grocery Store": [
|
| 3148 |
+
{"card": "Amex Gold", "rewards": amount * 0.04, "rate": "4x points", "note": "Best for U.S. supermarkets"},
|
| 3149 |
+
{"card": "Citi Custom Cash", "rewards": amount * 0.05, "rate": "5% cashback", "note": "Up to $500/month"},
|
| 3150 |
+
{"card": "Chase Freedom Flex", "rewards": amount * 0.05, "rate": "5% rotating", "note": "When groceries are bonus category"}
|
| 3151 |
+
],
|
| 3152 |
+
"Restaurant": [
|
| 3153 |
+
{"card": "Amex Gold", "rewards": amount * 0.04, "rate": "4x points", "note": "Worldwide dining"},
|
| 3154 |
+
{"card": "Chase Sapphire Reserve", "rewards": amount * 0.03, "rate": "3x points", "note": "Premium travel card"},
|
| 3155 |
+
{"card": "Capital One Savor", "rewards": amount * 0.04, "rate": "4% cashback", "note": "Dining specialist"}
|
| 3156 |
+
],
|
| 3157 |
+
"Gas Station": [
|
| 3158 |
+
{"card": "Costco Anywhere Visa", "rewards": amount * 0.04, "rate": "4% cashback", "note": "Best for gas"},
|
| 3159 |
+
{"card": "Citi Custom Cash", "rewards": amount * 0.05, "rate": "5% cashback", "note": "Up to $500/month"},
|
| 3160 |
+
{"card": "Chase Freedom Unlimited", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Baseline option"}
|
| 3161 |
+
],
|
| 3162 |
+
"Department Store": [
|
| 3163 |
+
{"card": "Target RedCard", "rewards": amount * 0.05, "rate": "5% off", "note": "At Target only"},
|
| 3164 |
+
{"card": "Citi Double Cash", "rewards": amount * 0.02, "rate": "2% cashback", "note": "Works everywhere"},
|
| 3165 |
+
{"card": "Chase Freedom Unlimited", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Good backup"}
|
| 3166 |
+
],
|
| 3167 |
+
"Fast Food": [
|
| 3168 |
+
{"card": "Amex Gold", "rewards": amount * 0.04, "rate": "4x points", "note": "Includes fast food"},
|
| 3169 |
+
{"card": "Citi Double Cash", "rewards": amount * 0.02, "rate": "2% cashback", "note": "Universal option"},
|
| 3170 |
+
{"card": "Chase Freedom Unlimited", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Flexible rewards"}
|
| 3171 |
+
],
|
| 3172 |
+
"Online Shopping": [
|
| 3173 |
+
{"card": "Chase Freedom Flex", "rewards": amount * 0.05, "rate": "5% rotating", "note": "When online shopping is bonus"},
|
| 3174 |
+
{"card": "Citi Double Cash", "rewards": amount * 0.02, "rate": "2% cashback", "note": "Works everywhere"},
|
| 3175 |
+
{"card": "Capital One Quicksilver", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Simple cashback"}
|
| 3176 |
+
]
|
| 3177 |
+
}
|
| 3178 |
+
|
| 3179 |
+
# Get alternatives for category or use default
|
| 3180 |
+
alternatives = category_alternatives.get(category, [
|
| 3181 |
+
{"card": "Citi Double Cash", "rewards": amount * 0.02, "rate": "2% cashback", "note": "Universal option"},
|
| 3182 |
+
{"card": "Chase Freedom Unlimited", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Flexible rewards"},
|
| 3183 |
+
{"card": "Capital One Quicksilver", "rewards": amount * 0.015, "rate": "1.5% cashback", "note": "Simple cashback"}
|
| 3184 |
+
])
|
| 3185 |
+
|
| 3186 |
+
# Filter out the primary card if it's in alternatives
|
| 3187 |
+
primary_lower = primary_card.lower()
|
| 3188 |
+
alternatives = [alt for alt in alternatives if primary_lower not in alt['card'].lower()]
|
| 3189 |
+
|
| 3190 |
+
return alternatives[:3] # Return top 3
|
| 3191 |
+
|
| 3192 |
def analyze_receipt_with_vision(image_path, user_id):
|
| 3193 |
"""Extract transaction data from receipt using GPT-4 Vision"""
|
| 3194 |
|