from dotenv import load_dotenv import os import streamlit as st from streamlit_option_menu import option_menu import pandas as pd import base64 from Functions import RFPProcessor # from localStoragePy import localStoragePy from Utils import ( export, clear_rfp_data, get_binary_file_downloader_html, generate_roadmap_image, ) # from Login_and_email import * from Proposal import prop #localStorage = localStoragePy("RFP", "json") # Initialize session states if "generated" not in st.session_state: st.session_state["generated"] = [] if "past" not in st.session_state: st.session_state["past"] = [] if "input" not in st.session_state: st.session_state["input"] = "" if "vectorstore" not in st.session_state: st.session_state["vectorstore"] = None if "rfp_details" not in st.session_state: st.session_state["rfp_details"] = "" if "is_data_processed" not in st.session_state: st.session_state["is_data_processed"] = False if "user_stories" not in st.session_state: st.session_state["user_stories"] = "" if "user_stories_data" not in st.session_state: st.session_state["user_stories_data"] = [] if "user_stories_json" not in st.session_state: st.session_state["user_stories_json"] = {} if "is_user_stories_created" not in st.session_state: st.session_state["is_user_stories_created"] = False if "rfp_summary" not in st.session_state: st.session_state["rfp_summary"] = "" if "estimation_data" not in st.session_state: st.session_state["estimation_data"] = [] if "estimation_data_json" not in st.session_state: st.session_state["estimation_data_json"] = {} if "is_estimation_data_created" not in st.session_state: st.session_state["is_estimation_data_created"] = False if "roadmap_data" not in st.session_state: st.session_state["roadmap_data"] = [] if "roadmap_data_json" not in st.session_state: st.session_state["roadmap_data_json"] = [] if "is_roadmap_data_created" not in st.session_state: st.session_state["is_roadmap_data_created"] = False if "is_presentation_created" not in st.session_state: st.session_state["is_presentation_created"] = False def main(): function = RFPProcessor() if "input" not in st.session_state: st.session_state["input"] = "" with st.sidebar: menu_choice = option_menu( menu_title="RFPStoryCraft", options=[ "Home", "RFP Bot", "User Stories", "Summary", "Estimations", "RoadMap", ], icons=["house", "list-task", "book", "book", "list-task"], ) if st.session_state["is_data_processed"] == True: st.button("Clear RFP Data", on_click=clear_rfp_data) # if localStorage.getItem("email"): # st.button("Log out", on_click=lambda: log_out_user(localStorage)) if menu_choice == "Home": with st.form("my_form"): project_name = st.text_input( "Project Name", key="Project Name", type="default", placeholder="Project Name", ) files = st.file_uploader( "Document", type=["pdf", "txt", "docx"], accept_multiple_files=True ) submitted = st.form_submit_button("Process Data") if submitted: if project_name and files: function.process_rfp_data(project_name, files) else: st.warning( "project_name and file are required to create create stories", icon="⚠️", ) if menu_choice == "RFP Bot": if st.session_state["is_data_processed"] == True: st.title(" RFP Chatbot ") st.subheader(" Powered by Coffeebeans") st.text_input( "You: ", st.session_state["input"], key="input", placeholder="Your AI assistant here! Ask me Queries related to RFP", on_change=function.genrate_bot_result(), label_visibility="hidden", ) with st.container(): for i in range(len(st.session_state["generated"]) - 1, -1, -1): st.success(st.session_state["generated"][i], icon="🤖") st.info(st.session_state["past"][i], icon="🧐") else: st.warning("Plesase Process RFP Details to access this feature", icon="⚠️") if menu_choice == "User Stories": if st.session_state["is_data_processed"] == True: st.title("User Stories") st.button( "Genrate User Stories", type="primary", on_click=function.genrate_user_stories, ) if st.session_state["is_user_stories_created"] == True: st.button( "Export Stories", on_click=lambda: export(st.session_state["user_stories_data"]), ) with st.container(): df = pd.DataFrame(st.session_state["user_stories_data"]) st.table(df) else: st.warning("Plesase Process RFP Details to access this feature", icon="⚠️") if menu_choice == "Summary": if st.session_state["is_data_processed"] == True: st.title("Summary") with st.container(): st.markdown(st.session_state["rfp_summary"]) else: st.warning("Plesase Process RFP Details to access this feature", icon="⚠️") if menu_choice == "Estimations": if st.session_state["is_data_processed"] == True: if st.session_state["is_user_stories_created"] == True: st.title("Estimations") senior_developers = st.text_input( label="Number of Senior Developers", placeholder="Enter here....", ) junior_developers = st.text_input( label="Number of Junior Developers", placeholder="Enter here...", ) tech_leads = st.text_input( label="Number of Tech Leads", placeholder="Enter here....", ) if ( senior_developers and junior_developers and tech_leads and st.session_state["is_user_stories_created"] == True ): st.button( "Generate Estimations", on_click=lambda: function.generate_estimations( tech_leads, senior_developers, junior_developers ), ) if st.session_state["is_estimation_data_created"] == True: st.button( "Export Stories", on_click=lambda: export( st.session_state["estimation_data"] ), ) with st.container(): df = pd.DataFrame(st.session_state["estimation_data"]) st.table(df) else: st.warning( "Plesase Process User Stories to access this feature", icon="⚠️" ) else: st.warning("Plesase Process RFP Details to access this feature", icon="⚠️") if menu_choice == "RoadMap": if st.session_state["is_data_processed"] == True: if st.session_state["is_estimation_data_created"] == True: st.title("RoadMap") st.button( "Generate RoadMap", on_click=lambda: function.generate_roadmap() ) if st.session_state["is_roadmap_data_created"] == True: st.button( "Export RoadMap", on_click=lambda: export(st.session_state["roadmap_data"]), ) if st.button("Generate Roadmap and Download"): st.info("Generating roadmap... Please wait.") # Generate the roadmap image generate_roadmap_image() with st.container(): df = pd.DataFrame(st.session_state["roadmap_data"]) st.table(df) else: st.warning( "Please Process the Estimations Data to access this feature", icon="⚠️", ) else: st.warning("Plesase Process RFP Details to access this feature", icon="⚠️") # if menu_choice == "Proposal": # if st.session_state["is_data_processed"] == True: # if st.session_state["is_user_stories_created"] == True: # st.title("Proposal") # num_slides = st.number_input( # "Enter the number of slides", min_value=1, max_value=20, value=None # ) # if num_slides: # st.button( # "Generate Presentation", on_click=lambda: prop(num_slides) # ) # if st.session_state["is_presentation_created"] == True: # st.success("Presentation Created!", icon="✅") # with open("Generated_Presentation.pptx", "rb") as pptx_file: # pptx_bytes = pptx_file.read() # st.download_button( # label="Download Presentation", # data=pptx_bytes, # file_name="Generated_Presentation_from_code.pptx", # mime="application/vnd.openxmlformats-officedocument.presentationml.presentation", # ) # else: # st.warning( # "Please Process the User Stories Data to access this feature", # icon="⚠️", # ) # else: # st.warning("Plesase Process RFP Details to access this feature", icon="⚠️") if __name__ == "__main__": main()