waleedmohd commited on
Commit
cbe4b29
·
verified ·
1 Parent(s): edd8287

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -47,22 +47,25 @@ def respond(message: str, history: list):
47
 
48
  # Check for "Back to Menu" keyword
49
  if "القائمة" in message or "menu" in message.lower():
50
- return "main_menu"
51
 
52
  # Classify the user's intent using NLP
53
  intent = classify_intent(message)
54
 
55
  # If intent is recognized, return the corresponding response
56
  if intent != "unknown":
57
- return ONB_GUIDELINES.get(intent, "عذرًا، لم يتم التعرف على الخيار المحدد.")
 
58
 
59
  # Fallback to keyword matching if NLP doesn't recognize the intent
60
  for keyword, key in INTENT_TO_RESPONSE.items():
61
  if keyword in message:
62
- return ONB_GUIDELINES.get(key, "عذرًا، لم يتم التعرف على الخيار المحدد.")
 
63
 
64
  # Default response if no intent or keyword is matched
65
- return "عذرًا، لم أفهم سؤالك. الرجاء إعادة الصياغة أو كتابة 'القائمة' للعودة إلى القائمة الرئيسية."
 
66
 
67
  # Main menu with submenus
68
  main_menu = {
 
47
 
48
  # Check for "Back to Menu" keyword
49
  if "القائمة" in message or "menu" in message.lower():
50
+ return "main_menu", history + [[message, "تم العودة إلى القائمة الرئيسية."]]
51
 
52
  # Classify the user's intent using NLP
53
  intent = classify_intent(message)
54
 
55
  # If intent is recognized, return the corresponding response
56
  if intent != "unknown":
57
+ response = ONB_GUIDELINES.get(intent, "عذرًا، لم يتم التعرف على الخيار المحدد.")
58
+ return response, history + [[message, response]]
59
 
60
  # Fallback to keyword matching if NLP doesn't recognize the intent
61
  for keyword, key in INTENT_TO_RESPONSE.items():
62
  if keyword in message:
63
+ response = ONB_GUIDELINES.get(key, "عذرًا، لم يتم التعرف على الخيار المحدد.")
64
+ return response, history + [[message, response]]
65
 
66
  # Default response if no intent or keyword is matched
67
+ response = "عذرًا، لم أفهم سؤالك. الرجاء إعادة الصياغة أو كتابة 'القائمة' للعودة إلى القائمة الرئيسية."
68
+ return response, history + [[message, response]]
69
 
70
  # Main menu with submenus
71
  main_menu = {