Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -520,15 +520,41 @@ def parse_analyst_output(raw_output):
|
|
520 |
|
521 |
return key_insights, data_insights
|
522 |
|
523 |
-
|
524 |
# Main Execution Block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
if st.button("Generate Patent Insights"):
|
526 |
with st.spinner('Processing...'):
|
527 |
try:
|
528 |
# Start the timer
|
529 |
start_time = time.time()
|
530 |
|
531 |
-
#
|
532 |
if not patent_area or not stakeholder:
|
533 |
st.error("Please provide both Patent Technology Area and Stakeholder.")
|
534 |
else:
|
@@ -543,11 +569,6 @@ if st.button("Generate Patent Insights"):
|
|
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 |
-
# Initialize placeholders for charts and tables
|
547 |
-
charts = []
|
548 |
-
table_data = []
|
549 |
-
key_insights, data_insights = [], []
|
550 |
-
|
551 |
# Parse Analyst Output (Key Insights + Data Insights)
|
552 |
if analyst_output and analyst_output.strip():
|
553 |
key_insights, data_insights = parse_analyst_output(analyst_output)
|
@@ -561,8 +582,7 @@ if st.button("Generate Patent Insights"):
|
|
561 |
# Display Data Tables
|
562 |
table_data = display_table(data_insights)
|
563 |
|
564 |
-
#
|
565 |
-
tab1, tab2, tab3 = st.tabs(["π Final Report", "π Planner's Insights", "π Analyst's Analysis"])
|
566 |
|
567 |
# Final Report Tab
|
568 |
with tab1:
|
@@ -586,14 +606,24 @@ if st.button("Generate Patent Insights"):
|
|
586 |
if analyst_output and analyst_output.strip():
|
587 |
st.write(analyst_output)
|
588 |
|
589 |
-
#
|
590 |
st.subheader("Structured Analyst Output")
|
591 |
st.write(data_insights)
|
592 |
|
593 |
-
# Visualizations
|
594 |
-
|
595 |
-
|
|
|
|
|
|
|
|
|
596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
else:
|
598 |
st.warning("No analyst analysis available.")
|
599 |
|
@@ -625,3 +655,4 @@ if st.button("Generate Patent Insights"):
|
|
625 |
error_message = traceback.format_exc()
|
626 |
logging.error(f"An error occurred during execution:\n{error_message}")
|
627 |
st.error(f"β οΈ An unexpected error occurred:\n{e}")
|
|
|
|
520 |
|
521 |
return key_insights, data_insights
|
522 |
|
|
|
523 |
# Main Execution Block
|
524 |
+
# Initialize placeholders for outputs to ensure tabs are always visible
|
525 |
+
planner_output = "Planner insights will appear here after generating insights."
|
526 |
+
analyst_output = "Analyst data will appear here after generating insights."
|
527 |
+
writer_output = "Final report will appear here after generating insights."
|
528 |
+
charts = []
|
529 |
+
table_data = []
|
530 |
+
key_insights, data_insights = [], []
|
531 |
+
|
532 |
+
# Create tabs at the start so they are always visible
|
533 |
+
tab1, tab2, tab3 = st.tabs(["π Final Report", "π Planner's Insights", "π Analyst's Analysis"])
|
534 |
+
|
535 |
+
# Final Report Tab (Initial State)
|
536 |
+
with tab1:
|
537 |
+
st.header("Final Patent Strategy Report")
|
538 |
+
st.info(writer_output)
|
539 |
+
|
540 |
+
# Planner's Insights Tab (Initial State)
|
541 |
+
with tab2:
|
542 |
+
st.header("Planner's Research Insights")
|
543 |
+
st.info(planner_output)
|
544 |
+
|
545 |
+
# Analyst's Analysis Tab (Initial State)
|
546 |
+
with tab3:
|
547 |
+
st.header("Analyst's Data Analysis")
|
548 |
+
st.info(analyst_output)
|
549 |
+
|
550 |
+
# Button to Generate Insights
|
551 |
if st.button("Generate Patent Insights"):
|
552 |
with st.spinner('Processing...'):
|
553 |
try:
|
554 |
# Start the timer
|
555 |
start_time = time.time()
|
556 |
|
557 |
+
# Validate user inputs
|
558 |
if not patent_area or not stakeholder:
|
559 |
st.error("Please provide both Patent Technology Area and Stakeholder.")
|
560 |
else:
|
|
|
569 |
analyst_output = getattr(results.tasks_output[1], "raw", "No details available.")
|
570 |
writer_output = getattr(results.tasks_output[2], "raw", "No details available.")
|
571 |
|
|
|
|
|
|
|
|
|
|
|
572 |
# Parse Analyst Output (Key Insights + Data Insights)
|
573 |
if analyst_output and analyst_output.strip():
|
574 |
key_insights, data_insights = parse_analyst_output(analyst_output)
|
|
|
582 |
# Display Data Tables
|
583 |
table_data = display_table(data_insights)
|
584 |
|
585 |
+
# Update Tabs with Results
|
|
|
586 |
|
587 |
# Final Report Tab
|
588 |
with tab1:
|
|
|
606 |
if analyst_output and analyst_output.strip():
|
607 |
st.write(analyst_output)
|
608 |
|
609 |
+
# Structured Analyst Output
|
610 |
st.subheader("Structured Analyst Output")
|
611 |
st.write(data_insights)
|
612 |
|
613 |
+
# Visualizations Section
|
614 |
+
if charts:
|
615 |
+
st.subheader("Generated Visualizations")
|
616 |
+
for chart_path in charts:
|
617 |
+
st.image(chart_path, use_column_width=True)
|
618 |
+
else:
|
619 |
+
st.info("No visualizations generated.")
|
620 |
|
621 |
+
# Data Tables Section
|
622 |
+
if table_data:
|
623 |
+
st.subheader("Detailed Data Tables")
|
624 |
+
st.write(table_data)
|
625 |
+
else:
|
626 |
+
st.info("No data tables generated.")
|
627 |
else:
|
628 |
st.warning("No analyst analysis available.")
|
629 |
|
|
|
655 |
error_message = traceback.format_exc()
|
656 |
logging.error(f"An error occurred during execution:\n{error_message}")
|
657 |
st.error(f"β οΈ An unexpected error occurred:\n{e}")
|
658 |
+
|