Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -141,14 +141,14 @@ if st.session_state.df is not None:
|
|
| 141 |
|
| 142 |
analyze_data = Task(
|
| 143 |
description="Analyze the extracted data for query: {query}.",
|
| 144 |
-
expected_output="Analysis text summarizing findings.",
|
| 145 |
agent=data_analyst,
|
| 146 |
context=[extract_data],
|
| 147 |
)
|
| 148 |
|
| 149 |
write_report = Task(
|
| 150 |
-
description="Summarize the analysis into an executive report.",
|
| 151 |
-
expected_output="Markdown report of insights.",
|
| 152 |
agent=report_writer,
|
| 153 |
context=[analyze_data],
|
| 154 |
)
|
|
@@ -168,12 +168,17 @@ if st.session_state.df is not None:
|
|
| 168 |
query = st.text_area("Enter Query:", value="Provide insights into the salary of a Principal Data Scientist.")
|
| 169 |
if st.button("Submit Query"):
|
| 170 |
with st.spinner("Processing query..."):
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
st.markdown("### Analysis Report:")
|
| 175 |
|
| 176 |
-
# Generate relevant visualizations
|
| 177 |
visualizations = []
|
| 178 |
|
| 179 |
fig_salary = px.box(st.session_state.df, x="job_title", y="salary_in_usd",
|
|
@@ -191,26 +196,17 @@ if st.session_state.df is not None:
|
|
| 191 |
title="Salary Distribution by Employment Type")
|
| 192 |
visualizations.append(fig_employment)
|
| 193 |
|
| 194 |
-
#
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
# Show Conclusion
|
| 206 |
-
st.markdown(insert_section)
|
| 207 |
-
st.markdown(parts[1])
|
| 208 |
-
else:
|
| 209 |
-
# Default if Conclusion not found
|
| 210 |
-
st.markdown(result)
|
| 211 |
-
st.markdown("## π Visual Insights")
|
| 212 |
-
for fig in visualizations:
|
| 213 |
-
st.plotly_chart(fig, use_container_width=True)
|
| 214 |
|
| 215 |
# Tab 2: Full Data Visualization
|
| 216 |
with tab2:
|
|
|
|
| 141 |
|
| 142 |
analyze_data = Task(
|
| 143 |
description="Analyze the extracted data for query: {query}.",
|
| 144 |
+
expected_output="Analysis text summarizing findings (without a Conclusion section).",
|
| 145 |
agent=data_analyst,
|
| 146 |
context=[extract_data],
|
| 147 |
)
|
| 148 |
|
| 149 |
write_report = Task(
|
| 150 |
+
description="Summarize the analysis into an executive report without a Conclusion.",
|
| 151 |
+
expected_output="Markdown report of insights without Conclusion.",
|
| 152 |
agent=report_writer,
|
| 153 |
context=[analyze_data],
|
| 154 |
)
|
|
|
|
| 168 |
query = st.text_area("Enter Query:", value="Provide insights into the salary of a Principal Data Scientist.")
|
| 169 |
if st.button("Submit Query"):
|
| 170 |
with st.spinner("Processing query..."):
|
| 171 |
+
# Step 1: Generate Report WITHOUT Conclusion
|
| 172 |
+
inputs = {"query": query + " Provide a detailed analysis but DO NOT include a Conclusion."}
|
| 173 |
+
report_result = crew.kickoff(inputs=inputs)
|
| 174 |
+
|
| 175 |
+
# Step 2: Generate ONLY the Conclusion
|
| 176 |
+
conclusion_inputs = {"query": query + " Now, provide only the Conclusion for this analysis."}
|
| 177 |
+
conclusion_result = crew.kickoff(inputs=conclusion_inputs)
|
| 178 |
|
| 179 |
st.markdown("### Analysis Report:")
|
| 180 |
|
| 181 |
+
# Step 3: Generate relevant visualizations
|
| 182 |
visualizations = []
|
| 183 |
|
| 184 |
fig_salary = px.box(st.session_state.df, x="job_title", y="salary_in_usd",
|
|
|
|
| 196 |
title="Salary Distribution by Employment Type")
|
| 197 |
visualizations.append(fig_employment)
|
| 198 |
|
| 199 |
+
# Step 4: Display report without conclusion
|
| 200 |
+
st.markdown(report_result)
|
| 201 |
+
|
| 202 |
+
# Step 5: Insert Visual Insights
|
| 203 |
+
st.markdown("## π Visual Insights")
|
| 204 |
+
for fig in visualizations:
|
| 205 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 206 |
+
|
| 207 |
+
# Step 6: Append the Conclusion
|
| 208 |
+
st.markdown("## Conclusion")
|
| 209 |
+
st.markdown(conclusion_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
# Tab 2: Full Data Visualization
|
| 212 |
with tab2:
|