Update app.py
Browse files
app.py
CHANGED
|
@@ -443,9 +443,15 @@ def get_recommendation_with_agent(user_id, merchant, category, amount):
|
|
| 443 |
return
|
| 444 |
|
| 445 |
|
| 446 |
-
# ✅ Extract values correctly
|
| 447 |
card_id = recommendation.get('recommended_card', 'Unknown')
|
| 448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
rewards_earned = float(recommendation.get('rewards_earned', 0))
|
| 450 |
rewards_rate = recommendation.get('rewards_rate', 'N/A')
|
| 451 |
confidence = float(recommendation.get('confidence', 0))
|
|
|
|
| 443 |
return
|
| 444 |
|
| 445 |
|
|
|
|
| 446 |
card_id = recommendation.get('recommended_card', 'Unknown')
|
| 447 |
+
|
| 448 |
+
# ✅ CRITICAL FIX: Add 'c_' prefix if missing (backend returns without prefix)
|
| 449 |
+
if card_id != 'Unknown' and not card_id.startswith('c_'):
|
| 450 |
+
card_id = f'c_{card_id}'
|
| 451 |
+
print(f"✅ Normalized card_id to: {card_id}")
|
| 452 |
+
|
| 453 |
+
card_name = recommendation.get('card_name', card_id.replace('c_', '').replace('_', ' ').title())
|
| 454 |
+
|
| 455 |
rewards_earned = float(recommendation.get('rewards_earned', 0))
|
| 456 |
rewards_rate = recommendation.get('rewards_rate', 'N/A')
|
| 457 |
confidence = float(recommendation.get('confidence', 0))
|