Sulaiman8 commited on
Commit
79e1475
·
verified ·
1 Parent(s): 3b82c3f

Modify compare function

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -458,11 +458,10 @@ def compare_selected_cards(selected_names, card_lookup):
458
  if not selected_names or len(selected_names) < 2:
459
  return "<b style='color:red;'>Please select at least two cards to compare.</b>"
460
 
461
- comparison_data = "\n\n".join([
462
  f"{name}: {card_lookup.get(name)}" for name in selected_names
463
  ])
464
-
465
- prompt = (
466
  f"Do not include extra symbols like (* or #), just generate a textual response maybe with numbers for points."
467
  f"Compare the following credit cards based on their benefits. "
468
  f"Keep the output short, structured, and very readable:\n\n"
@@ -472,18 +471,18 @@ def compare_selected_cards(selected_names, card_lookup):
472
  f"Make it crisp and avoid lengthy explanations. "
473
  f"Conclude with a recommendation on which card suits which type of user."
474
  f"DO NOT INCLUDE ANY SYMBOLS LIKE # OR *"
475
- )
476
- print("comparing")
477
- try:
478
- response = model4.generate_content(prompt)
479
- return f"""
480
  <div style='background-color: #f9fbe7; padding: 15px; border-radius: 10px; font-family: sans-serif;'>
481
  <pre style='white-space: pre-wrap; font-size: 13px; color: #333;'>{response.text}</pre>
482
  </div>
483
  """
484
- except Exception as e:
485
- print("Comparison Error:", e)
486
- return "<b style='color:red;'>Something went wrong while comparing. Please try again.</b>"
487
 
488
  # Loading all 55 cards for comparison feature
489
  df_all_cards = pd.read_csv("credit_card_data_updated.csv")
 
458
  if not selected_names or len(selected_names) < 2:
459
  return "<b style='color:red;'>Please select at least two cards to compare.</b>"
460
 
461
+ comparison_data = "\n\n".join([
462
  f"{name}: {card_lookup.get(name)}" for name in selected_names
463
  ])
464
+ prompt = (
 
465
  f"Do not include extra symbols like (* or #), just generate a textual response maybe with numbers for points."
466
  f"Compare the following credit cards based on their benefits. "
467
  f"Keep the output short, structured, and very readable:\n\n"
 
471
  f"Make it crisp and avoid lengthy explanations. "
472
  f"Conclude with a recommendation on which card suits which type of user."
473
  f"DO NOT INCLUDE ANY SYMBOLS LIKE # OR *"
474
+ )
475
+ print("comparing")
476
+ try:
477
+ response = model4.generate_content(prompt)
478
+ return f"""
479
  <div style='background-color: #f9fbe7; padding: 15px; border-radius: 10px; font-family: sans-serif;'>
480
  <pre style='white-space: pre-wrap; font-size: 13px; color: #333;'>{response.text}</pre>
481
  </div>
482
  """
483
+ except Exception as e:
484
+ print("Comparison Error:", e)
485
+ return "<b style='color:red;'>Something went wrong while comparing. Please try again.</b>"
486
 
487
  # Loading all 55 cards for comparison feature
488
  df_all_cards = pd.read_csv("credit_card_data_updated.csv")