{content}
References used in answering the question will be displayed below.
" ) # gr.Markdown("References used in answering the question will be displayed below.") # gr.Markdown("nothing test") with gr.Tab("Setting"): # checkbox for allowing web search # flag_web_search = gr.Checkbox(label="Search web", info="Search information from Internet") gr.Markdown("More in DEV...") # Action functions user_txt.submit(check_input_text, user_txt, None).success( add_text, [chatbot, user_txt], [chatbot, user_txt] ).then(bot_lisa, [chatbot, flag_web_search], [chatbot, doc_citation]) submit_btn.click(check_input_text, user_txt, None).success( add_text, [chatbot, user_txt], [chatbot, user_txt], # concurrency_limit=8, # queue=False, ).then(bot_lisa, [chatbot, flag_web_search], [chatbot, doc_citation]) clear_btn.click(lambda: None, None, chatbot, queue=False) ###################################################################### ###################################################################### # Document-based QA with gr.Tab("Upload document 📚"): qa_conversation = gr.State( "placeholder", time_to_live=3600 ) # clean state after 1h, is , is time_to_live=3600 needed? with gr.Row(): with gr.Column(scale=7, variant="chat_panel"): chatbot_docqa = gr.Chatbot( [], elem_id="chatbot_docqa", label="Document Assistant", show_copy_button=True, likeable=True, ) docqa_question = gr.Textbox( label="Question", placeholder="Type in the question and press Enter/click Submit", ) with gr.Row(): with gr.Column(scale=50): docqa_submit_btn = gr.Button("Submit", variant="primary") with gr.Column(scale=50): docqa_clear_btn = gr.Button("Clear", variant="stop") gr.Examples( examples=[ "Summarize the paper", "Summarize the paper in 3 bullet points", # "Explain Abstract of this paper in 2 lines", "What are the contributions of this paper", "Explain the practical implications of this paper", "Methods used in this paper", "What data has been used in this paper", "Results of the paper", "Conclusions from the paper", "Limitations of this paper", "Future works suggested in this paper", ], inputs=docqa_question, outputs=chatbot_docqa, fn=add_text, label="Example questions for single document.", # cache_examples=True, cache_examples=False, examples_per_page=4, ) # Load file, reference (citations) and other settings with gr.Column(scale=3): with gr.Tab("Load"): # with gr.Column(scale=3, variant="load_file_panel"): with gr.Row(): gr.HTML( "Upload pdf/xml file(s), click the Load file button. After preprocessing, you can start asking questions about the document. (Please do not share sensitive document)" ) with gr.Row(): uploaded_doc = gr.File( label="Upload pdf/xml (max. 3) file(s)", file_count="multiple", file_types=[".pdf", ".xml"], type="filepath", height=100, ) with gr.Row(): langchain_status = gr.Textbox( label="Status", placeholder="", interactive=False ) load_document = gr.Button("Load file") with gr.Tab("References"): doc_citation_user_doc = gr.HTML( "References used in answering the question will be displayed below." ) with gr.Tab("Setting"): gr.Markdown("More in DEV...") # Actions load_document.click( document_changes, inputs=[uploaded_doc], # , repo_id], outputs=[ langchain_status, qa_conversation, ], # , docqa_db, docqa_retriever], queue=False, ) docqa_question.submit(check_input_text, docqa_question).success( add_text, [chatbot_docqa, docqa_question], [chatbot_docqa, docqa_question], ).then( bot, [chatbot_docqa, qa_conversation], [chatbot_docqa, doc_citation_user_doc], ) docqa_submit_btn.click(check_input_text, docqa_question).success( add_text, [chatbot_docqa, docqa_question], [chatbot_docqa, docqa_question], ).then( bot, [chatbot_docqa, qa_conversation], [chatbot_docqa, doc_citation_user_doc], ) ########################## # Preview tabs with gr.Tab("Preview feature 🔬"): # VLM model with gr.Tab("Vision LM 🖼"): vision_tmp_link = ( "https://kadi-iam-lisa-vlm.hf.space/" # vision model link ) with gr.Blocks(css="""footer {visibility: hidden};""") as preview_tab: gr.HTML( """""".format( vision_tmp_link ) ) # gr.Markdown("placeholder") # OAuth2 linkage to Kadi-demo with gr.Tab("KadiChat 💬"): kadichat_tmp_link = ( "https://kadi-iam-kadichat.hf.space/" # vision model link ) with gr.Blocks(css="""footer {visibility: hidden};""") as preview_tab: gr.HTML( """""".format( kadichat_tmp_link ) ) # Knowledge graph-enhanced RAG with gr.Tab("RAG enhanced with Knowledge Graph (dev) 🔎"): kg_tmp_link = "https://kadi-iam-kadikgraph.static.hf.space/index.html" gr.Markdown( "[If rendering fails, look at the graph here](https://kadi-iam-kadikgraph.static.hf.space)" ) with gr.Blocks(css="""footer {visibility: hidden};""") as preview_tab: gr.HTML( """ """.format( kg_tmp_link ) ) # About information with gr.Tab("About 📝"): with gr.Tab("Dev. info"): gr.Markdown( """ This system is being developed by the [Kadi Team at IAM-MMS, KIT](https://kadi.iam.kit.edu/kadi-ai), in collaboration with various groups with different scientific backgrounds. Changelog: - 23-10-2024: Add Kadi knowledge graph as test for Knowledge Graph-RAG. - 18-10-2024: Add linkage to Kadi. - 02-10-2024: Code cleaning, release code soon - 26-09-2024: Switch Vision-LLM to Mistral via API - 31-08-2024: Make document parsing as a preprocessing step and cache vector-database - 31-05-2024: Add Vision-LLM and draft Knowledge Graph-RAG (*preview*) - 21-05-2024: Add web search in setting (*experimental*) - 15-03-2024: Add evaluation and improve citation feature - 20-02-2024: Add citation feature (*experimental*) - 16-02-2024: Add support for xml file - 12-02-2024: Set demo on huggingface - 16-01-2024: Build first demo version - 23-11-2023: Draft concept Dev: - Metadata parsing - More robust citation feature - Conversational chat Current limitations: - The conversational chat (chat with history context) is not supported yet - Only 3 files are allowed to upload for testing *Notes: The model may produce incorrect statements. Users should treat these outputs as suggestions or starting points, not as definitive or accurate facts. """ ) with gr.Tab("What's included?"): from paper_list import paper_list_str gr.Markdown( f"Currently, LISA includes the following open/free access pulications/documents/websites:\n\n {paper_list_str}" ) # pdf_loader.change(pdf_changes, inputs=[pdf_loader, repo_id], outputs=[langchain_status], queue=False) ###################################################################### demo.queue(max_size=8, default_concurrency_limit=4).launch(share=True) if __name__ == "__main__": main()