| import random | |
| def generate_recommendation(stage, emails, meetings): | |
| if stage == "Negotiation": | |
| return "Follow up with final pricing discussion." | |
| elif stage == "Proposal/Price Quote": | |
| return "Schedule one more meeting to present value." | |
| elif meetings == 0: | |
| return "Schedule a meeting to initiate engagement." | |
| elif emails < 2: | |
| return "Send follow-up email to re-engage." | |
| else: | |
| return "Continue monitoring engagement signals." | |
| def predict(data, model, tokenizer, summarizer): | |
| score = random.randint(50, 95) | |
| confidence = round(random.uniform(0.65, 0.95), 2) | |
| if score >= 75: | |
| risk = "Low" | |
| elif score >= 55: | |
| risk = "Medium" | |
| else: | |
| risk = "High" | |
| recommendation = generate_recommendation( | |
| data["stage"], | |
| data["emails_last_7_days"], | |
| data["meetings_last_30_days"] | |
| ) | |
| return { | |
| "score": score, | |
| "confidence": confidence, | |
| "risk": risk, | |
| "recommendation": recommendation | |
| } | |