def generate_recommendation(stage, emails, meetings, risk): if risk == "High": if meetings == 0: return "Engagement is too low — schedule a call ASAP." elif emails < 2: return "Send a strong follow-up email to revive the deal." else: return "Evaluate lead quality and consider requalification." elif risk == "Medium": if stage == "Proposal/Price Quote": return "One more meeting may help close the deal." elif stage == "Negotiation": return "Follow up with urgency — include timeline in next steps." else: return "Monitor closely; engagement trend is average." else: return "Deal looks strong — continue with planned next steps and maintain momentum."