File size: 4,823 Bytes
5d4ad83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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])