Vela
Created a frontend dashboard
5d4ad83
raw
history blame
4.82 kB
import streamlit as st
import pandas as pd
import os
from src.utils import streamlit_function
from src.utils import logger
logger = logger.get_logger()
streamlit_function.config_homepage()
st.title("Sustainability Report Analyzer")
st.write("Upload your sustainability report PDF and generate insights using Gemini models.")
uploaded_files = streamlit_function.upload_file("pdf", label="πŸ“€ Upload Sustainability Report PDF")
if uploaded_files:
st.session_state.uploaded_files = uploaded_files
if "uploaded_files" not in st.session_state:
st.session_state.uploaded_files = []
if st.session_state.uploaded_files:
columns = st.columns(1)
# # import streamlit as st
# # from application.schemas.response_schema import GEMINI_GHG_PARAMETERS, GEMINI_ENVIRONMENTAL_PARAMETERS_CSRD,GEMINI_ENVIRONMENT_PARAMETERS,GEMINI_SOCIAL_PARAMETERS, GEMINI_GOVERNANCE_PARAMETERS, GEMINI_MATERIALITY_PARAMETERS, GEMINI_NET_ZERO_INTERVENTION_PARAMETERS
# # from application.services import streamlit_function, gemini_model
# # from application.utils import logger
# # import test
# # logger = logger.get_logger()
# # streamlit_function.config_homepage()
# # st.title("Sustainability Report Analyzer")
# # st.write("Upload your sustainability report PDF and generate insights using different models.")
# # MODEL = ["gemini-1.5-pro-latest", "gemini-2.0-flash", "gemini-1.5-flash", "gemini-2.5-pro-exp-03-25"]
# # MODEL_1 = "gemini-1.5-pro-latest"
# # MODEL_2 = "gemini-2.0-flash"
# # MODEL_3 = "gemini-1.5-flash"
# # API_1 = "gemini"
# # API_2 = "gemini"
# # API_3 = "gemini"
# # response_schema = [ GEMINI_GHG_PARAMETERS, GEMINI_ENVIRONMENTAL_PARAMETERS_CSRD,
# # GEMINI_ENVIRONMENT_PARAMETERS,GEMINI_SOCIAL_PARAMETERS,
# # GEMINI_GOVERNANCE_PARAMETERS, GEMINI_MATERIALITY_PARAMETERS,
# # GEMINI_NET_ZERO_INTERVENTION_PARAMETERS]
# # if "uploaded_files" not in st.session_state:
# # st.session_state.uploaded_files = []
# # MODEL = st.selectbox(
# # "Select Model",
# # options=MODEL,
# # index=0,
# # )
# # uploaded_files = streamlit_function.upload_file("pdf", label="Upload Sustainability Report PDF")
# # if uploaded_files:
# # st.session_state.uploaded_files = uploaded_files
# # if st.session_state.uploaded_files:
# # columns = st.columns([5, 5, 5], gap="small")
# # for i, col in enumerate(columns):
# # if i < len(st.session_state.uploaded_files):
# # pdf_file = st.session_state.uploaded_files[i]
# # file_name = pdf_file.name.removesuffix(".pdf")
# # result_key = f"{MODEL}_result_file_{i+1}"
# # with col:
# # st.write(f"**File {i+1}:** `{pdf_file.name}`")
# # if st.button(f"Extract Data from File {i+1}", key=f"extract_btn_{i}"):
# # with st.spinner(f"Extracting data from File {i+1} using {MODEL}..."):
# # for schema in response_schema:
# # result = gemini_model.extract_emissions_data_as_json(API_1, MODEL, pdf_file, schema)
# # if schema == GEMINI_GHG_PARAMETERS:
# # column = "Greenhouse Gas (GHG) Protocol Parameters"
# # elif schema == GEMINI_ENVIRONMENTAL_PARAMETERS_CSRD:
# # column = "Environmental Parameters (CSRD)"
# # elif schema == GEMINI_ENVIRONMENT_PARAMETERS:
# # column = "Environmental Parameters"
# # elif schema == GEMINI_SOCIAL_PARAMETERS:
# # column = "Social Parameters"
# # elif schema == GEMINI_GOVERNANCE_PARAMETERS:
# # column = "Governance Parameters"
# # elif schema == GEMINI_MATERIALITY_PARAMETERS:
# # column = "Materiality Parameters"
# # elif schema == GEMINI_NET_ZERO_INTERVENTION_PARAMETERS:
# # column = "Net Zero Intervention Parameters"
# # else:
# # column = None
# # test.export_results_to_excel(result, sheet_name=MODEL, filename=file_name, column=column )
# # st.session_state[result_key] = result
# # if st.session_state.get(result_key):
# # st.write(f"**Extracted Metrics for File {i+1}:**")
# # st.json(st.session_state[result_key])