Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -390,18 +390,26 @@ def parse_analyst_output(raw_output):
|
|
390 |
key_insights = []
|
391 |
data_insights = []
|
392 |
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
|
403 |
return key_insights, data_insights
|
404 |
|
|
|
405 |
# Main Execution Block
|
406 |
if st.button("Generate Patent Insights"):
|
407 |
with st.spinner('Processing...'):
|
|
|
390 |
key_insights = []
|
391 |
data_insights = []
|
392 |
|
393 |
+
try:
|
394 |
+
structured_data = ast.literal_eval(raw_output) if isinstance(raw_output, str) else raw_output
|
395 |
+
|
396 |
+
for item in structured_data:
|
397 |
+
if "Category" not in item:
|
398 |
+
logging.warning(f"Missing 'Category' in item: {item}")
|
399 |
+
continue
|
400 |
+
|
401 |
+
if item.get("Type") == "Key Insight":
|
402 |
+
key_insights.append(item["Values"])
|
403 |
+
elif item.get("Type") == "Data Insight":
|
404 |
+
data_insights.append(item)
|
405 |
+
else:
|
406 |
+
data_insights.append(item)
|
407 |
+
except Exception as e:
|
408 |
+
logging.error(f"Error parsing analyst output: {e}")
|
409 |
|
410 |
return key_insights, data_insights
|
411 |
|
412 |
+
|
413 |
# Main Execution Block
|
414 |
if st.button("Generate Patent Insights"):
|
415 |
with st.spinner('Processing...'):
|