Update main.py
Browse files
main.py
CHANGED
@@ -7,12 +7,14 @@ from ai_analysis import AIAnalysis # Import the ai analysis class
|
|
7 |
from sidebar import Sidebar # Import the Sidebar class
|
8 |
from report import ReportGenerator
|
9 |
|
10 |
-
# ... (rest of your imports and app setup)
|
11 |
-
|
12 |
def main():
|
13 |
# Initialize the app configuration
|
14 |
app_config = AppConfig()
|
15 |
|
|
|
|
|
|
|
|
|
16 |
# Initialize the sidebar
|
17 |
sidebar = Sidebar()
|
18 |
sidebar.display()
|
@@ -141,36 +143,69 @@ def main():
|
|
141 |
with st.expander(f"{student_name} Decision Tree", expanded=False):
|
142 |
st.graphviz_chart(tree_diagram.source)
|
143 |
|
144 |
-
# Prepare input for the language model
|
145 |
-
llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
|
146 |
|
147 |
-
# Generate Notes and Recommendations using
|
148 |
-
with st.spinner("Generating
|
149 |
-
|
150 |
-
|
151 |
|
152 |
-
|
153 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
# Download AI output
|
156 |
-
ai_analysis.download_llm_output(recommendations, "
|
|
|
157 |
|
158 |
-
# Generate the PDF Report
|
159 |
-
report_gen = ReportGenerator()
|
160 |
-
combined_pdf = report_gen.create_combined_pdf(intervention_fig, student_metrics_fig, recommendations)
|
161 |
|
162 |
-
# Add the download button
|
163 |
-
st.download_button(
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
except Exception as e:
|
173 |
st.error(f"Error processing the file: {str(e)}")
|
174 |
|
175 |
if __name__ == '__main__':
|
176 |
-
main()
|
|
|
|
|
|
|
|
|
|
7 |
from sidebar import Sidebar # Import the Sidebar class
|
8 |
from report import ReportGenerator
|
9 |
|
|
|
|
|
10 |
def main():
|
11 |
# Initialize the app configuration
|
12 |
app_config = AppConfig()
|
13 |
|
14 |
+
# Initialize the session state
|
15 |
+
if 'ai_recommendations' not in st.session_state:
|
16 |
+
st.session_state.ai_recommendations = None
|
17 |
+
|
18 |
# Initialize the sidebar
|
19 |
sidebar = Sidebar()
|
20 |
sidebar.display()
|
|
|
143 |
with st.expander(f"{student_name} Decision Tree", expanded=False):
|
144 |
st.graphviz_chart(tree_diagram.source)
|
145 |
|
146 |
+
# # Prepare input for the language model
|
147 |
+
# llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
|
148 |
|
149 |
+
# # Generate Notes and Recommendations using LLM
|
150 |
+
# with st.spinner("Generating MTSS.ai analysis..."):
|
151 |
+
# # recommendations = ai_analysis.prompt_response_from_hf_llm(llm_input)
|
152 |
+
# recommendations = ai_analysis.prompt_response_from_mistral_llm(llm_input)
|
153 |
|
154 |
+
# Generate Notes and Recommendations using LLM
|
155 |
+
if st.session_state.ai_recommendations is None:
|
156 |
+
with st.spinner("Generating MTSS.ai analysis..."):
|
157 |
+
llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
|
158 |
+
recommendations = ai_analysis.prompt_response_from_mistral_llm(llm_input)
|
159 |
+
st.session_state.ai_recommendations = recommendations
|
160 |
+
|
161 |
+
# Display the recommendations
|
162 |
+
st.subheader("MTSS.ai Analysis")
|
163 |
+
# st.markdown(recommendations)
|
164 |
+
st.markdown(st.session_state.ai_recommendations)
|
165 |
|
166 |
# Download AI output
|
167 |
+
# ai_analysis.download_llm_output(recommendations, "MTSSai_Report.txt")
|
168 |
+
ai_analysis.download_llm_output(st.session_state.ai_recommendations, "MTSSai_Report.txt")
|
169 |
|
170 |
+
# # Generate the PDF Report
|
171 |
+
# report_gen = ReportGenerator()
|
172 |
+
# combined_pdf = report_gen.create_combined_pdf(intervention_fig, student_metrics_fig, recommendations)
|
173 |
|
174 |
+
# # Add the download button
|
175 |
+
# st.download_button(
|
176 |
+
# label="Download Combined Report (PDF)",
|
177 |
+
# data=combined_pdf,
|
178 |
+
# file_name="combined_report.pdf",
|
179 |
+
# mime="application/pdf",
|
180 |
+
# icon="📄",
|
181 |
+
# use_container_width=True
|
182 |
+
# )
|
183 |
+
|
184 |
+
# Generate the PDF Report using the stored recommendations
|
185 |
+
if st.button("Generate PDF Report"):
|
186 |
+
report_gen = ReportGenerator()
|
187 |
+
combined_pdf = report_gen.create_combined_pdf(
|
188 |
+
intervention_fig,
|
189 |
+
student_metrics_fig,
|
190 |
+
st.session_state.ai_recommendations
|
191 |
+
)
|
192 |
+
|
193 |
+
# Add the download button for the PDF
|
194 |
+
st.download_button(
|
195 |
+
label="Download Combined Report (PDF)",
|
196 |
+
data=combined_pdf,
|
197 |
+
file_name="combined_report.pdf",
|
198 |
+
mime="application/pdf",
|
199 |
+
icon="📄",
|
200 |
+
use_container_width=True
|
201 |
+
)
|
202 |
|
203 |
except Exception as e:
|
204 |
st.error(f"Error processing the file: {str(e)}")
|
205 |
|
206 |
if __name__ == '__main__':
|
207 |
+
main()
|
208 |
+
|
209 |
+
|
210 |
+
|
211 |
+
|