Trabis commited on
Commit
f2f172c
·
verified ·
1 Parent(s): 700b120

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -22
app.py CHANGED
@@ -391,7 +391,7 @@ body {
391
  font-family: var(--font-family-arabic) !important;
392
  font-size: 1.2rem !important;
393
  font-weight: 600 !important;
394
- color: var(--primary-color) !important;
395
  margin-bottom: 0.5rem !important;
396
  }
397
 
@@ -478,14 +478,11 @@ with gr.Blocks(css=custom_css) as iface:
478
  variant="primary"
479
  )
480
 
481
- # status_text = gr.Markdown("", elem_classes="rtl-text status-text")
482
-
483
  # def on_submit(question):
484
- # # Retourne trois valeurs : réponse, contexte et statut
485
- # result, context = process_question(question)
486
- # status = "تمت معالجة السؤال بنجاح" # "Question processed successfully"
487
- # return result, context, status
488
-
489
  # submit_btn.click(
490
  # fn=on_submit,
491
  # inputs=input_text,
@@ -493,27 +490,24 @@ with gr.Blocks(css=custom_css) as iface:
493
  # api_name="predict",
494
  # queue=True
495
  # )
496
-
497
- # if __name__ == "__main__":
498
- # iface.launch(
499
- # share=True,
500
- # server_name="0.0.0.0",
501
- # server_port=7860,
502
- # max_threads=3,
503
- # show_error=True
504
- # )
505
-
506
  def on_submit(question):
507
- response, context = process_question(question)
508
- return response, context
509
-
 
 
 
 
 
510
  submit_btn.click(
511
  fn=on_submit,
512
  inputs=input_text,
513
  outputs=[answer_box, context_box],
514
  api_name="predict",
515
  queue=True
516
- )
 
 
517
 
518
  if __name__ == "__main__":
519
  iface.launch(
 
391
  font-family: var(--font-family-arabic) !important;
392
  font-size: 1.2rem !important;
393
  font-weight: 600 !important;
394
+ color: #000000 !important; /* Couleur noire pour les étiquettes */
395
  margin-bottom: 0.5rem !important;
396
  }
397
 
 
478
  variant="primary"
479
  )
480
 
481
+
 
482
  # def on_submit(question):
483
+ # response, context = process_question(question)
484
+ # return response, context
485
+
 
 
486
  # submit_btn.click(
487
  # fn=on_submit,
488
  # inputs=input_text,
 
490
  # api_name="predict",
491
  # queue=True
492
  # )
 
 
 
 
 
 
 
 
 
 
493
  def on_submit(question):
494
+ response, context = "", ""
495
+ for chunk in process_question(question):
496
+ if isinstance(chunk, str):
497
+ response += chunk
498
+ else:
499
+ response += chunk.content
500
+ yield response, context # Renvoie progressivement la réponse
501
+
502
  submit_btn.click(
503
  fn=on_submit,
504
  inputs=input_text,
505
  outputs=[answer_box, context_box],
506
  api_name="predict",
507
  queue=True
508
+ )
509
+
510
+
511
 
512
  if __name__ == "__main__":
513
  iface.launch(