Spaces:
Sleeping
Sleeping
MohammedNasser
commited on
Commit
•
4fe5255
1
Parent(s):
fecc1c6
Update app.py
Browse files
app.py
CHANGED
@@ -143,7 +143,25 @@ body {
|
|
143 |
|
144 |
label {
|
145 |
font-size: 16px !important;
|
146 |
-
color:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
"""
|
@@ -183,7 +201,7 @@ def upload_pdf(pdf_file):
|
|
183 |
def chat(user_input):
|
184 |
global chain, chathistory
|
185 |
|
186 |
-
chathistory.append({"role": "
|
187 |
|
188 |
prompt = f"""
|
189 |
You are an expert Arabic-language assistant specialized in analyzing and responding to queries about Arabic PDF documents. Your responses should be precise, informative, and reflect the professional tone and structure expected in formal Arabic communication. Focus on extracting and presenting relevant information from the document clearly and systematically, while avoiding colloquial or informal language.
|
@@ -198,7 +216,7 @@ def chat(user_input):
|
|
198 |
response = chain({"question": prompt})
|
199 |
assistant_response = response["answer"]
|
200 |
|
201 |
-
chathistory.append({"role": "
|
202 |
# Generate a unique identifier for the audio file
|
203 |
audio_id = str(uuid.uuid4())
|
204 |
|
@@ -222,18 +240,18 @@ with gr.Blocks(css=custom_css) as demo:
|
|
222 |
submit_button_pdf = gr.Button("ارفع الملف", interactive=False)
|
223 |
with gr.Row():
|
224 |
with gr.Column(scale=3):
|
225 |
-
chatbot = gr.Chatbot(label="
|
226 |
|
227 |
with gr.Row():
|
228 |
-
chat_input = gr.Textbox(label="
|
229 |
#chat_output = gr.Textbox(label="الرد الآلي 🤖", rtl=True, visible=False)
|
230 |
with gr.Row():
|
231 |
audio_output = gr.Audio(label="🔊", visible=False)
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
|
238 |
def handle_file_upload(pdf):
|
239 |
output_label.value=''
|
|
|
143 |
|
144 |
label {
|
145 |
font-size: 16px !important;
|
146 |
+
color: darkgray !important;
|
147 |
+
}
|
148 |
+
.message.user {
|
149 |
+
background-color: #FFFFFF;
|
150 |
+
}
|
151 |
+
|
152 |
+
.message.bot {
|
153 |
+
background-color: #F7EED3;
|
154 |
+
}
|
155 |
+
|
156 |
+
.message::before {
|
157 |
+
content: '';
|
158 |
+
display: inline-block;
|
159 |
+
width: 24px;
|
160 |
+
height: 24px;
|
161 |
+
background-size: contain;
|
162 |
+
background-repeat: no-repeat;
|
163 |
+
margin-right: 10px;
|
164 |
+
vertical-align: middle;
|
165 |
}
|
166 |
|
167 |
"""
|
|
|
201 |
def chat(user_input):
|
202 |
global chain, chathistory
|
203 |
|
204 |
+
chathistory.append({"role": "👤", "content": user_input})
|
205 |
|
206 |
prompt = f"""
|
207 |
You are an expert Arabic-language assistant specialized in analyzing and responding to queries about Arabic PDF documents. Your responses should be precise, informative, and reflect the professional tone and structure expected in formal Arabic communication. Focus on extracting and presenting relevant information from the document clearly and systematically, while avoiding colloquial or informal language.
|
|
|
216 |
response = chain({"question": prompt})
|
217 |
assistant_response = response["answer"]
|
218 |
|
219 |
+
chathistory.append({"role": "🤖", "content": assistant_response})
|
220 |
# Generate a unique identifier for the audio file
|
221 |
audio_id = str(uuid.uuid4())
|
222 |
|
|
|
240 |
submit_button_pdf = gr.Button("ارفع الملف", interactive=False)
|
241 |
with gr.Row():
|
242 |
with gr.Column(scale=3):
|
243 |
+
chatbot = gr.Chatbot(label="الشات", elem_id="chatbox", height=400, rtl=True, layout='bubble', bubble_full_width=False)
|
244 |
|
245 |
with gr.Row():
|
246 |
+
chat_input = gr.Textbox(label="💬", rtl=True, visible=False, placeholder="أدخل سؤالك هنا ..", elem_id="inputbox", lines=2)
|
247 |
#chat_output = gr.Textbox(label="الرد الآلي 🤖", rtl=True, visible=False)
|
248 |
with gr.Row():
|
249 |
audio_output = gr.Audio(label="🔊", visible=False)
|
250 |
+
|
251 |
+
with gr.Row():
|
252 |
+
submit_button_chat = gr.Button("إرسال", interactive=True, visible=False)
|
253 |
+
with gr.Row():
|
254 |
+
clear_btn = gr.Button("مسح", interactive=True, visible=False)
|
255 |
|
256 |
def handle_file_upload(pdf):
|
257 |
output_label.value=''
|