DrishtiSharma commited on
Commit
25fd95c
·
verified ·
1 Parent(s): 368c5c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -390,18 +390,26 @@ def parse_analyst_output(raw_output):
390
  key_insights = []
391
  data_insights = []
392
 
393
- structured_data = ast.literal_eval(raw_output) if isinstance(raw_output, str) else raw_output
394
-
395
- for item in structured_data:
396
- if item.get("Type") == "Key Insight":
397
- key_insights.append(item["Values"])
398
- elif item.get("Type") == "Data Insight":
399
- data_insights.append(item)
400
- else:
401
- data_insights.append(item)
 
 
 
 
 
 
 
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...'):