import pandas as pd import google.generativeai as genai import os #function to compare cards def compare_selected_cards(selected_names, card_lookup): genai.configure(api_key=os.environ.get("api_key_4")) model4 = genai.GenerativeModel('gemini-2.0-flash') print(selected_names) if not selected_names or len(selected_names) < 2: return "Please select at least two cards to compare." comparison_data = "\n\n".join([ f"{name}: {card_lookup.get(name)}" for name in selected_names ]) prompt = ( f"Do not include extra symbols like (* or #), just generate a textual response maybe with numbers for points." f"Compare the following credit cards based on their benefits. " f"Keep the output short, structured, and very readable:\n\n" f"{comparison_data}\n\n" f"Use markdown format with clear section headers like 'Comparison' and 'Recommendation'. " f"Present key differences as bullet points without using '*' symbols — use '-' instead. " f"Make it crisp and avoid lengthy explanations. " f"Conclude with a recommendation on which card suits which type of user." f"DO NOT INCLUDE ANY SYMBOLS LIKE # OR *" ) print("comparing") try: response = model4.generate_content(prompt) return f"""
{response.text}