Spaces:
Runtime error
Runtime error
Update output_parser.py
Browse files- output_parser.py +14 -14
output_parser.py
CHANGED
@@ -2,20 +2,13 @@ from typing import List, Optional
|
|
2 |
from pydantic import BaseModel, Field
|
3 |
import json
|
4 |
|
5 |
-
class SpeakerAnalysis(BaseModel):
|
6 |
-
Speaker: str = "Unknown Speaker"
|
7 |
-
GeneralImpression: str = "No general impression provided"
|
8 |
-
AttachmentStyle: Optional['AttachmentStyle'] = None
|
9 |
-
BigFiveTraits: Optional['BigFiveTraits'] = None
|
10 |
-
PersonalityDisorder: Optional['PersonalityDisorder'] = None
|
11 |
-
|
12 |
class AttachmentStyle(BaseModel):
|
13 |
-
Secured: float =
|
14 |
Anxious_Preoccupied: float = Field(0.0, alias="Anxious-Preoccupied")
|
15 |
Dismissive_Avoidant: float = Field(0.0, alias="Dismissive-Avoidant")
|
16 |
Fearful_Avoidant: float = Field(0.0, alias="Fearful-Avoidant")
|
17 |
-
Self: int =
|
18 |
-
Others: int =
|
19 |
Anxiety: int = 0
|
20 |
Avoidance: int = 0
|
21 |
Explanation: str = "No explanation provided"
|
@@ -40,6 +33,13 @@ class PersonalityDisorder(BaseModel):
|
|
40 |
Obsessional: int = 0
|
41 |
Explanation: str = "No explanation provided"
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
class OutputParser:
|
44 |
def parse(self, text: str) -> List[SpeakerAnalysis]:
|
45 |
try:
|
@@ -56,10 +56,10 @@ class OutputParser:
|
|
56 |
def parse_speaker_analysis(self, obj: dict) -> SpeakerAnalysis:
|
57 |
return SpeakerAnalysis(
|
58 |
Speaker=obj.get("Speaker", "Unknown Speaker"),
|
59 |
-
GeneralImpression=obj.get("
|
60 |
-
AttachmentStyle=AttachmentStyle(**obj.get("
|
61 |
-
BigFiveTraits=BigFiveTraits(**obj.get("
|
62 |
-
PersonalityDisorder=PersonalityDisorder(**obj.get("
|
63 |
)
|
64 |
|
65 |
def get_format_instructions(self) -> str:
|
|
|
2 |
from pydantic import BaseModel, Field
|
3 |
import json
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
class AttachmentStyle(BaseModel):
|
6 |
+
Secured: float = 0.0
|
7 |
Anxious_Preoccupied: float = Field(0.0, alias="Anxious-Preoccupied")
|
8 |
Dismissive_Avoidant: float = Field(0.0, alias="Dismissive-Avoidant")
|
9 |
Fearful_Avoidant: float = Field(0.0, alias="Fearful-Avoidant")
|
10 |
+
Self: int = 0
|
11 |
+
Others: int = 0
|
12 |
Anxiety: int = 0
|
13 |
Avoidance: int = 0
|
14 |
Explanation: str = "No explanation provided"
|
|
|
33 |
Obsessional: int = 0
|
34 |
Explanation: str = "No explanation provided"
|
35 |
|
36 |
+
class SpeakerAnalysis(BaseModel):
|
37 |
+
Speaker: str = "Unknown Speaker"
|
38 |
+
GeneralImpression: str = "No general impression provided"
|
39 |
+
AttachmentStyle: AttachmentStyle = AttachmentStyle()
|
40 |
+
BigFiveTraits: BigFiveTraits = BigFiveTraits()
|
41 |
+
PersonalityDisorder: PersonalityDisorder = PersonalityDisorder()
|
42 |
+
|
43 |
class OutputParser:
|
44 |
def parse(self, text: str) -> List[SpeakerAnalysis]:
|
45 |
try:
|
|
|
56 |
def parse_speaker_analysis(self, obj: dict) -> SpeakerAnalysis:
|
57 |
return SpeakerAnalysis(
|
58 |
Speaker=obj.get("Speaker", "Unknown Speaker"),
|
59 |
+
GeneralImpression=obj.get("General Impression", "No general impression provided"),
|
60 |
+
AttachmentStyle=AttachmentStyle(**(obj.get("Attachment Styles", {}))),
|
61 |
+
BigFiveTraits=BigFiveTraits(**(obj.get("Big Five Traits", {}))),
|
62 |
+
PersonalityDisorder=PersonalityDisorder(**(obj.get("Personality Disorders", {})))
|
63 |
)
|
64 |
|
65 |
def get_format_instructions(self) -> str:
|