Skip to content

Commit 0f3169f

Browse files
author
Val Brodsky
committed
Update FactCheckingTool to match the latest api
1 parent 11e89eb commit 0f3169f

File tree

2 files changed

+47
-34
lines changed

2 files changed

+47
-34
lines changed

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

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55

66
from labelbox.schema.tool_building.tool_type import ToolType
77
from labelbox.schema.tool_building.variant import (
8-
Variant,
98
VariantWithActions,
109
)
1110

1211

12+
class FactCheckingActions(Enum):
13+
WRITE_JUSTIFICATION = "justification"
14+
15+
1316
class UnsupportedStepActions(Enum):
14-
WRITE_JUSTIFICATION = "writeJustification"
17+
WRITE_JUSTIFICATION = "justification"
1518

1619

1720
class CanConfidentlyAssessStepActions(Enum):
18-
WRITE_JUSTIFICATION = "writeJustification"
21+
WRITE_JUSTIFICATION = "justification"
1922

2023

2124
class NoFactualInformationStepActions(Enum):
22-
WRITE_JUSTIFICATION = "writeJustification"
25+
WRITE_JUSTIFICATION = "justification"
2326

2427

2528
@dataclass
@@ -29,43 +32,53 @@ class FactCheckingVariants:
2932
NOTE do not change the variants directly
3033
"""
3134

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+
)
3442
)
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+
)
3751
)
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+
)
4059
)
4160
unsupported_step: VariantWithActions = field(
4261
default_factory=lambda: VariantWithActions(
4362
id=3,
4463
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=[],
4966
)
5067
)
5168
cant_confidently_assess_step: VariantWithActions = field(
5269
default_factory=lambda: VariantWithActions(
5370
id=4,
5471
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=[],
5974
)
6075
)
6176
no_factual_information_step: VariantWithActions = field(
6277
default_factory=lambda: VariantWithActions(
6378
id=5,
6479
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=[],
6982
)
7083
)
7184

@@ -90,11 +103,11 @@ def from_dict(cls, dictionary: List[Dict[str, Any]]):
90103

91104
for variant in dictionary:
92105
if variant["id"] == 0:
93-
accurate_step = Variant(**variant)
106+
accurate_step = VariantWithActions(**variant)
94107
elif variant["id"] == 1:
95-
inaccurate_step = Variant(**variant)
108+
inaccurate_step = VariantWithActions(**variant)
96109
elif variant["id"] == 2:
97-
disputed_step = Variant(**variant)
110+
disputed_step = VariantWithActions(**variant)
98111
elif variant["id"] == 3:
99112
unsupported_step = VariantWithActions(**variant)
100113
elif variant["id"] == 4:

libs/labelbox/tests/unit/test_unit_fact_checking_tool.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ def test_fact_checking_as_dict_default():
1616
"featureSchemaId": None,
1717
"definition": {
1818
"variants": [
19-
{"id": 0, "name": "Accurate"},
20-
{"id": 1, "name": "Inaccurate"},
21-
{"id": 2, "name": "Disputed"},
19+
{"id": 0, "name": "Accurate", "actions": ["justification"]},
20+
{"id": 1, "name": "Inaccurate", "actions": ["justification"]},
21+
{"id": 2, "name": "Disputed", "actions": ["justification"]},
2222
{
2323
"id": 3,
2424
"name": "Unsupported",
25-
"actions": ["writeJustification"],
25+
"actions": [],
2626
},
2727
{
2828
"id": 4,
2929
"name": "Can't confidently assess",
30-
"actions": ["writeJustification"],
30+
"actions": [],
3131
},
3232
{
3333
"id": 5,
3434
"name": "No factual information",
35-
"actions": ["writeJustification"],
35+
"actions": [],
3636
},
3737
],
3838
"version": 1,
@@ -60,9 +60,9 @@ def test_step_reasoning_as_dict_with_actions():
6060
"featureSchemaId": None,
6161
"definition": {
6262
"variants": [
63-
{"id": 0, "name": "Accurate"},
64-
{"id": 1, "name": "Inaccurate"},
65-
{"id": 2, "name": "Disputed"},
63+
{"id": 0, "name": "Accurate", "actions": ["justification"]},
64+
{"id": 1, "name": "Inaccurate", "actions": ["justification"]},
65+
{"id": 2, "name": "Disputed", "actions": ["justification"]},
6666
{
6767
"id": 3,
6868
"name": "Unsupported",

0 commit comments

Comments
 (0)