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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -42,19 +42,25 @@ def get_content_score(text, top_intents):
42
  score += 0.2
43
  return min(score + 0.1, 1.0)
44
 
 
45
  def generate_reply(input_text, intent):
46
- prompt = (
47
- f"You are a telecom customer service agent. Based on the customer's message: '{input_text}'\n"
48
- f"The detected issue is: '{intent}'.\n"
49
- f"Generate a reply in 3 short sentences:\n"
50
- f"1. Start with a polite sentence showing understanding.\n"
51
- f"2. Offer a clear, actionable solution to the issue.\n"
52
- f"3. End with a short, friendly question offering further help.\n"
53
- f"Each sentence should be no more than 100 characters.\n"
54
- )
55
- result = text_generator(prompt)[0]['generated_text']
56
- cleaned = re.sub(r'(\. ){2,}', '. ', result)
57
- return cleaned.strip()
 
 
 
 
 
58
 
59
  # UI
60
  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
+ # 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")