Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
intent_closings = {
|
49 |
-
"top up balance": "Would you like to
|
50 |
-
"reactivate service": "Shall I help you
|
51 |
"report service outage": "Would you like me to file a service report for you?",
|
52 |
-
"change mobile plan": "
|
53 |
-
"ask for billing support": "
|
54 |
-
"cancel subscription": "
|
55 |
-
"check account status": "
|
56 |
"upgrade device": "Would you like me to show available upgrade options?"
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
return
|
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")
|