Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
gradio_version = gr.__version__
|
5 |
print(f"Using Gradio version: {gradio_version}")
|
6 |
|
7 |
-
# Placeholder response function
|
8 |
def get_response(user_message):
|
9 |
-
return f"رد تلقائي: {user_message}" # Replace
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
|
14 |
-
|
|
|
|
|
15 |
msg = gr.Textbox(placeholder="اكتب سؤالك هنا...", rtl=True, elem_id="input-box")
|
16 |
clear = gr.Button("مسح", elem_id="clear-btn")
|
17 |
-
|
18 |
def user(user_message, history):
|
19 |
history.append([user_message, None])
|
20 |
return "", history
|
21 |
|
22 |
def bot(history):
|
23 |
-
|
24 |
-
bot_message = get_response(user_message)
|
25 |
-
history[-1][1] = bot_message
|
26 |
return history
|
27 |
|
28 |
-
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
29 |
-
bot, chatbot, chatbot
|
30 |
-
)
|
31 |
-
|
32 |
clear.click(lambda: [], None, chatbot, queue=False)
|
33 |
|
34 |
-
|
35 |
-
# Launch the app
|
36 |
-
demo.launch(css=css_path, share=True)
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Print current Gradio version
|
4 |
gradio_version = gr.__version__
|
5 |
print(f"Using Gradio version: {gradio_version}")
|
6 |
|
|
|
7 |
def get_response(user_message):
|
8 |
+
return f"رد تلقائي: {user_message}" # Replace with your AI model
|
9 |
|
10 |
+
# Load CSS content from file (ensure 'custom.css' exists in your working directory)
|
11 |
+
css_path = "custom.css"
|
12 |
+
with open(css_path, "r", encoding="utf-8") as f:
|
13 |
+
custom_css = f.read()
|
14 |
|
15 |
+
with gr.Blocks(title="المتحدث الآلي للتشريعات المحلية لإمارة دبي", css=custom_css) as demo:
|
16 |
+
gr.Markdown("# Dubai Legislation Chatbot\nاسأل أي سؤال حول تشريعات دبي - نسخة تجريبية (تصميم وتنفيذ م. أسامة الخطيب)", elem_id="title")
|
17 |
+
chatbot = gr.Chatbot(elem_id="chatbot", type="messages")
|
18 |
msg = gr.Textbox(placeholder="اكتب سؤالك هنا...", rtl=True, elem_id="input-box")
|
19 |
clear = gr.Button("مسح", elem_id="clear-btn")
|
20 |
+
|
21 |
def user(user_message, history):
|
22 |
history.append([user_message, None])
|
23 |
return "", history
|
24 |
|
25 |
def bot(history):
|
26 |
+
history[-1][1] = get_response(history[-1][0])
|
|
|
|
|
27 |
return history
|
28 |
|
29 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)
|
|
|
|
|
|
|
30 |
clear.click(lambda: [], None, chatbot, queue=False)
|
31 |
|
32 |
+
demo.launch(share=True)
|
|
|
|