diff --git a/examples/storm_examples/helper/process_kaggle_arxiv_abstract_dataset.py b/examples/storm_examples/helper/process_kaggle_arxiv_abstract_dataset.py index 1a07d062..926192bf 100644 --- a/examples/storm_examples/helper/process_kaggle_arxiv_abstract_dataset.py +++ b/examples/storm_examples/helper/process_kaggle_arxiv_abstract_dataset.py @@ -1,4 +1,5 @@ -"""Process `arxiv_data_210930-054931.csv` from https://www.kaggle.com/datasets/spsayakpaul/arxiv-paper-abstracts +"""Process `arxiv_data_210930-054931.csv` +from https://www.kaggle.com/datasets/spsayakpaul/arxiv-paper-abstracts to a csv file that is compatible with VectorRM. """ diff --git a/frontend/demo_light/pages_util/CreateNewArticle.py b/frontend/demo_light/pages_util/CreateNewArticle.py index e548baa9..2257044a 100644 --- a/frontend/demo_light/pages_util/CreateNewArticle.py +++ b/frontend/demo_light/pages_util/CreateNewArticle.py @@ -5,13 +5,7 @@ import streamlit as st from demo_util import DemoFileIOHelper, DemoTextProcessingHelper, DemoUIHelper, truncate_filename - -def create_new_article_page(): - demo_util.clear_other_page_session_state(page_index=3) - - if "page3_write_article_state" not in st.session_state: - st.session_state["page3_write_article_state"] = "not started" - +def handle_not_started(): if st.session_state["page3_write_article_state"] == "not started": _, search_form_column, _ = st.columns([2, 5, 2]) @@ -42,6 +36,7 @@ def create_new_article_page(): else: st.session_state["page3_write_article_state"] = "initiated" +def handle_initiated(): if st.session_state["page3_write_article_state"] == "initiated": current_working_dir = os.path.join(demo_util.get_demo_dir(), "DEMO_WORKING_DIR") if not os.path.exists(current_working_dir): @@ -52,7 +47,8 @@ def create_new_article_page(): st.session_state["page3_current_working_dir"] = current_working_dir st.session_state["page3_write_article_state"] = "pre_writing" - if st.session_state["page3_write_article_state"] == "pre_writing": +def handle_pre_writing(): + if st.session_state["page3_write_article_state"] == "pre_writing": status = st.status("I am brain**STORM**ing now to research the topic. (This may take 2-3 minutes.)") st_callback_handler = demo_util.StreamlitCallbackHandler(status) with status: @@ -71,6 +67,7 @@ def create_new_article_page(): st.session_state["page3_write_article_state"] = "final_writing" status.update(label="brain**STORM**ing complete!", state="complete") +def handle_final_writing(): if st.session_state["page3_write_article_state"] == "final_writing": # polish final article with st.status( @@ -86,6 +83,7 @@ def create_new_article_page(): st.session_state["page3_write_article_state"] = "prepare_to_show_result" status.update(label="information snythesis complete!", state="complete") +def handle_prepare_to_show_result(): if st.session_state["page3_write_article_state"] == "prepare_to_show_result": _, show_result_col, _ = st.columns([4, 3, 4]) with show_result_col: @@ -93,6 +91,8 @@ def create_new_article_page(): st.session_state["page3_write_article_state"] = "completed" st.rerun() +def handle_completed(): + if st.session_state["page3_write_article_state"] == "completed": # display polished article current_working_dir_paths = DemoFileIOHelper.read_structure_to_dict( @@ -101,3 +101,21 @@ def create_new_article_page(): demo_util.display_article_page(selected_article_name=st.session_state["page3_topic_name_cleaned"], selected_article_file_path_dict=current_article_file_path_dict, show_title=True, show_main_article=True) + +def create_new_article_page(): + demo_util.clear_other_page_session_state(page_index=3) + + if "page3_write_article_state" not in st.session_state: + st.session_state["page3_write_article_state"] = "not started" + + handle_not_started() + + handle_initiated() + + handle_pre_writing() + + handle_final_writing() + + handle_prepare_to_show_result() + + handle_completed() diff --git a/frontend/demo_light/storm.py b/frontend/demo_light/storm.py index c68b88cf..1d095c35 100644 --- a/frontend/demo_light/storm.py +++ b/frontend/demo_light/storm.py @@ -35,13 +35,15 @@ def main(): menu_container = st.container() with menu_container: pages = ["My Articles", "Create New Article"] + styles={ + "container": {"padding": "0.2rem 0", + "background-color": "#22222200"}, + } menu_selection = option_menu(None, pages, icons=['house', 'search'], menu_icon="cast", default_index=0, orientation="horizontal", manual_select=st.session_state.selected_page, - styles={ - "container": {"padding": "0.2rem 0", "background-color": "#22222200"}, - }, + styles=styles, key='menu_selection') if st.session_state.get("manual_selection_override", False): menu_selection = pages[st.session_state["selected_page"]]