rfp_to_story / app.py
Darpan07's picture
Update app.py
b85cff9 verified
raw
history blame
8.73 kB
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
# from Login_and_email import *
# 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
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",
)
file = st.file_uploader("Document", type="pdf")
submitted = st.form_submit_button("Process Data")
if submitted:
if project_name and file:
function.process_rfp_data(project_name, file)
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:
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
roadmap_image_data = generate_roadmap_image()
# Display the generated image
st.image(roadmap_image_data, caption='Project Roadmap', use_column_width=True)
# Provide a download link for the image
st.markdown(get_binary_file_downloader_html(roadmap_image_data, 'project_roadmap.png', 'Download Image'), unsafe_allow_html=True)
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 __name__ == "__main__":
# if localStorage.getItem("email"):
main()
# else:
# authenticate(localStorage)