Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
from langdetect import detect
|
4 |
|
5 |
# Load Arabic NLP model for intent classification
|
6 |
intent_classifier = pipeline("text-classification", model="aubmindlab/bert-base-arabertv02")
|
7 |
|
|
|
|
|
|
|
8 |
# Omdurman National Bank-specific guidelines
|
9 |
ONB_GUIDELINES = {
|
10 |
"balance": "يمكنك التحقق من رصيدك عبر الإنترنت أو عبر تطبيق الهاتف الخاص ببنك أم درمان الوطني.",
|
@@ -32,10 +34,10 @@ INTENT_TO_RESPONSE = {
|
|
32 |
}
|
33 |
|
34 |
def detect_language(text):
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
def classify_intent(message: str):
|
41 |
# Use NLP model to classify the user's intent
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
# Load Arabic NLP model for intent classification
|
5 |
intent_classifier = pipeline("text-classification", model="aubmindlab/bert-base-arabertv02")
|
6 |
|
7 |
+
# Load language detection model
|
8 |
+
language_detector = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection")
|
9 |
+
|
10 |
# Omdurman National Bank-specific guidelines
|
11 |
ONB_GUIDELINES = {
|
12 |
"balance": "يمكنك التحقق من رصيدك عبر الإنترنت أو عبر تطبيق الهاتف الخاص ببنك أم درمان الوطني.",
|
|
|
34 |
}
|
35 |
|
36 |
def detect_language(text):
|
37 |
+
# Use Hugging Face language detection model
|
38 |
+
result = language_detector(text)
|
39 |
+
language = result[0]['label']
|
40 |
+
return language
|
41 |
|
42 |
def classify_intent(message: str):
|
43 |
# Use NLP model to classify the user's intent
|