Update app.py
Browse files
app.py
CHANGED
@@ -413,6 +413,7 @@ with gr.Blocks(css="""
|
|
413 |
input_text_chat.submit(fn=stream_response, inputs=[input_text_chat, chatbot], outputs=[chatbot, input_text_chat])
|
414 |
|
415 |
# Formularz
|
|
|
416 |
with gr.TabItem("馃摑 Formularz"):
|
417 |
input_text_form = gr.Textbox(label="Zadaj pytanie:", placeholder="Napisz tutaj pytanie...", lines=2, interactive=True)
|
418 |
|
@@ -477,5 +478,81 @@ with gr.Blocks(css="""
|
|
477 |
inputs=session_dir,
|
478 |
outputs=download_files
|
479 |
)
|
480 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
gui.launch()
|
|
|
413 |
input_text_chat.submit(fn=stream_response, inputs=[input_text_chat, chatbot], outputs=[chatbot, input_text_chat])
|
414 |
|
415 |
# Formularz
|
416 |
+
'''
|
417 |
with gr.TabItem("馃摑 Formularz"):
|
418 |
input_text_form = gr.Textbox(label="Zadaj pytanie:", placeholder="Napisz tutaj pytanie...", lines=2, interactive=True)
|
419 |
|
|
|
478 |
inputs=session_dir,
|
479 |
outputs=download_files
|
480 |
)
|
481 |
+
'''
|
482 |
+
with gr.TabItem("馃摑 Formularz"):
|
483 |
+
input_text_form = gr.Textbox(label="Zadaj pytanie:", placeholder="Napisz tutaj pytanie...", lines=2, interactive=True)
|
484 |
+
|
485 |
+
with gr.Row():
|
486 |
+
with gr.Column(scale=1):
|
487 |
+
submit_button = gr.Button("Wy艣lij pytanie")
|
488 |
+
with gr.Column(scale=1):
|
489 |
+
clear_answer_button = gr.Button("Wyczy艣膰 formularz", elem_classes="button_wyczysc-color")
|
490 |
+
with gr.Column(scale=7):
|
491 |
+
gr.Markdown("")
|
492 |
+
|
493 |
+
with gr.Row():
|
494 |
+
with gr.Column(scale=1):
|
495 |
+
zacytuj_button = gr.Button("Przytocz 藕r贸d艂a")
|
496 |
+
with gr.Column(scale=8):
|
497 |
+
gr.Markdown("")
|
498 |
+
|
499 |
+
gr.Markdown("### Odpowied藕 (sformatowana):")
|
500 |
+
output_answer = gr.Markdown()
|
501 |
+
|
502 |
+
gr.Markdown("### Odpowied藕 (do skopiowania):")
|
503 |
+
output_answer_text = gr.Textbox(interactive=False, lines=5)
|
504 |
+
|
505 |
+
output_cytaty = gr.State("")
|
506 |
+
|
507 |
+
gr.Markdown("### 殴r贸d艂a:")
|
508 |
+
output_sources = gr.Markdown()
|
509 |
+
|
510 |
+
gr.Markdown("### Pobierz odpowiedzi:")
|
511 |
+
download_files = gr.File(label="Pliki do pobrania", interactive=False, file_types=[".docx"])
|
512 |
+
|
513 |
+
# Logika przycisk贸w
|
514 |
+
submit_button.click(
|
515 |
+
response,
|
516 |
+
inputs=[input_text_form, historia_formularza],
|
517 |
+
outputs=[output_answer, output_sources, output_cytaty]
|
518 |
+
).then(
|
519 |
+
zaktualizuj_historie,
|
520 |
+
inputs=[input_text_form, output_answer_text, historia_formularza],
|
521 |
+
outputs=historia_formularza
|
522 |
+
).then(
|
523 |
+
zapisz_odpowiedz,
|
524 |
+
inputs=[output_answer_text, input_text_form, output_sources, session_dir],
|
525 |
+
outputs=None
|
526 |
+
).then(
|
527 |
+
lista_plikow,
|
528 |
+
inputs=session_dir,
|
529 |
+
outputs=download_files
|
530 |
+
)
|
531 |
+
|
532 |
+
clear_answer_button.click(
|
533 |
+
wyczysc_formularz,
|
534 |
+
inputs=[],
|
535 |
+
outputs=[output_answer, input_text_form, output_sources, historia_formularza, output_answer_text]
|
536 |
+
)
|
537 |
+
|
538 |
+
zacytuj_button.click(
|
539 |
+
dodaj_cytaty,
|
540 |
+
inputs=[output_answer_text, output_cytaty],
|
541 |
+
outputs=output_answer_text
|
542 |
+
).then(
|
543 |
+
zapisz_odpowiedz,
|
544 |
+
inputs=[output_answer_text, input_text_form, output_sources, session_dir],
|
545 |
+
outputs=None
|
546 |
+
).then(
|
547 |
+
lista_plikow,
|
548 |
+
inputs=session_dir,
|
549 |
+
outputs=download_files
|
550 |
+
)
|
551 |
+
|
552 |
+
# Automatyczne kopiowanie Markdown -> Textbox (po ka偶dej odpowiedzi)
|
553 |
+
output_answer.change(
|
554 |
+
lambda x: x,
|
555 |
+
inputs=output_answer,
|
556 |
+
outputs=output_answer_text
|
557 |
+
)
|
558 |
gui.launch()
|