Spaces:
Runtime error
Runtime error
Update output_parser.py
Browse files- output_parser.py +9 -14
output_parser.py
CHANGED
@@ -57,23 +57,18 @@ class OutputParser:
|
|
57 |
attachment_styles = obj.get("Attachment Styles", {})
|
58 |
big_five_traits = obj.get("Big Five Traits", {})
|
59 |
personality_disorders = obj.get("Personality Disorders", {})
|
60 |
-
|
61 |
# Handle general_impression as a string
|
62 |
-
general_impression = obj.get("General Impression",
|
63 |
if isinstance(general_impression, dict):
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
# If it parses successfully, it's likely a JSON string, so we'll keep it as is
|
70 |
-
except json.JSONDecodeError:
|
71 |
-
# If it's not a valid JSON string, we'll keep it as is (it's already a string)
|
72 |
-
pass
|
73 |
-
|
74 |
return SpeakerAnalysis(
|
75 |
-
speaker=obj.get("Speaker", "Unknown Speaker"),
|
76 |
-
general_impression=
|
77 |
attachment_style=AttachmentStyle(
|
78 |
secured=attachment_styles.get("Secured", 0.0),
|
79 |
anxious_preoccupied=attachment_styles.get("Anxious-Preoccupied", 0.0),
|
|
|
57 |
attachment_styles = obj.get("Attachment Styles", {})
|
58 |
big_five_traits = obj.get("Big Five Traits", {})
|
59 |
personality_disorders = obj.get("Personality Disorders", {})
|
60 |
+
|
61 |
# Handle general_impression as a string
|
62 |
+
general_impression = obj.get("General Impression", {})
|
63 |
if isinstance(general_impression, dict):
|
64 |
+
# Convert the dictionary to a formatted string
|
65 |
+
general_impression_str = "\n".join([f"{key}: {value}" for key, value in general_impression.items()])
|
66 |
+
else:
|
67 |
+
general_impression_str = str(general_impression)
|
68 |
+
|
|
|
|
|
|
|
|
|
|
|
69 |
return SpeakerAnalysis(
|
70 |
+
speaker=str(obj.get("Speaker", "Unknown Speaker")), # Convert to string
|
71 |
+
general_impression=general_impression_str,
|
72 |
attachment_style=AttachmentStyle(
|
73 |
secured=attachment_styles.get("Secured", 0.0),
|
74 |
anxious_preoccupied=attachment_styles.get("Anxious-Preoccupied", 0.0),
|