File tree Expand file tree Collapse file tree 2 files changed +47
-9
lines changed
src/labelbox/schema/tool_building Expand file tree Collapse file tree 2 files changed +47
-9
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,7 @@ def asdict(self) -> Dict[str, Any]:
16
16
17
17
18
18
@dataclass
19
- class VariantWithActions :
20
- id : int
21
- name : str
19
+ class VariantWithActions (Variant ):
22
20
actions : List [str ] = field (default_factory = list )
23
21
_available_actions : Set [str ] = field (default_factory = set )
24
22
@@ -32,11 +30,7 @@ def reset_actions(self) -> None:
32
30
self .actions = []
33
31
34
32
def asdict (self ) -> Dict [str , Any ]:
35
- data = {
36
- "id" : self .id ,
37
- "name" : self .name ,
38
- }
39
- if len (self .actions ) > 0 :
40
- data ["actions" ] = self .actions
33
+ data = super ().asdict ()
34
+ data ["actions" ] = self .actions
41
35
42
36
return data
Original file line number Diff line number Diff line change @@ -41,3 +41,47 @@ def test_fact_checking_as_dict_default():
41
41
}
42
42
43
43
assert tool_dict == expected_dict
44
+
45
+
46
+ def test_step_reasoning_as_dict_with_actions ():
47
+ tool = FactCheckingTool (name = "Fact Checking Tool" )
48
+ tool .set_unsupported_step_actions ([])
49
+ tool .set_cant_confidently_assess_step_actions ([])
50
+ tool .set_no_factual_information_step_actions ([])
51
+
52
+ # Get the dictionary representation
53
+ tool_dict = tool .asdict ()
54
+
55
+ # Expected dictionary structure
56
+ expected_dict = {
57
+ "tool" : "fact-checking" ,
58
+ "name" : "Fact Checking Tool" ,
59
+ "required" : False ,
60
+ "schemaNodeId" : None ,
61
+ "featureSchemaId" : None ,
62
+ "definition" : {
63
+ "variants" : [
64
+ {"id" : 0 , "name" : "Accurate" },
65
+ {"id" : 1 , "name" : "Inaccurate" },
66
+ {"id" : 2 , "name" : "Disputed" },
67
+ {
68
+ "id" : 3 ,
69
+ "name" : "Unsupported" ,
70
+ "actions" : [],
71
+ },
72
+ {
73
+ "id" : 4 ,
74
+ "name" : "Can't confidently assess" ,
75
+ "actions" : [],
76
+ },
77
+ {
78
+ "id" : 5 ,
79
+ "name" : "No factual information" ,
80
+ "actions" : [],
81
+ },
82
+ ],
83
+ "version" : 1 ,
84
+ },
85
+ }
86
+
87
+ assert tool_dict == expected_dict
You can’t perform that action at this time.
0 commit comments