Spaces:
Sleeping
Sleeping
import gradio as gr | |
# Placeholder response function | |
def get_response(user_message): | |
return f"رد تلقائي: {user_message}" # Replace this with your AI model | |
with gr.Blocks(title="المتحدث الآلي للتشريعات المحلية لإمارة دبي") as demo: | |
gr.Markdown("# Dubai Legislation Chatbot\nاسأل أي سؤال حول تشريعات دبي - نسخة تجريبية (تصميم وتنفيذ م. أسامة الخطيب)", elem_id="title") | |
chatbot = gr.Chatbot(elem_id="chatbot") | |
msg = gr.Textbox(placeholder="اكتب سؤالك هنا...", rtl=True, elem_id="input-box") | |
clear = gr.Button("مسح", elem_id="clear-btn") | |
def user(user_message, history): | |
history.append([user_message, None]) | |
return "", history | |
def bot(history): | |
user_message = history[-1][0] | |
bot_message = get_response(user_message) | |
history[-1][1] = bot_message | |
return history | |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then( | |
bot, chatbot, chatbot | |
) | |
clear.click(lambda: [], None, chatbot, queue=False) | |
# Launch with custom RTL-friendly CSS | |
demo.launch(css=""" | |
#title { | |
text-align: center; | |
font-size: 24px; | |
color: darkblue; | |
direction: rtl; | |
} | |
#chatbot { | |
background-color: #f9f9f9; | |
border-radius: 10px; | |
padding: 10px; | |
direction: rtl; | |
text-align: right; | |
font-family: 'Tajawal', sans-serif; | |
} | |
#input-box { | |
border: 2px solid blue; | |
padding: 10px; | |
direction: rtl; | |
text-align: right; | |
} | |
#clear-btn { | |
background-color: red; | |
color: white; | |
font-weight: bold; | |
} | |
""") | |