Ryan commited on
Commit
33f6fed
·
1 Parent(s): e41c9c7
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -3,6 +3,7 @@ from ui.dataset_input import create_dataset_input, load_example_dataset
3
  from ui.analysis_screen import create_analysis_screen, process_analysis_request
4
  import nltk
5
  import os
 
6
 
7
  # Download necessary NLTK data packages
8
  def download_nltk_resources():
@@ -111,8 +112,24 @@ def create_app():
111
  results, output = process_analysis_request(dataset, selected_analyses, params)
112
  print(f"Analysis completed: {results}")
113
 
114
- # Output is already a dictionary, don't try to access .value
115
- return results, gr.update(visible=True, value=output)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  except Exception as e:
117
  import traceback
118
  error_trace = traceback.format_exc()
 
3
  from ui.analysis_screen import create_analysis_screen, process_analysis_request
4
  import nltk
5
  import os
6
+ import json
7
 
8
  # Download necessary NLTK data packages
9
  def download_nltk_resources():
 
112
  results, output = process_analysis_request(dataset, selected_analyses, params)
113
  print(f"Analysis completed: {results}")
114
 
115
+ # Parse the output if it's a JSON string
116
+ if isinstance(output, dict) and "value" in output:
117
+ try:
118
+ # If value is a JSON string, parse it
119
+ if isinstance(output["value"], str):
120
+ parsed_value = json.loads(output["value"])
121
+ # Format the data nicely for display
122
+ formatted_output = {
123
+ "analyses": parsed_value.get("analyses", {})
124
+ }
125
+ return results, gr.update(visible=True, value=formatted_output)
126
+ else:
127
+ return results, output
128
+ except json.JSONDecodeError:
129
+ return results, output
130
+ else:
131
+ return results, output
132
+
133
  except Exception as e:
134
  import traceback
135
  error_trace = traceback.format_exc()