Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -149,7 +149,7 @@ if st.session_state.df is not None:
|
|
| 149 |
llm=llm,
|
| 150 |
)
|
| 151 |
|
| 152 |
-
# Tasks for
|
| 153 |
extract_data = Task(
|
| 154 |
description="Extract data based on the query: {query}.",
|
| 155 |
expected_output="Database results matching the query.",
|
|
@@ -170,6 +170,7 @@ if st.session_state.df is not None:
|
|
| 170 |
context=[analyze_data],
|
| 171 |
)
|
| 172 |
|
|
|
|
| 173 |
write_conclusion = Task(
|
| 174 |
description=(
|
| 175 |
"Summarize the findings into a concise Conclusion. Include the max, min, and average salary in USD, "
|
|
@@ -180,10 +181,17 @@ if st.session_state.df is not None:
|
|
| 180 |
context=[analyze_data],
|
| 181 |
)
|
| 182 |
|
| 183 |
-
#
|
| 184 |
-
|
| 185 |
-
agents=[sql_dev, data_analyst, report_writer
|
| 186 |
-
tasks=[extract_data, analyze_data, write_report
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
process=Process.sequential,
|
| 188 |
verbose=True,
|
| 189 |
)
|
|
@@ -197,16 +205,16 @@ if st.session_state.df is not None:
|
|
| 197 |
if st.button("Submit Query"):
|
| 198 |
with st.spinner("Processing query..."):
|
| 199 |
# Step 1: Generate the main report (without Conclusion)
|
| 200 |
-
report_inputs = {"query": query
|
| 201 |
-
report_result =
|
| 202 |
|
| 203 |
# Step 2: Generate only the Conclusion
|
| 204 |
-
conclusion_inputs = {"query": query
|
| 205 |
-
conclusion_result =
|
| 206 |
|
| 207 |
-
#
|
| 208 |
-
main_report =
|
| 209 |
-
conclusion =
|
| 210 |
|
| 211 |
st.markdown("### Analysis Report:")
|
| 212 |
st.markdown(main_report)
|
|
@@ -260,6 +268,7 @@ if st.session_state.df is not None:
|
|
| 260 |
else:
|
| 261 |
st.info("Please load a dataset to proceed.")
|
| 262 |
|
|
|
|
| 263 |
# Sidebar Reference
|
| 264 |
with st.sidebar:
|
| 265 |
st.header("π Reference:")
|
|
|
|
| 149 |
llm=llm,
|
| 150 |
)
|
| 151 |
|
| 152 |
+
# Tasks for Report
|
| 153 |
extract_data = Task(
|
| 154 |
description="Extract data based on the query: {query}.",
|
| 155 |
expected_output="Database results matching the query.",
|
|
|
|
| 170 |
context=[analyze_data],
|
| 171 |
)
|
| 172 |
|
| 173 |
+
# Task for Conclusion
|
| 174 |
write_conclusion = Task(
|
| 175 |
description=(
|
| 176 |
"Summarize the findings into a concise Conclusion. Include the max, min, and average salary in USD, "
|
|
|
|
| 181 |
context=[analyze_data],
|
| 182 |
)
|
| 183 |
|
| 184 |
+
# Separate Crews for Report and Conclusion
|
| 185 |
+
crew_report = Crew(
|
| 186 |
+
agents=[sql_dev, data_analyst, report_writer],
|
| 187 |
+
tasks=[extract_data, analyze_data, write_report],
|
| 188 |
+
process=Process.sequential,
|
| 189 |
+
verbose=True,
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
crew_conclusion = Crew(
|
| 193 |
+
agents=[data_analyst, conclusion_writer],
|
| 194 |
+
tasks=[write_conclusion],
|
| 195 |
process=Process.sequential,
|
| 196 |
verbose=True,
|
| 197 |
)
|
|
|
|
| 205 |
if st.button("Submit Query"):
|
| 206 |
with st.spinner("Processing query..."):
|
| 207 |
# Step 1: Generate the main report (without Conclusion)
|
| 208 |
+
report_inputs = {"query": query}
|
| 209 |
+
report_result = crew_report.kickoff(inputs=report_inputs)
|
| 210 |
|
| 211 |
# Step 2: Generate only the Conclusion
|
| 212 |
+
conclusion_inputs = {"query": query}
|
| 213 |
+
conclusion_result = crew_conclusion.kickoff(inputs=conclusion_inputs)
|
| 214 |
|
| 215 |
+
# Extract results safely
|
| 216 |
+
main_report = report_result[0].output if report_result and hasattr(report_result[0], 'output') else "β οΈ No Report Generated."
|
| 217 |
+
conclusion = conclusion_result[0].output if conclusion_result and hasattr(conclusion_result[0], 'output') else "β οΈ No Conclusion Generated."
|
| 218 |
|
| 219 |
st.markdown("### Analysis Report:")
|
| 220 |
st.markdown(main_report)
|
|
|
|
| 268 |
else:
|
| 269 |
st.info("Please load a dataset to proceed.")
|
| 270 |
|
| 271 |
+
|
| 272 |
# Sidebar Reference
|
| 273 |
with st.sidebar:
|
| 274 |
st.header("π Reference:")
|