Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -538,49 +538,53 @@ if st.button("Generate Patent Insights"):
|
|
538 |
# Calculate elapsed time
|
539 |
elapsed_time = time.time() - start_time
|
540 |
|
541 |
-
# Extract
|
|
|
|
|
542 |
writer_output = getattr(results.tasks_output[2], "raw", "No details available.")
|
543 |
-
if writer_output and writer_output.strip():
|
544 |
-
st.markdown("### Final Report")
|
545 |
-
st.write(writer_output)
|
546 |
-
else:
|
547 |
-
st.warning("No final report available.")
|
548 |
-
|
549 |
-
# Expandable section for detailed insights
|
550 |
-
with st.expander("Explore Detailed Insights"):
|
551 |
-
tab1, tab2 = st.tabs(["Planner's Insights", "Analyst's Analysis"])
|
552 |
|
553 |
-
|
554 |
-
|
555 |
-
planner_output = getattr(results.tasks_output[0], "raw", "No details available.")
|
556 |
-
if planner_output and planner_output.strip():
|
557 |
-
st.write(planner_output)
|
558 |
-
else:
|
559 |
-
st.warning("No planner insights available.")
|
560 |
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
key_insights, data_insights = parse_analyst_output(analyst_output)
|
569 |
-
st.subheader("Structured Analyst Output")
|
570 |
-
st.write(data_insights)
|
571 |
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
|
579 |
-
|
580 |
-
|
581 |
|
582 |
-
|
583 |
-
|
584 |
|
585 |
# Notify user that the analysis is complete
|
586 |
st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
|
@@ -609,4 +613,4 @@ if st.button("Generate Patent Insights"):
|
|
609 |
except Exception as e:
|
610 |
error_message = traceback.format_exc()
|
611 |
logging.error(f"An error occurred during execution:\n{error_message}")
|
612 |
-
st.error(f"⚠️ An unexpected error occurred:\n{e}")
|
|
|
538 |
# Calculate elapsed time
|
539 |
elapsed_time = time.time() - start_time
|
540 |
|
541 |
+
# Extract Outputs
|
542 |
+
planner_output = getattr(results.tasks_output[0], "raw", "No details available.")
|
543 |
+
analyst_output = getattr(results.tasks_output[1], "raw", "No details available.")
|
544 |
writer_output = getattr(results.tasks_output[2], "raw", "No details available.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
545 |
|
546 |
+
# Organize outputs into tabs
|
547 |
+
tab1, tab2, tab3 = st.tabs(["📄 Final Report", "📝 Planner's Insights", "📊 Analyst's Analysis"])
|
|
|
|
|
|
|
|
|
|
|
548 |
|
549 |
+
# Final Report Tab
|
550 |
+
with tab1:
|
551 |
+
st.header("Final Patent Strategy Report")
|
552 |
+
if writer_output and writer_output.strip():
|
553 |
+
st.write(writer_output)
|
554 |
+
else:
|
555 |
+
st.warning("No final report available.")
|
|
|
|
|
|
|
556 |
|
557 |
+
# Planner's Insights Tab
|
558 |
+
with tab2:
|
559 |
+
st.header("Planner's Research Insights")
|
560 |
+
if planner_output and planner_output.strip():
|
561 |
+
st.write(planner_output)
|
562 |
+
else:
|
563 |
+
st.warning("No planner insights available.")
|
564 |
+
|
565 |
+
# Analyst's Analysis Tab
|
566 |
+
with tab3:
|
567 |
+
st.header("Analyst's Data Analysis")
|
568 |
+
if analyst_output and analyst_output.strip():
|
569 |
+
st.write(analyst_output)
|
570 |
+
|
571 |
+
# Parse Analyst Output (Key Insights + Data Insights)
|
572 |
+
key_insights, data_insights = parse_analyst_output(analyst_output)
|
573 |
+
st.subheader("Structured Analyst Output")
|
574 |
+
st.write(data_insights)
|
575 |
+
|
576 |
+
# Create Visualizations if enabled
|
577 |
+
charts = []
|
578 |
+
if enable_advanced_analysis and data_insights:
|
579 |
+
charts = create_visualizations(data_insights)
|
580 |
+
else:
|
581 |
+
st.info("No data insights available for visualizations.")
|
582 |
|
583 |
+
# Display Data Tables
|
584 |
+
table_data = display_table(data_insights)
|
585 |
|
586 |
+
else:
|
587 |
+
st.warning("No analyst analysis available.")
|
588 |
|
589 |
# Notify user that the analysis is complete
|
590 |
st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
|
|
|
613 |
except Exception as e:
|
614 |
error_message = traceback.format_exc()
|
615 |
logging.error(f"An error occurred during execution:\n{error_message}")
|
616 |
+
st.error(f"⚠️ An unexpected error occurred:\n{e}")
|