Skip to content

Commit ae2f4a8

Browse files
committed
Make variants internal
1 parent afa33f6 commit ae2f4a8

File tree

7 files changed

+58
-31
lines changed

7 files changed

+58
-31
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NoFactualInformationStepActions(Enum):
2626
class FactCheckingVariants:
2727
"""
2828
This class is used to define the possible options for fact-checking a step
29-
NOTE do not change steps directly
29+
NOTE do not change the variants directly
3030
"""
3131

3232
accurate_step: Variant = field(

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class StepReasoningVariants:
1717
"""
1818
This class is used to define the possible options for evaluating a step
1919
Currently the options are correct, neutral, and incorrect
20+
NOTE: do not change the variant values
2021
"""
2122

2223
correct_step: Variant = field(
@@ -33,7 +34,10 @@ class StepReasoningVariants:
3334
_available_actions={
3435
action.value for action in IncorrectStepActions
3536
},
36-
actions=["regenerateSteps"], # regenerateSteps is on by default
37+
actions=[
38+
IncorrectStepActions.REGENERATE_STEPS.value,
39+
IncorrectStepActions.GENERATE_AND_RATE_ALTERNATIVE_STEPS.value,
40+
], # action On by default
3741
)
3842
)
3943

@@ -102,6 +106,8 @@ class StepReasoningTool:
102106
"""
103107
Use this class in OntologyBuilder to create a tool for step reasoning
104108
The definition field lists the possible options to evaulate a step
109+
110+
NOTE: color attribute is for backward compatibility only and should not be set directly
105111
"""
106112

107113
name: str

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/integration/test_ontology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def test_step_reasoning_ontology(chat_evaluation_ontology):
340340
{
341341
"id": 2,
342342
"name": "Incorrect",
343-
"actions": ["regenerateSteps"],
343+
"actions": ["regenerateSteps", "generateAndRateAlternativeSteps"],
344344
},
345345
]
346346
assert step_reasoning_tool["definition"]["version"] == 1
@@ -365,7 +365,7 @@ def test_step_reasoning_ontology(chat_evaluation_ontology):
365365
{
366366
"id": 2,
367367
"name": "Incorrect",
368-
"actions": ["regenerateSteps"],
368+
"actions": ["regenerateSteps", "generateAndRateAlternativeSteps"],
369369
},
370370
]
371371

libs/labelbox/tests/unit/test_unit_fact_checking_tool.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from labelbox.schema.tool_building.fact_checking_tool import FactCheckingTool
2-
from labelbox.schema.tool_building.step_reasoning_tool import StepReasoningTool
32

43

54
def test_fact_checking_as_dict_default():
@@ -20,9 +19,21 @@ def test_fact_checking_as_dict_default():
2019
{"id": 0, "name": "Accurate"},
2120
{"id": 1, "name": "Inaccurate"},
2221
{"id": 2, "name": "Disputed"},
23-
{"id": 3, "name": "Unsupported", "actions": []},
24-
{"id": 4, "name": "Can't confidently assess", "actions": []},
25-
{"id": 5, "name": "No factual information", "actions": []},
22+
{
23+
"id": 3,
24+
"name": "Unsupported",
25+
"actions": ["writeJustification"],
26+
},
27+
{
28+
"id": 4,
29+
"name": "Can't confidently assess",
30+
"actions": ["writeJustification"],
31+
},
32+
{
33+
"id": 5,
34+
"name": "No factual information",
35+
"actions": ["writeJustification"],
36+
},
2637
],
2738
"version": 1,
2839
},
@@ -33,9 +44,9 @@ def test_fact_checking_as_dict_default():
3344

3445
def test_step_reasoning_as_dict_with_actions():
3546
tool = FactCheckingTool(name="Fact Checking Tool")
36-
tool.set_unsupported_step_actions()
37-
tool.set_cant_confidently_assess_step_actions()
38-
tool.set_no_factual_information_step_actions()
47+
tool.set_unsupported_step_actions([])
48+
tool.set_cant_confidently_assess_step_actions([])
49+
tool.set_no_factual_information_step_actions([])
3950

4051
# Get the dictionary representation
4152
tool_dict = tool.asdict()
@@ -55,17 +66,17 @@ def test_step_reasoning_as_dict_with_actions():
5566
{
5667
"id": 3,
5768
"name": "Unsupported",
58-
"actions": ["writeJustification"],
69+
"actions": [],
5970
},
6071
{
6172
"id": 4,
6273
"name": "Can't confidently assess",
63-
"actions": ["writeJustification"],
74+
"actions": [],
6475
},
6576
{
6677
"id": 5,
6778
"name": "No factual information",
68-
"actions": ["writeJustification"],
79+
"actions": [],
6980
},
7081
],
7182
"version": 1,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from labelbox.schema.tool_building.variant import VariantWithActions
2+
3+
4+
def test_variant_with_actions_as_dict():
5+
variant = VariantWithActions(
6+
id=0, name="Correct", _available_actions={"regenerateSteps"}
7+
)
8+
variant.set_actions(["regenerateSteps"])
9+
assert variant.asdict() == {
10+
"id": 0,
11+
"name": "Correct",
12+
"actions": ["regenerateSteps"],
13+
}
14+
variant.reset_actions()
15+
assert variant.asdict() == {
16+
"id": 0,
17+
"name": "Correct",
18+
"actions": [],
19+
}

libs/labelbox/tests/unit/test_unit_step_reasoning_tool.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22

33
from labelbox.schema.tool_building.step_reasoning_tool import (
4-
IncorrectStepActions,
54
StepReasoningTool,
65
)
76

@@ -26,7 +25,10 @@ def test_step_reasoning_as_dict_default():
2625
{
2726
"id": 2,
2827
"name": "Incorrect",
29-
"actions": ["regenerateSteps"],
28+
"actions": [
29+
"regenerateSteps",
30+
"generateAndRateAlternativeSteps",
31+
],
3032
},
3133
],
3234
"version": 1,
@@ -36,12 +38,7 @@ def test_step_reasoning_as_dict_default():
3638

3739
def test_step_reasoning_as_dict_with_actions():
3840
tool = StepReasoningTool(name="step reasoning")
39-
tool.set_incorrect_step_actions(
40-
[
41-
IncorrectStepActions.REGENERATE_STEPS,
42-
IncorrectStepActions.GENERATE_AND_RATE_ALTERNATIVE_STEPS,
43-
]
44-
)
41+
tool.set_incorrect_step_actions([])
4542
assert tool.asdict() == {
4643
"tool": "step-reasoning",
4744
"name": "step reasoning",

0 commit comments

Comments
 (0)