Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,6 +93,7 @@ def create_chain(vectorstore):
|
|
| 93 |
|
| 94 |
|
| 95 |
custom_css = """
|
|
|
|
| 96 |
body {
|
| 97 |
font-family: 'Noto Kufi Arabic', sans-serif;
|
| 98 |
background: linear-gradient(135deg, #799351 0%, #A67B5B 100%);
|
|
@@ -102,9 +103,9 @@ body {
|
|
| 102 |
}
|
| 103 |
|
| 104 |
.gradio-container {
|
| 105 |
-
direction: rtl;
|
| 106 |
-
font-family: 'Noto Kufi Arabic', sans-serif;
|
| 107 |
-
font-size: 16px;
|
| 108 |
max-width: 800px !important;
|
| 109 |
margin: auto !important;
|
| 110 |
background: rgba(255, 255, 255, 0.9);
|
|
@@ -115,41 +116,26 @@ body {
|
|
| 115 |
padding: 20px;
|
| 116 |
}
|
| 117 |
|
| 118 |
-
|
| 119 |
-
color: #1A4D2E;
|
| 120 |
-
font-weight: bold;
|
| 121 |
-
text-align: center;
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
p {
|
| 125 |
-
color: #A89F91;
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
.gradio-button {
|
| 129 |
background-color: blue !important;
|
| 130 |
color: #FFFFFF !important;
|
| 131 |
}
|
| 132 |
|
| 133 |
-
.
|
| 134 |
background-color: #FFFFFF !important;
|
| 135 |
color: #5F6F65 !important;
|
| 136 |
}
|
| 137 |
|
| 138 |
-
.gradio-chat-message {
|
| 139 |
-
border-radius: 10px;
|
| 140 |
-
padding: 10px;
|
| 141 |
-
margin-bottom: 10px;
|
| 142 |
-
}
|
| 143 |
|
| 144 |
-
.
|
| 145 |
background-color: #E7F0DC;
|
| 146 |
}
|
| 147 |
|
| 148 |
-
.
|
| 149 |
background-color: #F7EED3;
|
| 150 |
}
|
| 151 |
|
| 152 |
-
.
|
| 153 |
content: '';
|
| 154 |
display: inline-block;
|
| 155 |
width: 24px;
|
|
@@ -160,20 +146,23 @@ p {
|
|
| 160 |
vertical-align: middle;
|
| 161 |
}
|
| 162 |
|
| 163 |
-
.
|
| 164 |
content: '👤';
|
| 165 |
}
|
| 166 |
|
| 167 |
-
.
|
| 168 |
content: '🤖';
|
| 169 |
}
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
}
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
| 176 |
}
|
|
|
|
| 177 |
"""
|
| 178 |
# Function to check if the file is a valid PDF in Arabic and less than 10MB
|
| 179 |
def validate_pdf(pdf):
|
|
@@ -240,8 +229,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 |
|
|
@@ -254,7 +243,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 254 |
if is_valid:
|
| 255 |
# Enable the upload button if the file is valid
|
| 256 |
value=''
|
| 257 |
-
return gr.update(value=value), gr.update(interactive=True), gr.update(interactive=False), gr.update(label=""), gr.update(label="")
|
| 258 |
else:
|
| 259 |
value=f'<span style="color:{color}">{message}</span>'
|
| 260 |
return gr.update(value=value), gr.update(interactive=False), gr.update(interactive=False), gr.update(label=""), gr.update(label="")
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
custom_css = """
|
| 96 |
+
@import url('https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@400;700&display=swap');
|
| 97 |
body {
|
| 98 |
font-family: 'Noto Kufi Arabic', sans-serif;
|
| 99 |
background: linear-gradient(135deg, #799351 0%, #A67B5B 100%);
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
.gradio-container {
|
| 106 |
+
direction: rtl;
|
| 107 |
+
font-family: 'Noto Kufi Arabic', sans-serif;
|
| 108 |
+
font-size: 16px;
|
| 109 |
max-width: 800px !important;
|
| 110 |
margin: auto !important;
|
| 111 |
background: rgba(255, 255, 255, 0.9);
|
|
|
|
| 116 |
padding: 20px;
|
| 117 |
}
|
| 118 |
|
| 119 |
+
.gr-button {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
background-color: blue !important;
|
| 121 |
color: #FFFFFF !important;
|
| 122 |
}
|
| 123 |
|
| 124 |
+
.gr-button:hover {
|
| 125 |
background-color: #FFFFFF !important;
|
| 126 |
color: #5F6F65 !important;
|
| 127 |
}
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
+
.message.user {
|
| 131 |
background-color: #E7F0DC;
|
| 132 |
}
|
| 133 |
|
| 134 |
+
.message.bot {
|
| 135 |
background-color: #F7EED3;
|
| 136 |
}
|
| 137 |
|
| 138 |
+
.message::before {
|
| 139 |
content: '';
|
| 140 |
display: inline-block;
|
| 141 |
width: 24px;
|
|
|
|
| 146 |
vertical-align: middle;
|
| 147 |
}
|
| 148 |
|
| 149 |
+
.message.user::before {
|
| 150 |
content: '👤';
|
| 151 |
}
|
| 152 |
|
| 153 |
+
.message.bot::before {
|
| 154 |
content: '🤖';
|
| 155 |
}
|
| 156 |
+
|
| 157 |
+
#pdf_input input, #submit_button_pdf, #chat_input, #chat_output, #audio_output {
|
| 158 |
+
text-align: right !important; /* RTL alignment */
|
| 159 |
}
|
| 160 |
+
|
| 161 |
+
label {
|
| 162 |
+
font-size: 16px !important;
|
| 163 |
+
color: blue !important;
|
| 164 |
}
|
| 165 |
+
|
| 166 |
"""
|
| 167 |
# Function to check if the file is a valid PDF in Arabic and less than 10MB
|
| 168 |
def validate_pdf(pdf):
|
|
|
|
| 229 |
pdf_input = gr.File(label="اختر ملف PDF")
|
| 230 |
output_label = gr.HTML(value='') # Replaced Textbox with HTML for label
|
| 231 |
submit_button_pdf = gr.Button("ارفع الملف", interactive=False)
|
| 232 |
+
chat_input = gr.Textbox(label="")
|
| 233 |
+
chat_output = gr.Textbox(label="")
|
| 234 |
audio_output = gr.Audio(label="استمع إلى الرد", interactive=False)
|
| 235 |
submit_button_chat = gr.Button("إرسال", interactive=False)
|
| 236 |
|
|
|
|
| 243 |
if is_valid:
|
| 244 |
# Enable the upload button if the file is valid
|
| 245 |
value=''
|
| 246 |
+
return gr.update(value=value), gr.update(interactive=True), gr.update(interactive=False), gr.update(label="أدخل سؤالك هنا"), gr.update(label="الرد الآلي")
|
| 247 |
else:
|
| 248 |
value=f'<span style="color:{color}">{message}</span>'
|
| 249 |
return gr.update(value=value), gr.update(interactive=False), gr.update(interactive=False), gr.update(label=""), gr.update(label="")
|