5
5
6
6
from labelbox .schema .tool_building .tool_type import ToolType
7
7
from labelbox .schema .tool_building .variant import (
8
- Variant ,
9
8
VariantWithActions ,
10
9
)
11
10
12
11
12
+ class FactCheckingActions (Enum ):
13
+ WRITE_JUSTIFICATION = "writeJustification"
14
+
15
+
13
16
class UnsupportedStepActions (Enum ):
14
17
WRITE_JUSTIFICATION = "writeJustification"
15
18
@@ -29,43 +32,53 @@ class FactCheckingVariants:
29
32
NOTE do not change the variants directly
30
33
"""
31
34
32
- accurate_step : Variant = field (
33
- default_factory = lambda : Variant (id = 0 , name = "Accurate" )
35
+ accurate_step : VariantWithActions = field (
36
+ default_factory = lambda : VariantWithActions (
37
+ id = 0 ,
38
+ name = "Accurate" ,
39
+ _available_actions = {action .value for action in FactCheckingActions },
40
+ actions = [action .value for action in FactCheckingActions ],
41
+ )
34
42
)
35
- inaccurate_step : Variant = field (
36
- default_factory = lambda : Variant (id = 1 , name = "Inaccurate" )
43
+
44
+ inaccurate_step : VariantWithActions = field (
45
+ default_factory = lambda : VariantWithActions (
46
+ id = 1 ,
47
+ name = "Inaccurate" ,
48
+ _available_actions = {action .value for action in FactCheckingActions },
49
+ actions = [action .value for action in FactCheckingActions ],
50
+ )
37
51
)
38
- disputed_step : Variant = field (
39
- default_factory = lambda : Variant (id = 2 , name = "Disputed" )
52
+ disputed_step : VariantWithActions = field (
53
+ default_factory = lambda : VariantWithActions (
54
+ id = 2 ,
55
+ name = "Disputed" ,
56
+ _available_actions = {action .value for action in FactCheckingActions },
57
+ actions = [action .value for action in FactCheckingActions ],
58
+ )
40
59
)
41
60
unsupported_step : VariantWithActions = field (
42
61
default_factory = lambda : VariantWithActions (
43
62
id = 3 ,
44
63
name = "Unsupported" ,
45
- _available_actions = {
46
- action .value for action in UnsupportedStepActions
47
- },
48
- actions = [UnsupportedStepActions .WRITE_JUSTIFICATION .value ],
64
+ _available_actions = set (),
65
+ actions = [],
49
66
)
50
67
)
51
68
cant_confidently_assess_step : VariantWithActions = field (
52
69
default_factory = lambda : VariantWithActions (
53
70
id = 4 ,
54
71
name = "Can't confidently assess" ,
55
- _available_actions = {
56
- action .value for action in CanConfidentlyAssessStepActions
57
- },
58
- actions = [CanConfidentlyAssessStepActions .WRITE_JUSTIFICATION .value ],
72
+ _available_actions = set (),
73
+ actions = [],
59
74
)
60
75
)
61
76
no_factual_information_step : VariantWithActions = field (
62
77
default_factory = lambda : VariantWithActions (
63
78
id = 5 ,
64
79
name = "No factual information" ,
65
- _available_actions = {
66
- action .value for action in NoFactualInformationStepActions
67
- },
68
- actions = [NoFactualInformationStepActions .WRITE_JUSTIFICATION .value ],
80
+ _available_actions = set (),
81
+ actions = [],
69
82
)
70
83
)
71
84
@@ -90,11 +103,11 @@ def from_dict(cls, dictionary: List[Dict[str, Any]]):
90
103
91
104
for variant in dictionary :
92
105
if variant ["id" ] == 0 :
93
- accurate_step = Variant (** variant )
106
+ accurate_step = VariantWithActions (** variant )
94
107
elif variant ["id" ] == 1 :
95
- inaccurate_step = Variant (** variant )
108
+ inaccurate_step = VariantWithActions (** variant )
96
109
elif variant ["id" ] == 2 :
97
- disputed_step = Variant (** variant )
110
+ disputed_step = VariantWithActions (** variant )
98
111
elif variant ["id" ] == 3 :
99
112
unsupported_step = VariantWithActions (** variant )
100
113
elif variant ["id" ] == 4 :
@@ -126,6 +139,12 @@ def from_dict(cls, dictionary: List[Dict[str, Any]]):
126
139
127
140
@dataclass
128
141
class FactCheckingDefinition :
142
+ name : str
143
+ type : ToolType = field (default = ToolType .FACT_CHECKING , init = False )
144
+ required : bool = False
145
+ schema_id : Optional [str ] = None
146
+ feature_schema_id : Optional [str ] = None
147
+ color : Optional [str ] = None
129
148
variants : FactCheckingVariants = field (default_factory = FactCheckingVariants )
130
149
version : int = field (default = 1 )
131
150
title : Optional [str ] = None
@@ -145,10 +164,11 @@ def asdict(self) -> Dict[str, Any]:
145
164
146
165
@classmethod
147
166
def from_dict (cls , dictionary : Dict [str , Any ]) -> "FactCheckingDefinition" :
167
+ name = dictionary ["name" ]
148
168
variants = FactCheckingVariants .from_dict (dictionary ["variants" ])
149
169
title = dictionary .get ("title" , None )
150
170
value = dictionary .get ("value" , None )
151
- return cls (variants = variants , title = title , value = value )
171
+ return cls (name = name , variants = variants , title = title , value = value )
152
172
153
173
154
174
@dataclass
0 commit comments