Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -175,16 +175,17 @@ p {
|
|
| 175 |
"""
|
| 176 |
# Gradio interface
|
| 177 |
with gr.Blocks(css=custom_css) as demo:
|
| 178 |
-
gr.Markdown("#
|
| 179 |
gr.Markdown("## المنعقد السبت 14 - سبتمبر 2024")
|
| 180 |
|
| 181 |
with gr.Row():
|
| 182 |
pdf_input = gr.File(label="اختر ملف PDF للدردشة")
|
| 183 |
process_button = gr.Button("رفع وبدء الدردشة")
|
| 184 |
|
|
|
|
| 185 |
chat_interface = gr.ChatInterface(
|
| 186 |
chat,
|
| 187 |
-
chatbot=gr.Chatbot(height=400),
|
| 188 |
textbox=gr.Textbox(placeholder="اكتب سؤالك هنا...", container=False),
|
| 189 |
title="الدردشة مع البوت",
|
| 190 |
description="اسأل أي سؤال عن محتوى الملف PDF",
|
|
@@ -196,9 +197,17 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 196 |
clear_btn="مسح المحادثة",
|
| 197 |
)
|
| 198 |
|
|
|
|
| 199 |
audio_output = gr.Audio(label="الرد الصوتي")
|
| 200 |
|
| 201 |
process_button.click(process_pdf, inputs=[pdf_input], outputs=[chat_interface.textbox])
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
demo.launch()
|
|
|
|
|
|
| 175 |
"""
|
| 176 |
# Gradio interface
|
| 177 |
with gr.Blocks(css=custom_css) as demo:
|
| 178 |
+
gr.Markdown("# ديمو-بوت للقاء مركز حضرموت للدراسات التاريخية")
|
| 179 |
gr.Markdown("## المنعقد السبت 14 - سبتمبر 2024")
|
| 180 |
|
| 181 |
with gr.Row():
|
| 182 |
pdf_input = gr.File(label="اختر ملف PDF للدردشة")
|
| 183 |
process_button = gr.Button("رفع وبدء الدردشة")
|
| 184 |
|
| 185 |
+
# Remove the `chatbot` definition inside ChatInterface
|
| 186 |
chat_interface = gr.ChatInterface(
|
| 187 |
chat,
|
| 188 |
+
# Removed: chatbot=gr.Chatbot(height=400),
|
| 189 |
textbox=gr.Textbox(placeholder="اكتب سؤالك هنا...", container=False),
|
| 190 |
title="الدردشة مع البوت",
|
| 191 |
description="اسأل أي سؤال عن محتوى الملف PDF",
|
|
|
|
| 197 |
clear_btn="مسح المحادثة",
|
| 198 |
)
|
| 199 |
|
| 200 |
+
# Remove the separate chatbot instance here
|
| 201 |
audio_output = gr.Audio(label="الرد الصوتي")
|
| 202 |
|
| 203 |
process_button.click(process_pdf, inputs=[pdf_input], outputs=[chat_interface.textbox])
|
| 204 |
+
|
| 205 |
+
# Update submit function to avoid double chatbot reference
|
| 206 |
+
chat_interface.submit(
|
| 207 |
+
fn=lambda x, y: y[-1][1],
|
| 208 |
+
inputs=[chat_interface.textbox, chat_interface.chatbot], # The chatbot inside the interface
|
| 209 |
+
outputs=[audio_output]
|
| 210 |
+
)
|
| 211 |
|
| 212 |
demo.launch()
|
| 213 |
+
|