Spaces:
Runtime error
Runtime error
Update processing.py
Browse files- processing.py +14 -0
processing.py
CHANGED
@@ -170,6 +170,20 @@ Analysis:"""
|
|
170 |
for i, speaker_analysis in enumerate(speaker_analyses, 1):
|
171 |
speaker_id = f"Speaker {i}"
|
172 |
parsed_analysis = output_parser.parse_speaker_analysis(speaker_analysis)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
results[speaker_id] = {
|
174 |
'general_impression': general_impression,
|
175 |
'attachments': parsed_analysis.attachment_style,
|
|
|
170 |
for i, speaker_analysis in enumerate(speaker_analyses, 1):
|
171 |
speaker_id = f"Speaker {i}"
|
172 |
parsed_analysis = output_parser.parse_speaker_analysis(speaker_analysis)
|
173 |
+
|
174 |
+
# Convert general_impression to string if it's a dict or JSON object
|
175 |
+
general_impression = parsed_analysis.general_impression
|
176 |
+
if isinstance(general_impression, dict):
|
177 |
+
general_impression = json.dumps(general_impression)
|
178 |
+
elif isinstance(general_impression, str):
|
179 |
+
try:
|
180 |
+
# Check if it's a JSON string
|
181 |
+
json.loads(general_impression)
|
182 |
+
# If it parses successfully, it's likely a JSON string, so we'll keep it as is
|
183 |
+
except json.JSONDecodeError:
|
184 |
+
# If it's not a valid JSON string, we'll keep it as is (it's already a string)
|
185 |
+
pass
|
186 |
+
|
187 |
results[speaker_id] = {
|
188 |
'general_impression': general_impression,
|
189 |
'attachments': parsed_analysis.attachment_style,
|