Spaces:
Sleeping
Sleeping
MohammedNasser
commited on
Commit
•
73f55fa
1
Parent(s):
d54a402
Update app.py
Browse files
app.py
CHANGED
@@ -124,8 +124,8 @@ body {
|
|
124 |
}
|
125 |
|
126 |
.gradio-container {
|
127 |
-
direction: rtl;
|
128 |
-
font-family: 'Noto Kufi Arabic', sans-serif;
|
129 |
font-size: 16px; /* Adjust font size */
|
130 |
max-width: 800px !important;
|
131 |
margin: auto !important;
|
@@ -148,7 +148,7 @@ p {
|
|
148 |
}
|
149 |
|
150 |
.gradio-button {
|
151 |
-
background-color:
|
152 |
color: #FFFFFF !important;
|
153 |
}
|
154 |
|
@@ -254,24 +254,24 @@ with gr.Blocks(css=custom_css) as demo:
|
|
254 |
if is_valid:
|
255 |
# Enable the upload button if the file is valid
|
256 |
output_label.value=''
|
257 |
-
return output_label, gr.update(interactive=True)
|
258 |
else:
|
259 |
output_label.value=f'<span style="color:{color}">{message}</span>'
|
260 |
-
return output_label, gr.update(interactive=False)
|
261 |
|
262 |
def process_pdf_and_enable_components(pdf):
|
263 |
# Process PDF and activate the other components
|
264 |
output_label.value='<span style="color:blue">جاري معالجة الملف...</span>'
|
265 |
message, is_valid = upload_pdf(pdf)
|
266 |
output_label.value=f'<span style="color:green">{message}</span>'
|
267 |
-
return output_label, gr.update(interactive=True)
|
268 |
|
269 |
|
270 |
# When the user uploads a file, validate it and then allow PDF upload
|
271 |
-
pdf_input.change(handle_file_upload, inputs=pdf_input, outputs=[output_label,submit_button_pdf])
|
272 |
|
273 |
# When the user presses the upload button, process the PDF and enable other components
|
274 |
-
submit_button_pdf.click(process_pdf_and_enable_components, inputs=pdf_input, outputs=[output_label, submit_button_chat])
|
275 |
|
276 |
# Chat button connection
|
277 |
submit_button_chat.click(chat, inputs=chat_input, outputs=[chat_output, audio_output])
|
|
|
124 |
}
|
125 |
|
126 |
.gradio-container {
|
127 |
+
direction: rtl;
|
128 |
+
font-family: 'Noto Kufi Arabic', sans-serif;
|
129 |
font-size: 16px; /* Adjust font size */
|
130 |
max-width: 800px !important;
|
131 |
margin: auto !important;
|
|
|
148 |
}
|
149 |
|
150 |
.gradio-button {
|
151 |
+
background-color: blue !important;
|
152 |
color: #FFFFFF !important;
|
153 |
}
|
154 |
|
|
|
254 |
if is_valid:
|
255 |
# Enable the upload button if the file is valid
|
256 |
output_label.value=''
|
257 |
+
return output_label, gr.update(interactive=True), gr.update(interactive=False), gr.update(label=""), gr.update(label="")
|
258 |
else:
|
259 |
output_label.value=f'<span style="color:{color}">{message}</span>'
|
260 |
+
return output_label, gr.update(interactive=False), gr.update(interactive=False), gr.update(label=""), gr.update(label="")
|
261 |
|
262 |
def process_pdf_and_enable_components(pdf):
|
263 |
# Process PDF and activate the other components
|
264 |
output_label.value='<span style="color:blue">جاري معالجة الملف...</span>'
|
265 |
message, is_valid = upload_pdf(pdf)
|
266 |
output_label.value=f'<span style="color:green">{message}</span>'
|
267 |
+
return output_label, gr.update(interactive=True), gr.update(interactive=False)
|
268 |
|
269 |
|
270 |
# When the user uploads a file, validate it and then allow PDF upload
|
271 |
+
pdf_input.change(handle_file_upload, inputs=pdf_input, outputs=[output_label,submit_button_pdf, submit_button_chat, chat_output, chat_input])
|
272 |
|
273 |
# When the user presses the upload button, process the PDF and enable other components
|
274 |
+
submit_button_pdf.click(process_pdf_and_enable_components, inputs=pdf_input, outputs=[output_label, submit_button_chat, submit_button_pdf])
|
275 |
|
276 |
# Chat button connection
|
277 |
submit_button_chat.click(chat, inputs=chat_input, outputs=[chat_output, audio_output])
|