Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +27 -52
streamlit_app.py
CHANGED
|
@@ -29,75 +29,49 @@ incident_description = st.text_area("Enter Email Body:")
|
|
| 29 |
|
| 30 |
# حوادث شائعة
|
| 31 |
st.sidebar.title("Common Incidents")
|
| 32 |
-
common_incidents = ["Forgot Password", "Unable to access CRM", "Service Unavailable", "Data not syncing", "
|
| 33 |
|
| 34 |
for incident in common_incidents:
|
| 35 |
if st.sidebar.button(incident):
|
| 36 |
incident_description = incident
|
| 37 |
|
| 38 |
-
# ✅ تحسين الت
|
| 39 |
-
def
|
| 40 |
email_text = email_text.lower()
|
| 41 |
-
|
| 42 |
-
# تحديد ن
|
| 43 |
if re.search(r"(password|reset|forgot)", email_text):
|
| 44 |
-
|
| 45 |
elif re.search(r"(access|login|account|unable to login|cannot access)", email_text):
|
| 46 |
-
|
| 47 |
elif re.search(r"(quote|price|pricing|cost|sales)", email_text):
|
| 48 |
-
|
| 49 |
-
elif re.search(r"(payment|billing|invoice)", email_text):
|
| 50 |
-
incident_type = "Payment Issue"
|
| 51 |
-
else:
|
| 52 |
-
incident_type = "Uncategorized"
|
| 53 |
-
|
| 54 |
-
# تحديد المنطقة المتأثرة
|
| 55 |
-
if re.search(r"(login|sign in|authentication)", email_text):
|
| 56 |
-
affected_area = "Login"
|
| 57 |
-
elif re.search(r"(crm|dashboard|portal)", email_text):
|
| 58 |
-
affected_area = "CRM"
|
| 59 |
-
elif re.search(r"(payment|invoice|billing)", email_text):
|
| 60 |
-
affected_area = "Payment"
|
| 61 |
-
else:
|
| 62 |
-
affected_area = "General"
|
| 63 |
-
|
| 64 |
-
# تحديد مستوى الأهمية
|
| 65 |
-
if re.search(r"(urgent|immediately|critical|important)", email_text):
|
| 66 |
-
severity = "Critical"
|
| 67 |
-
elif re.search(r"(slow|delay|not working)", email_text):
|
| 68 |
-
severity = "Normal"
|
| 69 |
else:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
return incident_type, affected_area, severity
|
| 73 |
|
| 74 |
# ✅ توليد الحلول المؤقتة
|
| 75 |
def generate_temporary_solution(incident_type):
|
| 76 |
-
|
| 77 |
-
|
| 78 |
"To reset your password, please click on the 'Forgot Password' link on the login page. "
|
| 79 |
"If you still face issues, kindly share any error messages you encounter."
|
| 80 |
-
)
|
| 81 |
-
|
|
|
|
| 82 |
"If you are unable to access your account, try the following:\n"
|
| 83 |
"1. Ensure that you are using the correct username and password.\n"
|
| 84 |
"2. Clear your browser cache and try again.\n"
|
| 85 |
"3. If the issue persists, please provide the error message or screenshot for further assistance."
|
| 86 |
-
)
|
| 87 |
-
|
|
|
|
| 88 |
"Thank you for your interest. Our sales team will reach out to you shortly. "
|
| 89 |
"In the meantime, please specify the product or service you are inquiring about."
|
| 90 |
-
)
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
"If the issue persists, provide the transaction ID or screenshot of the error."
|
| 94 |
-
),
|
| 95 |
-
"Uncategorized": (
|
| 96 |
"Your request is not clear. Please provide more information so we can assist you effectively."
|
| 97 |
-
)
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
return solutions.get(incident_type, "Your request is not clear. Please provide more information.")
|
| 101 |
|
| 102 |
# ✅ توليد الرد النهائي
|
| 103 |
def generate_response(subject, body, incident_type):
|
|
@@ -120,8 +94,8 @@ def generate_response(subject, body, incident_type):
|
|
| 120 |
if st.button("Submit"):
|
| 121 |
if subject and incident_description:
|
| 122 |
with st.spinner("Processing..."):
|
| 123 |
-
# تصنيف الحادث
|
| 124 |
-
incident_type
|
| 125 |
|
| 126 |
# توليد الردود والحلول
|
| 127 |
acknowledgement, solution, response = generate_response(subject, incident_description, incident_type)
|
|
@@ -150,9 +124,10 @@ if st.button("Submit"):
|
|
| 150 |
|
| 151 |
# ✅ تعبئة الحقول في CRM
|
| 152 |
st.subheader("🛠️ CRM Fields")
|
| 153 |
-
st.write("**
|
| 154 |
-
st.write("**
|
| 155 |
-
st.write("**
|
|
|
|
| 156 |
st.write("**Submitted On:**", datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
| 157 |
st.write("**Incident Description:**", incident_description)
|
| 158 |
st.write("**Solution:**", solution)
|
|
|
|
| 29 |
|
| 30 |
# حوادث شائعة
|
| 31 |
st.sidebar.title("Common Incidents")
|
| 32 |
+
common_incidents = ["Forgot Password", "Unable to access CRM", "Service Unavailable", "Data not syncing", "User unable to login"]
|
| 33 |
|
| 34 |
for incident in common_incidents:
|
| 35 |
if st.sidebar.button(incident):
|
| 36 |
incident_description = incident
|
| 37 |
|
| 38 |
+
# ✅ تحسين التصنيف مع المزيد من الكلمات المفتاحية
|
| 39 |
+
def categorize_email(email_text):
|
| 40 |
email_text = email_text.lower()
|
| 41 |
+
|
| 42 |
+
# تحديد الحالات بناءً على كلمات مفتاحية
|
| 43 |
if re.search(r"(password|reset|forgot)", email_text):
|
| 44 |
+
return "Forgot Password"
|
| 45 |
elif re.search(r"(access|login|account|unable to login|cannot access)", email_text):
|
| 46 |
+
return "Support Request"
|
| 47 |
elif re.search(r"(quote|price|pricing|cost|sales)", email_text):
|
| 48 |
+
return "Sales Inquiry"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
else:
|
| 50 |
+
return "Uncategorized"
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# ✅ توليد الحلول المؤقتة
|
| 53 |
def generate_temporary_solution(incident_type):
|
| 54 |
+
if incident_type == "Forgot Password":
|
| 55 |
+
return (
|
| 56 |
"To reset your password, please click on the 'Forgot Password' link on the login page. "
|
| 57 |
"If you still face issues, kindly share any error messages you encounter."
|
| 58 |
+
)
|
| 59 |
+
elif incident_type == "Support Request":
|
| 60 |
+
return (
|
| 61 |
"If you are unable to access your account, try the following:\n"
|
| 62 |
"1. Ensure that you are using the correct username and password.\n"
|
| 63 |
"2. Clear your browser cache and try again.\n"
|
| 64 |
"3. If the issue persists, please provide the error message or screenshot for further assistance."
|
| 65 |
+
)
|
| 66 |
+
elif incident_type == "Sales Inquiry":
|
| 67 |
+
return (
|
| 68 |
"Thank you for your interest. Our sales team will reach out to you shortly. "
|
| 69 |
"In the meantime, please specify the product or service you are inquiring about."
|
| 70 |
+
)
|
| 71 |
+
else:
|
| 72 |
+
return (
|
|
|
|
|
|
|
|
|
|
| 73 |
"Your request is not clear. Please provide more information so we can assist you effectively."
|
| 74 |
+
)
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
# ✅ توليد الرد النهائي
|
| 77 |
def generate_response(subject, body, incident_type):
|
|
|
|
| 94 |
if st.button("Submit"):
|
| 95 |
if subject and incident_description:
|
| 96 |
with st.spinner("Processing..."):
|
| 97 |
+
# تصنيف الحادث
|
| 98 |
+
incident_type = categorize_email(incident_description)
|
| 99 |
|
| 100 |
# توليد الردود والحلول
|
| 101 |
acknowledgement, solution, response = generate_response(subject, incident_description, incident_type)
|
|
|
|
| 124 |
|
| 125 |
# ✅ تعبئة الحقول في CRM
|
| 126 |
st.subheader("🛠️ CRM Fields")
|
| 127 |
+
st.write("**Title:**", incident_type)
|
| 128 |
+
st.write("**Affect Service:**", "CRM" if "crm" in incident_description.lower() else "General")
|
| 129 |
+
st.write("**Configuration:**", "Default Configuration")
|
| 130 |
+
st.write("**Incident Area:**", "Login" if "login" in incident_description.lower() else "General")
|
| 131 |
st.write("**Submitted On:**", datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
| 132 |
st.write("**Incident Description:**", incident_description)
|
| 133 |
st.write("**Solution:**", solution)
|