Skip to content

Commit a358455

Browse files
author
Val Brodsky
committed
Make variants internal
1 parent 97be398 commit a358455

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

libs/labelbox/src/labelbox/schema/tool_building/variant.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def asdict(self) -> Dict[str, Any]:
1616

1717

1818
@dataclass
19-
class VariantWithActions:
20-
id: int
21-
name: str
19+
class VariantWithActions(Variant):
2220
actions: List[str] = field(default_factory=list)
2321
_available_actions: Set[str] = field(default_factory=set)
2422

@@ -32,11 +30,7 @@ def reset_actions(self) -> None:
3230
self.actions = []
3331

3432
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
4135

4236
return data

libs/labelbox/tests/unit/test_unit_fact_checking_tool.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,47 @@ def test_fact_checking_as_dict_default():
4141
}
4242

4343
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

0 commit comments

Comments
 (0)