reab5555 commited on
Commit
94d45ff
·
verified ·
1 Parent(s): e464649

Update output_parser.py

Browse files
Files changed (1) hide show
  1. 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", "No general impression provided")
63
  if isinstance(general_impression, dict):
64
- general_impression = json.dumps(general_impression)
65
- elif isinstance(general_impression, str):
66
- try:
67
- # Check if it's a JSON string
68
- json.loads(general_impression)
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=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),