front UI change
Browse files- app.py +134 -111
- climateqa/engine/chains/retrieve_documents.py +17 -0
- style.css +76 -11
app.py
CHANGED
@@ -60,6 +60,7 @@ try:
|
|
60 |
except Exception as e:
|
61 |
pass
|
62 |
|
|
|
63 |
|
64 |
# Set up Gradio Theme
|
65 |
theme = gr.themes.Base(
|
@@ -322,7 +323,8 @@ async def find_papers(query,after, relevant_content_sources):
|
|
322 |
else:
|
323 |
continue
|
324 |
yield docs_html, network_html, summary
|
325 |
-
|
|
|
326 |
|
327 |
|
328 |
# --------------------------------------------------------------------
|
@@ -398,7 +400,7 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
398 |
with gr.Column(scale=2, variant="panel",elem_id = "right-panel"):
|
399 |
|
400 |
|
401 |
-
with gr.Tabs() as tabs:
|
402 |
with gr.TabItem("Examples",elem_id = "tab-examples",id = 0):
|
403 |
|
404 |
examples_hidden = gr.Textbox(visible = False)
|
@@ -424,130 +426,148 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
424 |
)
|
425 |
|
426 |
samples.append(group_examples)
|
427 |
-
|
428 |
-
|
429 |
-
with gr.Tab("Sources",elem_id = "tab-sources",id = 1) as tab_sources:
|
430 |
-
sources_textbox = gr.HTML(show_label=False, elem_id="sources-textbox")
|
431 |
-
docs_textbox = gr.State("")
|
432 |
-
|
433 |
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
|
441 |
-
|
442 |
-
|
443 |
|
444 |
-
figures_cards = gr.HTML(show_label=False, elem_id="sources-figures")
|
445 |
|
|
|
|
|
446 |
|
447 |
|
448 |
-
|
449 |
-
|
450 |
-
# Fenêtre simulée pour le Summary
|
451 |
-
with gr.Group(visible=False, elem_id="papers-summary-popup") as summary_popup:
|
452 |
-
papers_summary = gr.Markdown("### Summary Content", visible=True, elem_id="papers-summary")
|
453 |
|
454 |
-
btn_relevant_papers = gr.Button("Relevant papers")
|
455 |
-
# Fenêtre simulée pour les Relevant Papers
|
456 |
-
with gr.Group(visible=False, elem_id="papers-relevant-popup") as relevant_popup:
|
457 |
-
papers_html = gr.HTML(show_label=False, elem_id="sources-textbox")
|
458 |
-
docs_textbox = gr.State("")
|
459 |
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
btn_citations_network.click(lambda: Modal(visible=True), None, modal)
|
465 |
|
466 |
-
|
467 |
|
468 |
-
with gr.Tab("Recommended content", elem_id="tab-recommended_content",
|
469 |
-
|
470 |
-
current_graphs.change(lambda x : x, inputs=[current_graphs], outputs=[graphs_container])
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
with gr.Tab("Configuration") as tab_config:
|
476 |
-
gr.Markdown("Reminders: You can talk in any language, ClimateQ&A is multi-lingual!")
|
477 |
-
|
478 |
-
|
479 |
-
dropdown_sources = gr.CheckboxGroup(
|
480 |
-
["IPCC", "IPBES","IPOS"],
|
481 |
-
label="Select source",
|
482 |
-
value=["IPCC"],
|
483 |
-
interactive=True,
|
484 |
-
)
|
485 |
-
dropdown_external_sources = gr.CheckboxGroup(
|
486 |
-
["IPCC figures","OpenAlex", "OurWorldInData"],
|
487 |
-
label="Select database to search for relevant content",
|
488 |
-
value=["IPCC figures"],
|
489 |
-
interactive=True,
|
490 |
-
)
|
491 |
-
|
492 |
-
dropdown_reports = gr.Dropdown(
|
493 |
-
POSSIBLE_REPORTS,
|
494 |
-
label="Or select specific reports",
|
495 |
-
multiselect=True,
|
496 |
-
value=None,
|
497 |
-
interactive=True,
|
498 |
-
)
|
499 |
-
|
500 |
-
dropdown_audience = gr.Dropdown(
|
501 |
-
["Children","General public","Experts"],
|
502 |
-
label="Select audience",
|
503 |
-
value="Experts",
|
504 |
-
interactive=True,
|
505 |
-
)
|
506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
513 |
|
|
|
|
|
514 |
|
515 |
|
516 |
#---------------------------------------------------------------------------------------
|
517 |
# OTHER TABS
|
518 |
#---------------------------------------------------------------------------------------
|
519 |
|
520 |
-
with gr.Tab("Settings",elem_id = "tab-config",id = 2):
|
521 |
|
522 |
-
|
523 |
|
524 |
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
|
547 |
-
after = gr.Slider(minimum=1950,maximum=2023,step=1,value=1960,label="Publication date",show_label=True,interactive=True,elem_id="date-papers")
|
548 |
|
549 |
-
|
550 |
-
|
551 |
|
552 |
|
553 |
with gr.Tab("About",elem_classes = "max-height other-tabs"):
|
@@ -612,23 +632,24 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
612 |
papers_number = papers_html.count("<h2>")
|
613 |
sources_notif_label = f"Sources ({sources_number})"
|
614 |
figures_notif_label = f"Figures ({figures_number})"
|
615 |
-
graphs_notif_label = f"
|
616 |
papers_notif_label = f"Papers ({papers_number})"
|
|
|
617 |
|
618 |
-
return gr.update(label = sources_notif_label), gr.update(label = figures_notif_label), gr.update(label = graphs_notif_label), gr.update(label = papers_notif_label)
|
619 |
|
620 |
(textbox
|
621 |
.submit(start_chat, [textbox,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_textbox")
|
622 |
.then(chat, [textbox,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, dropdown_external_sources] ,[chatbot,sources_textbox,output_query,output_language, sources_raw, current_graphs],concurrency_limit = 8,api_name = "chat_textbox")
|
623 |
.then(finish_chat, None, [textbox],api_name = "finish_chat_textbox")
|
624 |
-
# .then(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures,
|
625 |
)
|
626 |
|
627 |
(examples_hidden
|
628 |
.change(start_chat, [examples_hidden,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_examples")
|
629 |
.then(chat, [examples_hidden,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, dropdown_external_sources] ,[chatbot,sources_textbox,output_query,output_language, sources_raw, current_graphs],concurrency_limit = 8,api_name = "chat_textbox")
|
630 |
.then(finish_chat, None, [textbox],api_name = "finish_chat_examples")
|
631 |
-
# .then(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures,
|
632 |
)
|
633 |
|
634 |
|
@@ -641,19 +662,21 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
641 |
|
642 |
sources_raw.change(process_figures, inputs=[sources_raw], outputs=[figures_cards, gallery_component])
|
643 |
|
644 |
-
|
645 |
-
sources_textbox.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures,
|
646 |
-
figures_cards.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures,
|
647 |
-
current_graphs.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures,
|
648 |
-
papers_html.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures,
|
649 |
|
|
|
650 |
dropdown_samples.change(change_sample_questions,dropdown_samples,samples)
|
651 |
|
|
|
652 |
textbox.submit(find_papers,[textbox,after, dropdown_external_sources], [papers_html,citations_network,papers_summary])
|
653 |
examples_hidden.change(find_papers,[examples_hidden,after,dropdown_external_sources], [papers_html,citations_network,papers_summary])
|
654 |
|
655 |
-
btn_summary.click(toggle_summary_visibility, outputs=summary_popup)
|
656 |
-
btn_relevant_papers.click(toggle_relevant_visibility, outputs=relevant_popup)
|
657 |
|
658 |
demo.queue()
|
659 |
|
|
|
60 |
except Exception as e:
|
61 |
pass
|
62 |
|
63 |
+
import requests
|
64 |
|
65 |
# Set up Gradio Theme
|
66 |
theme = gr.themes.Base(
|
|
|
323 |
else:
|
324 |
continue
|
325 |
yield docs_html, network_html, summary
|
326 |
+
else :
|
327 |
+
yield "","", ""
|
328 |
|
329 |
|
330 |
# --------------------------------------------------------------------
|
|
|
400 |
with gr.Column(scale=2, variant="panel",elem_id = "right-panel"):
|
401 |
|
402 |
|
403 |
+
with gr.Tabs(elem_id = "right_panel_tab") as tabs:
|
404 |
with gr.TabItem("Examples",elem_id = "tab-examples",id = 0):
|
405 |
|
406 |
examples_hidden = gr.Textbox(visible = False)
|
|
|
426 |
)
|
427 |
|
428 |
samples.append(group_examples)
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
|
430 |
+
with gr.Tab("Configuration", id = 10, ) as tab_config:
|
431 |
+
gr.Markdown("Reminders: You can talk in any language, ClimateQ&A is multi-lingual!")
|
432 |
+
|
433 |
+
with gr.Row():
|
434 |
+
dropdown_sources = gr.CheckboxGroup(
|
435 |
+
["IPCC", "IPBES","IPOS"],
|
436 |
+
label="Select source",
|
437 |
+
value=["IPCC"],
|
438 |
+
interactive=True,
|
439 |
+
)
|
440 |
+
dropdown_external_sources = gr.CheckboxGroup(
|
441 |
+
["IPCC figures","OpenAlex", "OurWorldInData"],
|
442 |
+
label="Select database to search for relevant content",
|
443 |
+
value=["IPCC figures"],
|
444 |
+
interactive=True,
|
445 |
+
)
|
446 |
+
|
447 |
+
dropdown_reports = gr.Dropdown(
|
448 |
+
POSSIBLE_REPORTS,
|
449 |
+
label="Or select specific reports",
|
450 |
+
multiselect=True,
|
451 |
+
value=None,
|
452 |
+
interactive=True,
|
453 |
+
)
|
454 |
+
|
455 |
+
dropdown_audience = gr.Dropdown(
|
456 |
+
["Children","General public","Experts"],
|
457 |
+
label="Select audience",
|
458 |
+
value="Experts",
|
459 |
+
interactive=True,
|
460 |
+
)
|
461 |
|
462 |
+
|
463 |
+
after = gr.Slider(minimum=1950,maximum=2023,step=1,value=1960,label="Publication date",show_label=True,interactive=True,elem_id="date-papers", visible=False)
|
464 |
|
|
|
465 |
|
466 |
+
output_query = gr.Textbox(label="Query used for retrieval",show_label = True,elem_id = "reformulated-query",lines = 2,interactive = False, visible= False)
|
467 |
+
output_language = gr.Textbox(label="Language",show_label = True,elem_id = "language",lines = 1,interactive = False, visible= False)
|
468 |
|
469 |
|
470 |
+
dropdown_external_sources.change(lambda x: gr.update(visible = True ) if "OpenAlex" in x else gr.update(visible=False) , inputs=[dropdown_external_sources], outputs=[after])
|
471 |
+
# dropdown_external_sources.change(lambda x: gr.update(visible = True ) if "OpenAlex" in x else gr.update(visible=False) , inputs=[dropdown_external_sources], outputs=[after], visible=True)
|
|
|
|
|
|
|
472 |
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
+
with gr.Tab("Sources",elem_id = "tab-sources",id = 1) as tab_sources:
|
475 |
+
sources_textbox = gr.HTML(show_label=False, elem_id="sources-textbox")
|
476 |
+
docs_textbox = gr.State("")
|
477 |
+
|
|
|
478 |
|
|
|
479 |
|
480 |
+
with gr.Tab("Recommended content", elem_id="tab-recommended_content",id=2) as tab_recommended_content:
|
481 |
+
with gr.Tabs(elem_id = "group-subtabs") as tabs_recommended_content:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
|
483 |
+
with gr.Tab("Figures",elem_id = "tab-figures",id = 3) as tab_figures:
|
484 |
+
sources_raw = gr.State()
|
485 |
+
|
486 |
+
with Modal(visible=False, elem_id="modal_figure_galery") as modal:
|
487 |
+
gallery_component = gr.Gallery(object_fit='scale-down',elem_id="gallery-component", height="80vh")
|
488 |
+
|
489 |
+
show_full_size_figures = gr.Button("Show figures in full size",elem_id="show-figures",interactive=True)
|
490 |
+
show_full_size_figures.click(lambda : Modal(visible=True),None,modal)
|
491 |
+
|
492 |
+
figures_cards = gr.HTML(show_label=False, elem_id="sources-figures")
|
493 |
+
|
494 |
+
|
495 |
+
|
496 |
+
with gr.Tab("Papers",elem_id = "tab-citations",id = 4) as tab_papers:
|
497 |
+
# btn_summary = gr.Button("Summary")
|
498 |
+
# Fenêtre simulée pour le Summary
|
499 |
+
with gr.Accordion(visible=True, elem_id="papers-summary-popup", label= "See summary of relevant papers", open= False) as summary_popup:
|
500 |
+
papers_summary = gr.Markdown("", visible=True, elem_id="papers-summary")
|
501 |
+
|
502 |
+
# btn_relevant_papers = gr.Button("Relevant papers")
|
503 |
+
# Fenêtre simulée pour les Relevant Papers
|
504 |
+
with gr.Accordion(visible=True, elem_id="papers-relevant-popup",label= "See relevant papers", open= False) as relevant_popup:
|
505 |
+
papers_html = gr.HTML(show_label=False, elem_id="papers-textbox")
|
506 |
+
docs_textbox = gr.State("")
|
507 |
+
|
508 |
+
btn_citations_network = gr.Button("Explore papers citations network")
|
509 |
+
# Fenêtre simulée pour le Citations Network
|
510 |
+
with Modal(visible=False) as modal:
|
511 |
+
citations_network = gr.HTML("<h3>Citations Network Graph</h3>", visible=True, elem_id="papers-citations-network")
|
512 |
+
btn_citations_network.click(lambda: Modal(visible=True), None, modal)
|
513 |
+
|
514 |
|
515 |
+
|
516 |
+
with gr.Tab("Graphs", elem_id="tab-graphs", id=5) as tab_graphs:
|
517 |
+
graphs_container = gr.HTML("<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>",elem_id="graphs-container")
|
518 |
+
current_graphs.change(lambda x : x, inputs=[current_graphs], outputs=[graphs_container])
|
519 |
+
|
520 |
+
# with gr.Tab("OECD",elem_id = "tab-oecd",id = 6):
|
521 |
+
# oecd_indicator = "RIVER_FLOOD_RP100_POP_SH"
|
522 |
+
# oecd_topic = "climate"
|
523 |
+
# oecd_latitude = "46.8332"
|
524 |
+
# oecd_longitude = "5.3725"
|
525 |
+
# oecd_zoom = "5.6442"
|
526 |
+
# # Create the HTML content with the iframe
|
527 |
+
# iframe_html = f"""
|
528 |
+
# <iframe src="https://localdataportal.oecd.org/maps.html?indicator={oecd_indicator}&topic={oecd_topic}&latitude={oecd_latitude}&longitude={oecd_longitude}&zoom={oecd_zoom}"
|
529 |
+
# width="100%" height="600" frameborder="0" style="border:0;" allowfullscreen></iframe>
|
530 |
+
# """
|
531 |
+
# oecd_textbox = gr.HTML(iframe_html, show_label=False, elem_id="oecd-textbox")
|
532 |
|
533 |
+
|
534 |
+
|
535 |
|
536 |
|
537 |
#---------------------------------------------------------------------------------------
|
538 |
# OTHER TABS
|
539 |
#---------------------------------------------------------------------------------------
|
540 |
|
541 |
+
# with gr.Tab("Settings",elem_id = "tab-config",id = 2):
|
542 |
|
543 |
+
# gr.Markdown("Reminder: You can talk in any language, ClimateQ&A is multi-lingual!")
|
544 |
|
545 |
|
546 |
+
# dropdown_sources = gr.CheckboxGroup(
|
547 |
+
# ["IPCC", "IPBES","IPOS", "OpenAlex"],
|
548 |
+
# label="Select source",
|
549 |
+
# value=["IPCC"],
|
550 |
+
# interactive=True,
|
551 |
+
# )
|
552 |
|
553 |
+
# dropdown_reports = gr.Dropdown(
|
554 |
+
# POSSIBLE_REPORTS,
|
555 |
+
# label="Or select specific reports",
|
556 |
+
# multiselect=True,
|
557 |
+
# value=None,
|
558 |
+
# interactive=True,
|
559 |
+
# )
|
560 |
|
561 |
+
# dropdown_audience = gr.Dropdown(
|
562 |
+
# ["Children","General public","Experts"],
|
563 |
+
# label="Select audience",
|
564 |
+
# value="Experts",
|
565 |
+
# interactive=True,
|
566 |
+
# )
|
567 |
|
|
|
568 |
|
569 |
+
# output_query = gr.Textbox(label="Query used for retrieval",show_label = True,elem_id = "reformulated-query",lines = 2,interactive = False)
|
570 |
+
# output_language = gr.Textbox(label="Language",show_label = True,elem_id = "language",lines = 1,interactive = False)
|
571 |
|
572 |
|
573 |
with gr.Tab("About",elem_classes = "max-height other-tabs"):
|
|
|
632 |
papers_number = papers_html.count("<h2>")
|
633 |
sources_notif_label = f"Sources ({sources_number})"
|
634 |
figures_notif_label = f"Figures ({figures_number})"
|
635 |
+
graphs_notif_label = f"Graphs ({graphs_number})"
|
636 |
papers_notif_label = f"Papers ({papers_number})"
|
637 |
+
recommended_content_notif_label = f"Recommended content ({figures_number + graphs_number + papers_number})"
|
638 |
|
639 |
+
return gr.update(label = recommended_content_notif_label), gr.update(label = sources_notif_label), gr.update(label = figures_notif_label), gr.update(label = graphs_notif_label), gr.update(label = papers_notif_label)
|
640 |
|
641 |
(textbox
|
642 |
.submit(start_chat, [textbox,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_textbox")
|
643 |
.then(chat, [textbox,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, dropdown_external_sources] ,[chatbot,sources_textbox,output_query,output_language, sources_raw, current_graphs],concurrency_limit = 8,api_name = "chat_textbox")
|
644 |
.then(finish_chat, None, [textbox],api_name = "finish_chat_textbox")
|
645 |
+
# .then(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures, tab_graphs, tab_papers] )
|
646 |
)
|
647 |
|
648 |
(examples_hidden
|
649 |
.change(start_chat, [examples_hidden,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_examples")
|
650 |
.then(chat, [examples_hidden,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, dropdown_external_sources] ,[chatbot,sources_textbox,output_query,output_language, sources_raw, current_graphs],concurrency_limit = 8,api_name = "chat_textbox")
|
651 |
.then(finish_chat, None, [textbox],api_name = "finish_chat_examples")
|
652 |
+
# .then(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_sources, tab_figures, tab_graphs, tab_papers] )
|
653 |
)
|
654 |
|
655 |
|
|
|
662 |
|
663 |
sources_raw.change(process_figures, inputs=[sources_raw], outputs=[figures_cards, gallery_component])
|
664 |
|
665 |
+
# update sources numbers
|
666 |
+
sources_textbox.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_recommended_content, tab_sources, tab_figures, tab_graphs, tab_papers])
|
667 |
+
figures_cards.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_recommended_content, tab_sources, tab_figures, tab_graphs, tab_papers])
|
668 |
+
current_graphs.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_recommended_content, tab_sources, tab_figures, tab_graphs, tab_papers])
|
669 |
+
papers_html.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs,papers_html],[tab_recommended_content, tab_sources, tab_figures, tab_graphs, tab_papers])
|
670 |
|
671 |
+
# other questions examples
|
672 |
dropdown_samples.change(change_sample_questions,dropdown_samples,samples)
|
673 |
|
674 |
+
# search for papers
|
675 |
textbox.submit(find_papers,[textbox,after, dropdown_external_sources], [papers_html,citations_network,papers_summary])
|
676 |
examples_hidden.change(find_papers,[examples_hidden,after,dropdown_external_sources], [papers_html,citations_network,papers_summary])
|
677 |
|
678 |
+
# btn_summary.click(toggle_summary_visibility, outputs=summary_popup)
|
679 |
+
# btn_relevant_papers.click(toggle_relevant_visibility, outputs=relevant_popup)
|
680 |
|
681 |
demo.queue()
|
682 |
|
climateqa/engine/chains/retrieve_documents.py
CHANGED
@@ -183,6 +183,23 @@ async def get_IPCC_relevant_documents(
|
|
183 |
# The chain callback is not necessary, but it propagates the langchain callbacks to the astream_events logger to display intermediate results
|
184 |
# @chain
|
185 |
async def retrieve_documents(state,config, vectorstore,reranker,llm,rerank_by_question=True, k_final=15, k_before_reranking=100, k_summary=5, k_images=5):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
print("---- Retrieve documents ----")
|
187 |
|
188 |
# Get the documents from the state
|
|
|
183 |
# The chain callback is not necessary, but it propagates the langchain callbacks to the astream_events logger to display intermediate results
|
184 |
# @chain
|
185 |
async def retrieve_documents(state,config, vectorstore,reranker,llm,rerank_by_question=True, k_final=15, k_before_reranking=100, k_summary=5, k_images=5):
|
186 |
+
"""
|
187 |
+
Retrieve and rerank documents based on the current question in the state.
|
188 |
+
|
189 |
+
Args:
|
190 |
+
state (dict): The current state containing documents, related content, relevant content sources, remaining questions and n_questions.
|
191 |
+
config (dict): Configuration settings for logging and other purposes.
|
192 |
+
vectorstore (object): The vector store used to retrieve relevant documents.
|
193 |
+
reranker (object): The reranker used to rerank the retrieved documents.
|
194 |
+
llm (object): The language model used for processing.
|
195 |
+
rerank_by_question (bool, optional): Whether to rerank documents by question. Defaults to True.
|
196 |
+
k_final (int, optional): The final number of documents to retrieve. Defaults to 15.
|
197 |
+
k_before_reranking (int, optional): The number of documents to retrieve before reranking. Defaults to 100.
|
198 |
+
k_summary (int, optional): The number of summary documents to retrieve. Defaults to 5.
|
199 |
+
k_images (int, optional): The number of image documents to retrieve. Defaults to 5.
|
200 |
+
Returns:
|
201 |
+
dict: The updated state containing the retrieved and reranked documents, related content, and remaining questions.
|
202 |
+
"""
|
203 |
print("---- Retrieve documents ----")
|
204 |
|
205 |
# Get the documents from the state
|
style.css
CHANGED
@@ -2,6 +2,57 @@
|
|
2 |
/* :root {
|
3 |
--user-image: url('https://ih1.redbubble.net/image.4776899543.6215/st,small,507x507-pad,600x600,f8f8f8.jpg');
|
4 |
} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
.avatar-container.svelte-1x5p6hu:not(.thumbnail-item) img {
|
6 |
width: 100%;
|
7 |
height: 100%;
|
@@ -223,8 +274,9 @@ a {
|
|
223 |
}
|
224 |
*/
|
225 |
|
|
|
226 |
label.selected{
|
227 |
-
background:
|
228 |
}
|
229 |
|
230 |
#submit-button{
|
@@ -232,6 +284,12 @@ label.selected{
|
|
232 |
}
|
233 |
|
234 |
@media screen and (min-width: 1024px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
.gradio-container {
|
236 |
max-height: calc(100vh - 190px) !important;
|
237 |
overflow: hidden;
|
@@ -242,10 +300,7 @@ label.selected{
|
|
242 |
|
243 |
} */
|
244 |
|
245 |
-
|
246 |
-
height:calc(100vh - 190px) !important;
|
247 |
-
overflow-y: auto !important;
|
248 |
-
}
|
249 |
|
250 |
div#tab-examples{
|
251 |
height:calc(100vh - 190px) !important;
|
@@ -258,6 +313,10 @@ label.selected{
|
|
258 |
overflow-y: scroll !important;
|
259 |
/* overflow-y: auto !important; */
|
260 |
}
|
|
|
|
|
|
|
|
|
261 |
|
262 |
div#sources-figures{
|
263 |
height:calc(100vh - 300px) !important;
|
@@ -265,6 +324,18 @@ label.selected{
|
|
265 |
overflow-y: scroll !important;
|
266 |
}
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
div#tab-config{
|
269 |
height:calc(100vh - 190px) !important;
|
270 |
overflow-y: scroll !important;
|
@@ -553,12 +624,6 @@ span.chatbot > p > img{
|
|
553 |
color:red !important;
|
554 |
}
|
555 |
|
556 |
-
/* Additional style for scrollable tab content */
|
557 |
-
div#tab-recommended_content {
|
558 |
-
overflow-y: auto; /* Enable vertical scrolling */
|
559 |
-
max-height: 80vh; /* Adjust height as needed */
|
560 |
-
}
|
561 |
-
|
562 |
/* Mobile specific adjustments */
|
563 |
@media screen and (max-width: 767px) {
|
564 |
div#tab-recommended_content {
|
|
|
2 |
/* :root {
|
3 |
--user-image: url('https://ih1.redbubble.net/image.4776899543.6215/st,small,507x507-pad,600x600,f8f8f8.jpg');
|
4 |
} */
|
5 |
+
|
6 |
+
#tab-recommended_content{
|
7 |
+
padding-top: 0px;
|
8 |
+
padding-left : 0px;
|
9 |
+
padding-right: 0px;
|
10 |
+
}
|
11 |
+
#group-subtabs {
|
12 |
+
/* display: block; */
|
13 |
+
width: 100%; /* Ensures the parent uses the full width */
|
14 |
+
position : sticky;
|
15 |
+
}
|
16 |
+
|
17 |
+
#group-subtabs .tab-container {
|
18 |
+
display: flex;
|
19 |
+
text-align: center;
|
20 |
+
width: 100%; /* Ensures the tabs span the full width */
|
21 |
+
}
|
22 |
+
|
23 |
+
#group-subtabs .tab-container button {
|
24 |
+
flex: 1; /* Makes each button take equal width */
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
#papers-summary-popup button span{
|
29 |
+
/* make label of accordio in bold, center, and bigger */
|
30 |
+
font-size: 16px;
|
31 |
+
font-weight: bold;
|
32 |
+
text-align: center;
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
#papers-relevant-popup span{
|
37 |
+
/* make label of accordio in bold, center, and bigger */
|
38 |
+
font-size: 16px;
|
39 |
+
font-weight: bold;
|
40 |
+
text-align: center;
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
#tab-citations .button{
|
46 |
+
padding: 12px 16px;
|
47 |
+
font-size: 16px;
|
48 |
+
font-weight: bold;
|
49 |
+
cursor: pointer;
|
50 |
+
border: none;
|
51 |
+
outline: none;
|
52 |
+
text-align: left;
|
53 |
+
transition: background-color 0.3s ease;
|
54 |
+
}
|
55 |
+
|
56 |
.avatar-container.svelte-1x5p6hu:not(.thumbnail-item) img {
|
57 |
width: 100%;
|
58 |
height: 100%;
|
|
|
274 |
}
|
275 |
*/
|
276 |
|
277 |
+
|
278 |
label.selected{
|
279 |
+
background: #93c5fd !important;
|
280 |
}
|
281 |
|
282 |
#submit-button{
|
|
|
284 |
}
|
285 |
|
286 |
@media screen and (min-width: 1024px) {
|
287 |
+
/* Additional style for scrollable tab content */
|
288 |
+
/* div#tab-recommended_content {
|
289 |
+
overflow-y: auto;
|
290 |
+
max-height: 80vh;
|
291 |
+
} */
|
292 |
+
|
293 |
.gradio-container {
|
294 |
max-height: calc(100vh - 190px) !important;
|
295 |
overflow: hidden;
|
|
|
300 |
|
301 |
} */
|
302 |
|
303 |
+
|
|
|
|
|
|
|
304 |
|
305 |
div#tab-examples{
|
306 |
height:calc(100vh - 190px) !important;
|
|
|
313 |
overflow-y: scroll !important;
|
314 |
/* overflow-y: auto !important; */
|
315 |
}
|
316 |
+
div#graphs-container{
|
317 |
+
height:calc(100vh - 210px) !important;
|
318 |
+
overflow-y: scroll !important;
|
319 |
+
}
|
320 |
|
321 |
div#sources-figures{
|
322 |
height:calc(100vh - 300px) !important;
|
|
|
324 |
overflow-y: scroll !important;
|
325 |
}
|
326 |
|
327 |
+
div#graphs-container{
|
328 |
+
height:calc(100vh - 300px) !important;
|
329 |
+
max-height: 90vh !important;
|
330 |
+
overflow-y: scroll !important;
|
331 |
+
}
|
332 |
+
|
333 |
+
div#tab-citations{
|
334 |
+
height:calc(100vh - 300px) !important;
|
335 |
+
max-height: 90vh !important;
|
336 |
+
overflow-y: scroll !important;
|
337 |
+
}
|
338 |
+
|
339 |
div#tab-config{
|
340 |
height:calc(100vh - 190px) !important;
|
341 |
overflow-y: scroll !important;
|
|
|
624 |
color:red !important;
|
625 |
}
|
626 |
|
|
|
|
|
|
|
|
|
|
|
|
|
627 |
/* Mobile specific adjustments */
|
628 |
@media screen and (max-width: 767px) {
|
629 |
div#tab-recommended_content {
|