Skip to content

Commit 4fce5b0

Browse files
author
Val Brodsky
committed
Make variants internal
1 parent 9081058 commit 4fce5b0

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
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: 2 additions & 7 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,10 +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-
}
33+
data = super().asdict()
3934
if len(self.actions) > 0:
4035
data["actions"] = self.actions
4136

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: 0 additions & 1 deletion
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():
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

0 commit comments

Comments
 (0)