Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
import spacy
|
3 |
-
|
4 |
-
# Load the spaCy Arabic model
|
5 |
-
nlp = spacy.load("xx_ent_wiki_sm")
|
6 |
|
7 |
# Omdurman National Bank-specific guidelines
|
8 |
ONB_GUIDELINES = {
|
@@ -17,41 +13,27 @@ ONB_GUIDELINES = {
|
|
17 |
"contact": "الاتصال بنا على الرقم 249-123-456-789 أو عبر البريد الإلكتروني [email protected]."
|
18 |
}
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
return "transfer"
|
33 |
-
elif "حساب" in doc.text:
|
34 |
-
return "new_account"
|
35 |
-
elif "فائدة" in doc.text:
|
36 |
-
return "interest_rates"
|
37 |
-
elif "فرع" in doc.text:
|
38 |
-
return "branches"
|
39 |
-
elif "ساعات" in doc.text:
|
40 |
-
return "working_hours"
|
41 |
-
elif "اتصال" in doc.text:
|
42 |
-
return "contact"
|
43 |
-
else:
|
44 |
-
return None
|
45 |
|
46 |
def respond(message: str):
|
47 |
-
#
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
return ONB_GUIDELINES.get(intent, "عذرًا، لم يتم التعرف على الخيار المحدد.")
|
52 |
|
53 |
-
# Default response if no
|
54 |
-
return "عذرًا، لم أفهم سؤالك. الرجاء إعادة الصياغة أو اختيار أحد الخيارات التالية: " + ", ".join(
|
55 |
|
56 |
# Chat interface
|
57 |
with gr.Blocks(css=".gradio-container {direction: rtl;}") as demo:
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
# Omdurman National Bank-specific guidelines
|
4 |
ONB_GUIDELINES = {
|
|
|
13 |
"contact": "الاتصال بنا على الرقم 249-123-456-789 أو عبر البريد الإلكتروني [email protected]."
|
14 |
}
|
15 |
|
16 |
+
# Map keywords to responses
|
17 |
+
KEYWORD_TO_RESPONSE = {
|
18 |
+
"رصيد": "balance",
|
19 |
+
"بطاقة": "lost_card",
|
20 |
+
"قرض": "loan",
|
21 |
+
"تحويل": "transfer",
|
22 |
+
"حساب": "new_account",
|
23 |
+
"فائدة": "interest_rates",
|
24 |
+
"فرع": "branches",
|
25 |
+
"ساعات": "working_hours",
|
26 |
+
"اتصال": "contact"
|
27 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def respond(message: str):
|
30 |
+
# Check for keywords in the message
|
31 |
+
for keyword, key in KEYWORD_TO_RESPONSE.items():
|
32 |
+
if keyword in message:
|
33 |
+
return ONB_GUIDELINES.get(key, "عذرًا، لم يتم التعرف على الخيار المحدد.")
|
|
|
34 |
|
35 |
+
# Default response if no keyword is matched
|
36 |
+
return "عذرًا، لم أفهم سؤالك. الرجاء إعادة الصياغة أو اختيار أحد الخيارات التالية: " + ", ".join(KEYWORD_TO_RESPONSE.keys())
|
37 |
|
38 |
# Chat interface
|
39 |
with gr.Blocks(css=".gradio-container {direction: rtl;}") as demo:
|