JoshuaZywoo commited on
Commit
2889bc1
·
verified ·
1 Parent(s): e3db4d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -13
app.py CHANGED
@@ -42,25 +42,36 @@ def get_content_score(text, top_intents):
42
  score += 0.2
43
  return min(score + 0.1, 1.0)
44
 
45
- # Updated reply generator with intent-specific follow-up
46
  def generate_reply(input_text, intent):
47
- # Defined intent-specific closing prompts
 
 
 
 
 
 
 
 
 
 
 
 
48
  intent_closings = {
49
- "top up balance": "Would you like to see recharge options and prices?",
50
- "reactivate service": "Shall I help you reactivate your number now?",
51
  "report service outage": "Would you like me to file a service report for you?",
52
- "change mobile plan": "Need me to compare available plans for you?",
53
- "ask for billing support": "Would you like me to check your latest bill details?",
54
- "cancel subscription": "Should I guide you through the cancellation process?",
55
- "check account status": "Would you like an overview of your account status?",
56
  "upgrade device": "Would you like me to show available upgrade options?"
57
  }
58
 
59
- closing = intent_closings.get(intent.lower(), "Is there anything else I can help you with?")
60
- opening = "Thanks for reaching out. I understand your concern."
61
- action = f"Here's how we can assist with '{intent.lower()}'."
62
- reply = f"{opening} {action} {closing}"
63
- return reply
64
 
65
  # UI
66
  st.set_page_config(page_title="Customer Support Assistant", layout="centered")
 
42
  score += 0.2
43
  return min(score + 0.1, 1.0)
44
 
 
45
  def generate_reply(input_text, intent):
46
+ # Intent-specific suggestion sentences
47
+ intent_solutions = {
48
+ "top up balance": "Your balance is ¥12. Current promo: recharge ¥100 get ¥5 bonus.",
49
+ "reactivate service": "Your service is suspended due to unpaid ¥38. Recharge to restore within 30 mins.",
50
+ "change mobile plan": "You're on Plan Basic (¥68/5GB). Suggest Plan Plus (¥98/20GB).",
51
+ "check account status": "Your data usage is 3.2GB/5GB. Balance: ¥12. Calls left: 22 mins.",
52
+ "ask for billing support": "Last bill was ¥96 for March. Includes data overage ¥16.",
53
+ "cancel subscription": "Your contract ends on 2025-06-30. No penalty after this date.",
54
+ "upgrade device": "You're eligible for upgrade. New iPhone plan starts at ¥399/month.",
55
+ "report service outage": "We're detecting signal issues in your area (ZIP: XXX). Engineers notified."
56
+ }
57
+
58
+ # Intent-specific closing question
59
  intent_closings = {
60
+ "top up balance": "Would you like to proceed with a recharge now?",
61
+ "reactivate service": "Shall I help you restart your service now?",
62
  "report service outage": "Would you like me to file a service report for you?",
63
+ "change mobile plan": "Would you like to switch to a better plan?",
64
+ "ask for billing support": "Shall I show your last 3 billing records?",
65
+ "cancel subscription": "Shall I guide you through cancellation?",
66
+ "check account status": "Want a summary of your usage and balance?",
67
  "upgrade device": "Would you like me to show available upgrade options?"
68
  }
69
 
70
+ solution = intent_solutions.get(intent.lower(), "Here's how we can assist you with this issue.")
71
+ closing = intent_closings.get(intent.lower(), "Is there anything else I can help with?")
72
+ opening = "Thank you for contacting us. I understand your concern."
73
+
74
+ return f"{opening} {solution} {closing}"
75
 
76
  # UI
77
  st.set_page_config(page_title="Customer Support Assistant", layout="centered")