Spaces:
Sleeping
Sleeping
MohammedNasser
commited on
Commit
•
a0b5949
1
Parent(s):
280d715
Update app.py
Browse files
app.py
CHANGED
@@ -240,8 +240,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
240 |
pdf_input = gr.File(label="اختر ملف PDF")
|
241 |
output_label = gr.HTML(value='') # Replaced Textbox with HTML for label
|
242 |
submit_button_pdf = gr.Button("ارفع الملف", interactive=False)
|
243 |
-
chat_input = gr.Textbox(label="أدخل سؤالك هنا"
|
244 |
-
chat_output = gr.Textbox(label="الرد الآلي"
|
245 |
audio_output = gr.Audio(label="استمع إلى الرد", interactive=False)
|
246 |
submit_button_chat = gr.Button("إرسال", interactive=False)
|
247 |
|
@@ -253,26 +253,21 @@ with gr.Blocks(css=custom_css) as demo:
|
|
253 |
|
254 |
if is_valid:
|
255 |
# Enable the upload button if the file is valid
|
256 |
-
submit_button_pdf.update(interactive=True)
|
257 |
output_label.value=''
|
258 |
else:
|
259 |
output_label.value=f'<span style="color:{color}">{message}</span>'
|
260 |
|
261 |
def process_pdf_and_enable_components(pdf):
|
262 |
# Process PDF and activate the other components
|
263 |
-
output_label.value='<span style="color:
|
264 |
message, is_valid = upload_pdf(pdf)
|
265 |
output_label.value=f'<span style="color:green">{message}</span>'
|
266 |
-
|
267 |
-
chat_input.update(interactive=True)
|
268 |
-
chat_output.update(interactive=True)
|
269 |
-
audio_output.update(interactive=True)
|
270 |
-
submit_button_chat.update(interactive=True)
|
271 |
# When the user uploads a file, validate it and then allow PDF upload
|
272 |
-
pdf_input.change(handle_file_upload, inputs=pdf_input, outputs=[output_label])
|
273 |
|
274 |
# When the user presses the upload button, process the PDF and enable other components
|
275 |
-
submit_button_pdf.click(process_pdf_and_enable_components, inputs=pdf_input, outputs=[output_label])
|
276 |
|
277 |
# Chat button connection
|
278 |
submit_button_chat.click(chat, inputs=chat_input, outputs=[chat_output, audio_output])
|
|
|
240 |
pdf_input = gr.File(label="اختر ملف PDF")
|
241 |
output_label = gr.HTML(value='') # Replaced Textbox with HTML for label
|
242 |
submit_button_pdf = gr.Button("ارفع الملف", interactive=False)
|
243 |
+
chat_input = gr.Textbox(label="أدخل سؤالك هنا")
|
244 |
+
chat_output = gr.Textbox(label="الرد الآلي")
|
245 |
audio_output = gr.Audio(label="استمع إلى الرد", interactive=False)
|
246 |
submit_button_chat = gr.Button("إرسال", interactive=False)
|
247 |
|
|
|
253 |
|
254 |
if is_valid:
|
255 |
# Enable the upload button if the file is valid
|
|
|
256 |
output_label.value=''
|
257 |
else:
|
258 |
output_label.value=f'<span style="color:{color}">{message}</span>'
|
259 |
|
260 |
def process_pdf_and_enable_components(pdf):
|
261 |
# Process PDF and activate the other components
|
262 |
+
output_label.value='<span style="color:blue">جاري معالجة الملف...</span>'
|
263 |
message, is_valid = upload_pdf(pdf)
|
264 |
output_label.value=f'<span style="color:green">{message}</span>'
|
265 |
+
|
|
|
|
|
|
|
|
|
266 |
# When the user uploads a file, validate it and then allow PDF upload
|
267 |
+
pdf_input.change(handle_file_upload, inputs=pdf_input, outputs=[output_label,submit_button_pdf])
|
268 |
|
269 |
# When the user presses the upload button, process the PDF and enable other components
|
270 |
+
submit_button_pdf.click(process_pdf_and_enable_components, inputs=pdf_input, outputs=[output_label, submit_button_chat])
|
271 |
|
272 |
# Chat button connection
|
273 |
submit_button_chat.click(chat, inputs=chat_input, outputs=[chat_output, audio_output])
|