Update app.py
Browse files
app.py
CHANGED
@@ -397,6 +397,14 @@ with gr.Blocks(css="""
|
|
397 |
background-color: #A9A9A9 !important;
|
398 |
color: white !important;
|
399 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
""") as gui:
|
401 |
|
402 |
session_dir = gr.State(value=init_user_session)
|
@@ -404,74 +412,82 @@ with gr.Blocks(css="""
|
|
404 |
|
405 |
gr.Markdown("# Asystent Finansowy")
|
406 |
gr.Markdown("### Odpowiadam na pytania z zakresu ETF-贸w notowanych na GPW.")
|
407 |
-
gr.Markdown("###### Pami臋taj jestem tylko chatbotem i czasami si臋 myl臋, a moje odpowiedzi nie mog膮 by膰 traktowane jako rekomendacje inwestycyjne!")
|
408 |
-
|
409 |
-
with gr.
|
410 |
-
|
411 |
-
|
412 |
-
with gr.
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
background-color: #A9A9A9 !important;
|
398 |
color: white !important;
|
399 |
}
|
400 |
+
|
401 |
+
#markdown_odpowiedz {
|
402 |
+
border: 1px solid #ccc;
|
403 |
+
border-radius: 6px;
|
404 |
+
padding: 12px;
|
405 |
+
background-color: #f9f9f9;
|
406 |
+
margin-top: 6px;
|
407 |
+
}
|
408 |
""") as gui:
|
409 |
|
410 |
session_dir = gr.State(value=init_user_session)
|
|
|
412 |
|
413 |
gr.Markdown("# Asystent Finansowy")
|
414 |
gr.Markdown("### Odpowiadam na pytania z zakresu ETF-贸w notowanych na GPW.")
|
415 |
+
gr.Markdown("###### Pami臋taj: jestem tylko chatbotem i czasami si臋 myl臋, a moje odpowiedzi nie mog膮 by膰 traktowane jako rekomendacje inwestycyjne!")
|
416 |
+
|
417 |
+
with gr.Tabs():
|
418 |
+
|
419 |
+
# ChatBot
|
420 |
+
with gr.TabItem("馃挰 Chat"):
|
421 |
+
chatbot = gr.Chatbot()
|
422 |
+
input_text_chat = gr.Textbox(placeholder="Napisz tutaj pytanie...", container=False, autoscroll=True, scale=7)
|
423 |
+
input_text_chat.submit(fn=stream_response, inputs=[input_text_chat, chatbot], outputs=[chatbot, input_text_chat])
|
424 |
+
|
425 |
+
# Formularz
|
426 |
+
with gr.TabItem("馃摑 Formularz"):
|
427 |
+
input_text_form = gr.Textbox(label="Zadaj pytanie:", placeholder="Napisz tutaj pytanie...", lines=2, interactive=True)
|
428 |
+
|
429 |
+
with gr.Row():
|
430 |
+
with gr.Column(scale=1):
|
431 |
+
submit_button = gr.Button("Wy艣lij pytanie")
|
432 |
+
with gr.Column(scale=1):
|
433 |
+
clear_answer_button = gr.Button("Wyczy艣膰 formularz", elem_classes="button_wyczysc-color")
|
434 |
+
with gr.Column(scale=7):
|
435 |
+
gr.Markdown("")
|
436 |
+
|
437 |
+
gr.Markdown("### Odpowied藕:")
|
438 |
+
output_answer = gr.Markdown(elem_id="markdown_odpowiedz")
|
439 |
+
|
440 |
+
output_cytaty = gr.State("")
|
441 |
+
|
442 |
+
with gr.Row():
|
443 |
+
with gr.Column(scale=1):
|
444 |
+
zacytuj_button = gr.Button("Przytocz 藕r贸d艂a")
|
445 |
+
with gr.Column(scale=8):
|
446 |
+
gr.Markdown("")
|
447 |
+
|
448 |
+
gr.Markdown("### 殴r贸d艂a:")
|
449 |
+
output_sources = gr.Markdown()
|
450 |
+
|
451 |
+
gr.Markdown("### Pobierz odpowiedzi:")
|
452 |
+
download_files = gr.File(label="Pliki do pobrania", interactive=False, file_types=[".docx"])
|
453 |
+
|
454 |
+
# Logika przycisk贸w
|
455 |
+
submit_button.click(
|
456 |
+
response,
|
457 |
+
inputs=[input_text_form, historia_formularza],
|
458 |
+
outputs=[output_answer, output_sources, output_cytaty]
|
459 |
+
).then(
|
460 |
+
zaktualizuj_historie,
|
461 |
+
inputs=[input_text_form, output_answer, historia_formularza],
|
462 |
+
outputs=historia_formularza
|
463 |
+
).then(
|
464 |
+
zapisz_odpowiedz,
|
465 |
+
inputs=[output_answer, input_text_form, output_sources, session_dir],
|
466 |
+
outputs=None
|
467 |
+
).then(
|
468 |
+
lista_plikow,
|
469 |
+
inputs=session_dir,
|
470 |
+
outputs=download_files
|
471 |
+
)
|
472 |
+
|
473 |
+
clear_answer_button.click(
|
474 |
+
wyczysc_formularz,
|
475 |
+
inputs=[],
|
476 |
+
outputs=[output_answer, input_text_form, output_sources, historia_formularza]
|
477 |
+
)
|
478 |
+
|
479 |
+
zacytuj_button.click(
|
480 |
+
dodaj_cytaty,
|
481 |
+
inputs=[output_answer, output_cytaty],
|
482 |
+
outputs=output_answer
|
483 |
+
).then(
|
484 |
+
zapisz_odpowiedz,
|
485 |
+
inputs=[output_answer, input_text_form, output_sources, session_dir],
|
486 |
+
outputs=None
|
487 |
+
).then(
|
488 |
+
lista_plikow,
|
489 |
+
inputs=session_dir,
|
490 |
+
outputs=download_files
|
491 |
+
)
|
492 |
+
|
493 |
+
gui.launch()
|