TanujInsane commited on
Commit
7ff371f
·
1 Parent(s): c11cb65

fix: restore completely original constants.py and clean agent.py imports

Browse files
Files changed (2) hide show
  1. agent.py +4 -26
  2. constants.py +189 -3
agent.py CHANGED
@@ -2,7 +2,10 @@ import pickle
2
  import os
3
  import time
4
  from datetime import datetime
5
- from constants import CATEGORIES, CATEGORY_KWORDS
 
 
 
6
 
7
  # Moved constants to constants.py
8
 
@@ -158,31 +161,6 @@ Best regards,
158
  Operations Team""",
159
  }
160
 
161
- PRIORITY_RULES = {
162
- "urgent": ["urgent", "asap", "immediately", "critical", "emergency", "not working", "broken", "down", "error", "failed", "crashes", "crash"],
163
- "high": ["incorrect", "wrong", "missing", "cannot", "can't", "unable", "problem", "issue", "complaint"],
164
- "medium": ["review", "check", "update", "change", "request", "need", "want", "please"],
165
- "low": ["inquiry", "question", "info", "information", "general", "curious", "wondering"]
166
- }
167
-
168
- DEPARTMENT_MAP = {
169
- "General": {"team": "General Enquiries", "email": "hello@company.com", "sla": "48h"},
170
- "Billing": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
171
- "Technical": {"team": "Tech Support", "email": "techsupport@company.com", "sla": "4h"},
172
- "HR": {"team": "Human Resources", "email": "hr@company.com", "sla": "48h"},
173
- "Support": {"team": "Customer Support", "email": "support@company.com", "sla": "12h"},
174
- "Legal": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
175
- "Marketing": {"team": "Marketing", "email": "marketing@company.com", "sla": "48h"},
176
- "Operations": {"team": "Operations", "email": "ops@company.com", "sla": "24h"},
177
- }
178
-
179
- def get_reply_template(cat):
180
- if "-" in cat:
181
- parent = cat.split("-")[0]
182
- else:
183
- parent = cat
184
- return REPLY_TEMPLATES.get(cat, REPLY_TEMPLATES.get(parent, REPLY_TEMPLATES["General"]))
185
-
186
  class TicketAgent:
187
  def __init__(self, model_dir="."):
188
  self.models = {}
 
2
  import os
3
  import time
4
  from datetime import datetime
5
+ from constants import (
6
+ CATEGORIES, CATEGORY_KWORDS, PRIORITY_RULES,
7
+ DEPARTMENT_MAP, get_reply_template
8
+ )
9
 
10
  # Moved constants to constants.py
11
 
 
161
  Operations Team""",
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  class TicketAgent:
165
  def __init__(self, model_dir="."):
166
  self.models = {}
constants.py CHANGED
@@ -1,9 +1,36 @@
 
 
1
  CATEGORIES = {
2
- "easy": ["General","Billing","Support","Technical","HR"],
3
- "medium": ["General","Billing","Support","Technical","HR","Legal","Sales","Marketing","Operations","Complaints"],
4
- "hard": ["Cat_"+str(i) for i in range(22)]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
6
 
 
7
  CATEGORY_KWORDS = {
8
  "Technical": ["crash", "crashes", "bug", "error", "not working", "broken", "upload fail",
9
  "application", "software", "login fail", "404", "500", "exception",
@@ -17,3 +44,162 @@ CATEGORY_KWORDS = {
17
  "Marketing": ["ad", "campaign", "social media", "market", "promotion", "outreach"],
18
  "Finance": ["budget", "expense", "tax", "audit", "fiscal"],
19
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Category Definitions for all difficulties
3
  CATEGORIES = {
4
+ "easy": {
5
+ 0: "General",
6
+ 1: "Billing",
7
+ 2: "Support",
8
+ 3: "Technical",
9
+ 4: "HR"
10
+ },
11
+ "medium": {
12
+ 0: "General",
13
+ 1: "Billing",
14
+ 2: "Billing-Dispute",
15
+ 3: "Support",
16
+ 4: "Technical",
17
+ 5: "Technical-Bug",
18
+ 6: "HR-Payroll",
19
+ 7: "HR-Benefits",
20
+ 8: "Legal",
21
+ 9: "Executive"
22
+ },
23
+ "hard": {
24
+ 0: "General", 1: "Billing", 2: "Billing-Dispute", 3: "Billing-Refund",
25
+ 4: "Support-Urgent", 5: "Support-Normal", 6: "Technical", 7: "Technical-Bug",
26
+ 8: "Technical-Feature", 9: "HR-Payroll", 10: "HR-Benefits", 11: "HR-Complaint",
27
+ 12: "Legal", 13: "Legal-Contract", 14: "Legal-Compliance", 15: "Executive",
28
+ 16: "Executive-Strategic", 17: "Finance", 18: "Marketing", 19: "Operations",
29
+ 20: "Finance-Tax", 21: "Marketing-Social"
30
+ }
31
  }
32
 
33
+ # Keyword overrides for early classification
34
  CATEGORY_KWORDS = {
35
  "Technical": ["crash", "crashes", "bug", "error", "not working", "broken", "upload fail",
36
  "application", "software", "login fail", "404", "500", "exception",
 
44
  "Marketing": ["ad", "campaign", "social media", "market", "promotion", "outreach"],
45
  "Finance": ["budget", "expense", "tax", "audit", "fiscal"],
46
  }
47
+
48
+ # Priority detection rules
49
+ PRIORITY_RULES = {
50
+ "urgent": ["urgent", "asap", "immediately", "critical", "emergency", "not working",
51
+ "broken", "down", "error", "failed", "crashes", "crash"],
52
+ "high": ["incorrect", "wrong", "missing", "cannot", "can't", "unable",
53
+ "problem", "issue", "complaint"],
54
+ "medium": ["review", "check", "update", "change", "request", "need", "want", "please"],
55
+ "low": ["inquiry", "question", "info", "information", "general", "curious", "wondering"]
56
+ }
57
+
58
+ # Department routing and SLAs
59
+ DEPARTMENT_MAP = {
60
+ "General": {"team": "General Enquiries", "email": "hello@company.com", "sla": "48h"},
61
+ "Billing": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
62
+ "Billing-Dispute": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
63
+ "Billing-Refund": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
64
+ "Support": {"team": "Customer Support", "email": "support@company.com", "sla": "12h"},
65
+ "Support-Urgent": {"team": "Customer Support", "email": "support@company.com", "sla": "4h"},
66
+ "Support-Normal": {"team": "Customer Support", "email": "support@company.com", "sla": "12h"},
67
+ "Technical": {"team": "Tech Support", "email": "techsupport@company.com","sla": "4h"},
68
+ "Technical-Bug": {"team": "Tech Support", "email": "techsupport@company.com","sla": "4h"},
69
+ "Technical-Feature": {"team": "Engineering", "email": "dev@company.com", "sla": "72h"},
70
+ "HR": {"team": "Human Resources", "email": "hr@company.com", "sla": "48h"},
71
+ "HR-Payroll": {"team": "Payroll Team", "email": "hr@company.com", "sla": "48h"},
72
+ "HR-Benefits": {"team": "Benefits Admin", "email": "hr@company.com", "sla": "48h"},
73
+ "HR-Complaint": {"team": "Employee Relations", "email": "hr@company.com", "sla": "24h"},
74
+ "Legal": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
75
+ "Legal-Contract": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
76
+ "Legal-Compliance": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
77
+ "Executive": {"team": "Executive Office", "email": "exec@company.com", "sla": "48h"},
78
+ "Executive-Strategic": {"team": "Executive Office", "email": "exec@company.com", "sla": "48h"},
79
+ "Finance": {"team": "Finance", "email": "finance@company.com", "sla": "24h"},
80
+ "Finance-Tax": {"team": "Finance", "email": "finance@company.com", "sla": "48h"},
81
+ "Marketing": {"team": "Marketing", "email": "marketing@company.com", "sla": "48h"},
82
+ "Marketing-Social": {"team": "Marketing", "email": "marketing@company.com", "sla": "24h"},
83
+ "Operations": {"team": "Operations", "email": "ops@company.com", "sla": "24h"},
84
+ }
85
+
86
+ # Template mapping
87
+ REPLY_TEMPLATES = {
88
+ "General": """Dear Customer,
89
+
90
+ Thank you for your inquiry.
91
+
92
+ We have received your message and will respond within 48 hours.
93
+
94
+ Reference ID: {ref_id}
95
+ Priority: {priority}
96
+
97
+ Best regards,
98
+ General Enquiries Team""",
99
+
100
+ "Billing": """Dear Customer,
101
+
102
+ Thank you for contacting us regarding your billing inquiry.
103
+
104
+ We have received your request and our Billing & Finance team will review your account details within 24 hours.
105
+
106
+ What we'll do:
107
+ - Review your invoice/payment details
108
+ - Verify the transaction in question
109
+ - Send you a detailed resolution
110
+
111
+ Reference ID: {ref_id}
112
+ Priority: {priority}
113
+ Expected resolution: {sla}
114
+
115
+ If urgent, call: +1-800-BILLING
116
+
117
+ Best regards,
118
+ Billing & Finance Team""",
119
+
120
+ "Technical": """Dear Customer,
121
+
122
+ Thank you for reporting this technical issue.
123
+
124
+ Our Tech Support team has been notified and will respond within 4 hours.
125
+
126
+ Immediate steps you can try:
127
+ - Clear browser cache and retry
128
+ - Check our status page: status.company.com
129
+ - Restart the application
130
+
131
+ Reference ID: {ref_id}
132
+ Priority: {priority}
133
+ Expected resolution: {sla}
134
+
135
+ For critical issues: techsupport@company.com
136
+
137
+ Best regards,
138
+ Tech Support Team""",
139
+
140
+ "HR": """Dear Team Member,
141
+
142
+ Thank you for reaching out to Human Resources.
143
+
144
+ Your query has been received and will be handled with full confidentiality.
145
+
146
+ Our HR team will respond within 48 hours regarding:
147
+ - Policy clarifications
148
+ - Benefits & compensation
149
+ - Workplace concerns
150
+
151
+ Reference ID: {ref_id}
152
+ Priority: {priority}
153
+ Expected resolution: {sla}
154
+
155
+ Best regards,
156
+ Human Resources Team""",
157
+
158
+ "Support": """Dear Customer,
159
+
160
+ Thank you for contacting Customer Support.
161
+
162
+ We have logged your request and a support agent will be in touch within 12 hours.
163
+
164
+ Reference ID: {ref_id}
165
+ Priority: {priority}
166
+ Expected resolution: {sla}
167
+
168
+ Track your ticket: support.company.com/track/{ref_id}
169
+
170
+ Best regards,
171
+ Customer Support Team""",
172
+ }
173
+
174
+ # Hierarchy map - categories that are "close" get partial credit
175
+ CATEGORY_HIERARCHY = {
176
+ "Billing": ["Billing-Dispute", "Billing-Refund"],
177
+ "Billing-Dispute": ["Billing", "Billing-Refund"],
178
+ "Billing-Refund": ["Billing", "Billing-Dispute"],
179
+ "Support": ["Support-Urgent", "Support-Normal"],
180
+ "Support-Urgent": ["Support", "Support-Normal"],
181
+ "Support-Normal": ["Support", "Support-Urgent"],
182
+ "Technical": ["Technical-Bug", "Technical-Feature"],
183
+ "Technical-Bug": ["Technical", "Technical-Feature"],
184
+ "Technical-Feature": ["Technical", "Technical-Bug"],
185
+ "HR": ["HR-Payroll", "HR-Benefits", "HR-Complaint"],
186
+ "HR-Payroll": ["HR", "HR-Benefits"],
187
+ "HR-Benefits": ["HR", "HR-Payroll"],
188
+ "HR-Complaint": ["HR"],
189
+ "Legal": ["Legal-Contract", "Legal-Compliance"],
190
+ "Legal-Contract": ["Legal", "Legal-Compliance"],
191
+ "Legal-Compliance": ["Legal", "Legal-Contract"],
192
+ "Executive": ["Executive-Strategic"],
193
+ "Executive-Strategic": ["Executive"],
194
+ }
195
+
196
+ # Helper to find parent category
197
+ def get_parent_category(cat):
198
+ if "-" in cat:
199
+ return cat.split("-")[0]
200
+ return cat
201
+
202
+ # Helper to map any category to a template
203
+ def get_reply_template(cat):
204
+ parent = get_parent_category(cat)
205
+ return REPLY_TEMPLATES.get(cat, REPLY_TEMPLATES.get(parent, REPLY_TEMPLATES["General"]))