Spaces:
Runtime error
Runtime error
Update output_parser.py
Browse files- output_parser.py +35 -3
output_parser.py
CHANGED
@@ -54,12 +54,44 @@ class OutputParser:
|
|
54 |
raise ValueError(f"Error parsing output: {str(e)}")
|
55 |
|
56 |
def parse_speaker_analysis(self, obj: dict) -> SpeakerAnalysis:
|
|
|
|
|
|
|
|
|
57 |
return SpeakerAnalysis(
|
58 |
speaker=obj.get("Speaker", "Unknown Speaker"),
|
59 |
general_impression=obj.get("General Impression", "No general impression provided"),
|
60 |
-
attachment_style=AttachmentStyle(
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
)
|
64 |
|
65 |
output_parser = OutputParser()
|
|
|
54 |
raise ValueError(f"Error parsing output: {str(e)}")
|
55 |
|
56 |
def parse_speaker_analysis(self, obj: dict) -> SpeakerAnalysis:
|
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 |
return SpeakerAnalysis(
|
62 |
speaker=obj.get("Speaker", "Unknown Speaker"),
|
63 |
general_impression=obj.get("General Impression", "No general impression provided"),
|
64 |
+
attachment_style=AttachmentStyle(
|
65 |
+
secured=attachment_styles.get("Secured", 0.0),
|
66 |
+
anxious_preoccupied=attachment_styles.get("Anxious-Preoccupied", 0.0),
|
67 |
+
dismissive_avoidant=attachment_styles.get("Dismissive-Avoidant", 0.0),
|
68 |
+
fearful_avoidant=attachment_styles.get("Fearful-Avoidant", 0.0),
|
69 |
+
self_model=attachment_styles.get("Self", 0),
|
70 |
+
others_model=attachment_styles.get("Others", 0),
|
71 |
+
anxiety=attachment_styles.get("Anxiety", 0),
|
72 |
+
avoidance=attachment_styles.get("Avoidance", 0),
|
73 |
+
explanation=attachment_styles.get("Explanation", "No explanation provided")
|
74 |
+
),
|
75 |
+
big_five_traits=BigFiveTraits(
|
76 |
+
extraversion=big_five_traits.get("Extraversion", 0),
|
77 |
+
agreeableness=big_five_traits.get("Agreeableness", 0),
|
78 |
+
conscientiousness=big_five_traits.get("Conscientiousness", 0),
|
79 |
+
neuroticism=big_five_traits.get("Neuroticism", 0),
|
80 |
+
openness=big_five_traits.get("Openness", 0),
|
81 |
+
explanation=big_five_traits.get("Explanation", "No explanation provided")
|
82 |
+
),
|
83 |
+
personality_disorder=PersonalityDisorder(
|
84 |
+
depressed=personality_disorders.get("Depressed", 0),
|
85 |
+
paranoid=personality_disorders.get("Paranoid", 0),
|
86 |
+
schizoid_schizotypal=personality_disorders.get("Schizoid-Schizotypal", 0),
|
87 |
+
antisocial_psychopathic=personality_disorders.get("Antisocial-Psychopathic", 0),
|
88 |
+
borderline_dysregulated=personality_disorders.get("Borderline-Dysregulated", 0),
|
89 |
+
narcissistic=personality_disorders.get("Narcissistic", 0),
|
90 |
+
anxious_avoidant=personality_disorders.get("Anxious-Avoidant", 0),
|
91 |
+
dependent_victimized=personality_disorders.get("Dependent-Victimized", 0),
|
92 |
+
obsessional=personality_disorders.get("Obsessional", 0),
|
93 |
+
explanation=personality_disorders.get("Explanation", "No explanation provided")
|
94 |
+
)
|
95 |
)
|
96 |
|
97 |
output_parser = OutputParser()
|