Spaces:
Runtime error
Runtime error
import gradio as gr | |
import logging # For analytics | |
# Omdurman National Bank-specific guidelines | |
ONB_GUIDELINES = { | |
"balance": "يمكنك التحقق من رصيدك عبر الإنترنت أو عبر تطبيق الهاتف الخاص ببنك أم درمان الوطني.", | |
"lost_card": "في حالة فقدان البطاقة، اتصل بالرقم 249-123-456-789 فورًا.", | |
"loan": "شروط القرض تشمل الحد الأدنى للدخل (5000 جنيه سوداني) وتاريخ ائتماني جيد.", | |
"transfer": "لتحويل الأموال، استخدم تطبيق الهاتف أو الخدمة المصرفية عبر الإنترنت.", | |
"new_account": "لفتح حساب جديد، قم بزيارة أقرب فرع مع جواز سفرك أو هويتك الوطنية.", | |
"interest_rates": "أسعار الفائدة على الودائع تتراوح بين 5% إلى 10% سنويًا.", | |
"branches": "فروعنا موجودة في أم درمان، الخرطوم، وبورتسودان. زيارة موقعنا للتفاصيل.", | |
"working_hours": "ساعات العمل من 8 صباحًا إلى 3 مساءً من الأحد إلى الخميس.", | |
"contact": "الاتصال بنا على الرقم 249-123-456-789 أو عبر البريد الإلكتروني [email protected]." | |
} | |
# Map Arabic menu options to English keys | |
OPTION_TO_KEY = { | |
"التحقق من الرصيد": "balance", | |
"الإبلاغ عن فقدان البطاقة": "lost_card", | |
"شروط الحصول على قرض": "loan", | |
"تحويل الأموال": "transfer", | |
"فتح حساب جديد": "new_account", | |
"أسعار الفائدة": "interest_rates", | |
"فروع البنك": "branches", | |
"ساعات العمل": "working_hours", | |
"الاتصال بالبنك": "contact" | |
} | |
# Set up logging for analytics | |
logging.basicConfig(filename='chatbot_queries.log', level=logging.INFO) | |
def respond(option: str): | |
# Log the selected option | |
logging.info(f"Selected Option: {option}") | |
# Map the Arabic option to the English key | |
key = OPTION_TO_KEY.get(option) | |
# Return the corresponding response | |
if key: | |
return ONB_GUIDELINES.get(key, "عذرًا، لم يتم التعرف على الخيار المحدد.") | |
else: | |
return "عذرًا، لم يتم التعرف على الخيار المحدد." | |
# Arabic menu options | |
menu_options = list(OPTION_TO_KEY.keys()) | |
# Omdurman National Bank-specific interface | |
with gr.Blocks(css=".gradio-container {direction: rtl;}") as demo: | |
gr.Markdown("# <center>بنك أم درمان الوطني - المساعد المصرفي</center>") | |
with gr.Tab("المحادثة"): | |
gr.Markdown("## اختر أحد الخيارات التالية:") | |
# Create buttons for each menu option | |
with gr.Row(): | |
for option in menu_options: | |
gr.Button(option).click( | |
fn=respond, | |
inputs=gr.Textbox(value=option, visible=False), | |
outputs=gr.Textbox(label="الرد", interactive=False) | |
) | |
# Output textbox for responses | |
output = gr.Textbox(label="الرد", interactive=False) | |
with gr.Tab("الإرشادات المصرفية"): | |
gr.Markdown("## إرشادات بنك أم درمان الوطني") | |
for key, value in ONB_GUIDELINES.items(): | |
gr.Markdown(f"**{key.capitalize()}**: {value}") | |
if __name__ == "__main__": | |
demo.launch( | |
server_name="0.0.0.0", | |
server_port=7860, | |
share=True # Enable public link | |
) |