from dotenv import load_dotenv
import os
import streamlit as st
from streamlit_option_menu import option_menu
from Functions import RFPProcessor
from utills import ( on_click_toggle)
# Initialize session states for rfp data (data processing)
if "vectorstore" not in st.session_state:
st.session_state["vectorstore"] = None
if "pdf_details" not in st.session_state:
st.session_state["pdf_details"] = ""
if "is_data_processed" not in st.session_state:
st.session_state["is_data_processed"] = False
# Initialize session states for summary bot
if "generated_bot_results" not in st.session_state:
st.session_state["generated_bot_results"] = []
if "past_bot_results" not in st.session_state:
st.session_state["past_bot_results"] = []
if "bot_input" not in st.session_state:
st.session_state["bot_input"] = ""
# Initialize session states for case
if "case_summary" not in st.session_state:
st.session_state["case_summary"] = ""
if "selected_model" not in st.session_state:
st.session_state["selected_model"] = "gpt-3.5-turbo-16k"
def main():
st.set_page_config(page_title="Justice League",
page_icon="⚖️", layout="wide")
top_left_container = st.sidebar.container()
model_name = "GPT-4o" if st.session_state["selected_model"] == "gpt-4o" else "GPT-3.5-turbo"
st.markdown(
"""
""",
unsafe_allow_html=True
)
with top_left_container:
st.markdown("
Toggle for Model Selection
", unsafe_allow_html=True)
st.markdown("(Default : GPT-3.5)
", unsafe_allow_html=True)
st.toggle(model_name, value=st.session_state["selected_model"] == "gpt-4o", key="model_toggle", on_change=on_click_toggle, args=None, disabled=False, label_visibility="visible")
function = RFPProcessor()
with st.sidebar:
menu_choice = option_menu(
menu_title="Legal Assistant",
options=[
"Home",
"Legal Bot",
],
icons=["house", "list-task"],
)
if menu_choice == "Home":
with st.form("my_form"):
case_name = st.text_input(
"Case Name",
key="Case Name",
type="default",
placeholder="Case Name",
)
files = st.file_uploader(
"Document", type=["pdf", "txt", "docx"], accept_multiple_files=True
)
submitted = st.form_submit_button("Process Data")
if submitted:
if case_name and files:
function.process_case_data(case_name, files)
else:
st.warning(
"project_name and file are required to create create stories",
icon="⚠️",
)
if st.session_state["is_data_processed"] == True:
st.title("Summary")
with st.container():
st.markdown(st.session_state["case_summary"])
if menu_choice == "Legal Bot":
if st.session_state["is_data_processed"] == True:
st.title(" Legal Bot ")
st.subheader(" Powered by Coffeebeans")
st.text_input(
"You: ",
st.session_state["bot_input"],
key="bot_input",
placeholder="Your AI Case assistant here! Ask me Queries related to Case",
on_change=function.genrate_legal_bot_result(),
label_visibility="hidden",
)
with st.container():
for i in range(len(st.session_state["generated_bot_results"]) - 1, -1, -1):
st.success(st.session_state["generated_bot_results"][i], icon="🤖")
st.info(st.session_state["past_bot_results"][i], icon="🧐")
else:
st.warning("Plesase Process Case Details to access this logal case bot", icon="⚠️")
if __name__ == "__main__":
main()