DHEIVER commited on
Commit
28f8836
·
verified ·
1 Parent(s): 1013dbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -65
app.py CHANGED
@@ -129,6 +129,11 @@ def demo():
129
  background-color: #f9fafb;
130
  }
131
 
 
 
 
 
 
132
  /* Header styles */
133
  .header {
134
  text-align: center;
@@ -178,95 +183,95 @@ def demo():
178
  /* Buttons */
179
  .primary-button {
180
  background: linear-gradient(90deg, #3b82f6, #2563eb);
181
- color: white;
182
- border: none;
183
- padding: 10px 20px;
184
- border-radius: 8px;
185
- font-weight: 500;
186
  cursor: pointer;
187
  transition: all 0.2s ease;
188
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
189
  }
190
 
191
  .primary-button:hover {
192
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
193
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
194
  transform: translateY(-1px);
195
  }
196
 
197
  /* Status indicators */
198
  .status {
199
- padding: 8px 12px;
200
- border-radius: 6px;
201
- font-size: 0.9rem;
202
- font-weight: 500;
203
  }
204
 
205
  .status-success {
206
- background-color: #d1fae5;
207
- color: #065f46;
208
  }
209
 
210
  .status-waiting {
211
- background-color: #fef3c7;
212
- color: #92400e;
213
  }
214
 
215
  .status-error {
216
- background-color: #fee2e2;
217
- color: #b91c1c;
218
  }
219
 
220
  /* Chat container */
221
  .chat-container {
222
- border-radius: 10px;
223
- border: 1px solid #e5e7eb;
224
- overflow: hidden;
225
  }
226
 
227
  /* Document upload area */
228
  .upload-area {
229
- border: 2px dashed #d1d5db;
230
- border-radius: 8px;
231
- padding: 20px;
232
- text-align: center;
233
- background-color: #f9fafb;
234
  transition: all 0.2s ease;
235
  }
236
 
237
  .upload-area:hover {
238
- border-color: #3b82f6;
239
- background-color: #eff6ff;
240
  }
241
 
242
  /* Parameter sliders */
243
  .parameter-slider {
244
- margin-bottom: 15px;
245
  }
246
 
247
  /* Reference boxes */
248
  .reference-box {
249
- background-color: #f3f4f6;
250
- border-left: 4px solid #3b82f6;
251
- padding: 10px 15px;
252
- margin-bottom: 10px;
253
- border-radius: 4px;
254
  }
255
 
256
  .reference-box-title {
257
- font-weight: 600;
258
- color: #1e40af;
259
- margin-bottom: 5px;
260
- display: flex;
261
- justify-content: space-between;
262
  }
263
 
264
  .page-number {
265
- background-color: #dbeafe;
266
- color: #1e40af;
267
- padding: 2px 8px;
268
- border-radius: 12px;
269
- font-size: 0.8rem;
270
  }
271
 
272
  /* Responsive adjustments */
@@ -341,13 +346,13 @@ def demo():
341
  with gr.Row():
342
  # Left column - Setup
343
  with gr.Column(scale=1):
344
- with gr.Box(elem_classes="card"):
345
  gr.HTML(upload_html)
346
  document = gr.Files(height=200, file_count="multiple", file_types=["pdf"], interactive=True)
347
  db_btn = gr.Button("Create Vector Database", elem_classes="primary-button")
348
  db_progress = gr.Textbox(value="Not initialized", show_label=False, elem_classes="status status-waiting")
349
 
350
- with gr.Box(elem_classes="card"):
351
  gr.HTML(model_html)
352
  llm_btn = gr.Radio(list_llm_simple, label="", value=list_llm_simple[0], type="index")
353
 
@@ -359,7 +364,7 @@ def demo():
359
  qachain_btn = gr.Button("Initialize Chatbot", elem_classes="primary-button")
360
  llm_progress = gr.Textbox(value="Not initialized", show_label=False, elem_classes="status status-waiting")
361
 
362
- with gr.Box(elem_classes="card"):
363
  gr.Markdown("### Usage Instructions")
364
  gr.Markdown("""
365
  1. Upload one or more PDF documents
@@ -373,7 +378,7 @@ def demo():
373
 
374
  # Right column - Chat
375
  with gr.Column(scale=1.5):
376
- with gr.Box(elem_classes="card"):
377
  gr.HTML(chat_html)
378
  language_selector = gr.Radio(["English", "Português"], label="Response Language", value="English")
379
 
@@ -388,26 +393,26 @@ def demo():
388
  with gr.Row():
389
  clear_btn = gr.Button("Clear Chat", scale=1)
390
 
391
- with gr.Box(elem_classes="card"):
392
  gr.HTML(reference_html)
393
  with gr.Accordion("Document References", open=True):
394
- with gr.Box(elem_classes="reference-box"):
395
- with gr.Row():
396
- gr.Markdown("**Reference 1**", elem_classes="reference-box-title")
397
- source1_page = gr.Number(label="Page", show_label=False, elem_classes="page-number")
398
- doc_source1 = gr.Textbox(show_label=False, lines=2)
399
-
400
- with gr.Box(elem_classes="reference-box"):
401
- with gr.Row():
402
- gr.Markdown("**Reference 2**", elem_classes="reference-box-title")
403
- source2_page = gr.Number(label="Page", show_label=False, elem_classes="page-number")
404
- doc_source2 = gr.Textbox(show_label=False, lines=2)
405
-
406
- with gr.Box(elem_classes="reference-box"):
407
- with gr.Row():
408
- gr.Markdown("**Reference 3**", elem_classes="reference-box-title")
409
- source3_page = gr.Number(label="Page", show_label=False, elem_classes="page-number")
410
- doc_source3 = gr.Textbox(show_label=False, lines=2)
411
 
412
  # Preprocessing events
413
  db_btn.click(initialize_database, inputs=[document], outputs=[vector_db, db_progress])
 
129
  background-color: #f9fafb;
130
  }
131
 
132
+ .container {
133
+ max-width: 1200px;
134
+ margin: 0 auto;
135
+ }
136
+
137
  /* Header styles */
138
  .header {
139
  text-align: center;
 
183
  /* Buttons */
184
  .primary-button {
185
  background: linear-gradient(90deg, #3b82f6, #2563eb);
186
+ color: white !important;
187
+ border: none !important;
188
+ padding: 10px 20px !important;
189
+ border-radius: 8px !important;
190
+ font-weight: 500 !important;
191
  cursor: pointer;
192
  transition: all 0.2s ease;
193
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
194
  }
195
 
196
  .primary-button:hover {
197
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
198
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
199
  transform: translateY(-1px);
200
  }
201
 
202
  /* Status indicators */
203
  .status {
204
+ padding: 8px 12px !important;
205
+ border-radius: 6px !important;
206
+ font-size: 0.9rem !important;
207
+ font-weight: 500 !important;
208
  }
209
 
210
  .status-success {
211
+ background-color: #d1fae5 !important;
212
+ color: #065f46 !important;
213
  }
214
 
215
  .status-waiting {
216
+ background-color: #fef3c7 !important;
217
+ color: #92400e !important;
218
  }
219
 
220
  .status-error {
221
+ background-color: #fee2e2 !important;
222
+ color: #b91c1c !important;
223
  }
224
 
225
  /* Chat container */
226
  .chat-container {
227
+ border-radius: 10px !important;
228
+ border: 1px solid #e5e7eb !important;
229
+ overflow: hidden !important;
230
  }
231
 
232
  /* Document upload area */
233
  .upload-area {
234
+ border: 2px dashed #d1d5db !important;
235
+ border-radius: 8px !important;
236
+ padding: 20px !important;
237
+ text-align: center !important;
238
+ background-color: #f9fafb !important;
239
  transition: all 0.2s ease;
240
  }
241
 
242
  .upload-area:hover {
243
+ border-color: #3b82f6 !important;
244
+ background-color: #eff6ff !important;
245
  }
246
 
247
  /* Parameter sliders */
248
  .parameter-slider {
249
+ margin-bottom: 15px !important;
250
  }
251
 
252
  /* Reference boxes */
253
  .reference-box {
254
+ background-color: #f3f4f6 !important;
255
+ border-left: 4px solid #3b82f6 !important;
256
+ padding: 10px 15px !important;
257
+ margin-bottom: 10px !important;
258
+ border-radius: 4px !important;
259
  }
260
 
261
  .reference-box-title {
262
+ font-weight: 600 !important;
263
+ color: #1e40af !important;
264
+ margin-bottom: 5px !important;
265
+ display: flex !important;
266
+ justify-content: space-between !important;
267
  }
268
 
269
  .page-number {
270
+ background-color: #dbeafe !important;
271
+ color: #1e40af !important;
272
+ padding: 2px 8px !important;
273
+ border-radius: 12px !important;
274
+ font-size: 0.8rem !important;
275
  }
276
 
277
  /* Responsive adjustments */
 
346
  with gr.Row():
347
  # Left column - Setup
348
  with gr.Column(scale=1):
349
+ with gr.Group(elem_classes="card"):
350
  gr.HTML(upload_html)
351
  document = gr.Files(height=200, file_count="multiple", file_types=["pdf"], interactive=True)
352
  db_btn = gr.Button("Create Vector Database", elem_classes="primary-button")
353
  db_progress = gr.Textbox(value="Not initialized", show_label=False, elem_classes="status status-waiting")
354
 
355
+ with gr.Group(elem_classes="card"):
356
  gr.HTML(model_html)
357
  llm_btn = gr.Radio(list_llm_simple, label="", value=list_llm_simple[0], type="index")
358
 
 
364
  qachain_btn = gr.Button("Initialize Chatbot", elem_classes="primary-button")
365
  llm_progress = gr.Textbox(value="Not initialized", show_label=False, elem_classes="status status-waiting")
366
 
367
+ with gr.Group(elem_classes="card"):
368
  gr.Markdown("### Usage Instructions")
369
  gr.Markdown("""
370
  1. Upload one or more PDF documents
 
378
 
379
  # Right column - Chat
380
  with gr.Column(scale=1.5):
381
+ with gr.Group(elem_classes="card"):
382
  gr.HTML(chat_html)
383
  language_selector = gr.Radio(["English", "Português"], label="Response Language", value="English")
384
 
 
393
  with gr.Row():
394
  clear_btn = gr.Button("Clear Chat", scale=1)
395
 
396
+ with gr.Group(elem_classes="card"):
397
  gr.HTML(reference_html)
398
  with gr.Accordion("Document References", open=True):
399
+ # Reference 1
400
+ gr.Markdown("**Reference 1**", elem_classes="reference-box-title")
401
+ with gr.Row():
402
+ doc_source1 = gr.Textbox(show_label=False, lines=2, elem_classes="reference-box")
403
+ source1_page = gr.Number(label="Page", show_label=True, elem_classes="page-number")
404
+
405
+ # Reference 2
406
+ gr.Markdown("**Reference 2**", elem_classes="reference-box-title")
407
+ with gr.Row():
408
+ doc_source2 = gr.Textbox(show_label=False, lines=2, elem_classes="reference-box")
409
+ source2_page = gr.Number(label="Page", show_label=True, elem_classes="page-number")
410
+
411
+ # Reference 3
412
+ gr.Markdown("**Reference 3**", elem_classes="reference-box-title")
413
+ with gr.Row():
414
+ doc_source3 = gr.Textbox(show_label=False, lines=2, elem_classes="reference-box")
415
+ source3_page = gr.Number(label="Page", show_label=True, elem_classes="page-number")
416
 
417
  # Preprocessing events
418
  db_btn.click(initialize_database, inputs=[document], outputs=[vector_db, db_progress])