Skip to content

Commit cdf6552

Browse files
author
Val Brodsky
committed
Port latest updates to step reasoning
1 parent ae2f4a8 commit cdf6552

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
from typing import Any, Dict, List, Optional
55

66
from labelbox.schema.tool_building.tool_type import ToolType
7-
from labelbox.schema.tool_building.variant import Variant, VariantWithActions
7+
from labelbox.schema.tool_building.variant import VariantWithActions
88

99

1010
class IncorrectStepActions(Enum):
1111
REGENERATE_STEPS = "regenerateSteps"
1212
GENERATE_AND_RATE_ALTERNATIVE_STEPS = "generateAndRateAlternativeSteps"
13+
REWRITE_STEP = "rewriteStep"
14+
JUSTIFICATION = "justification"
1315

1416

1517
@dataclass
@@ -20,11 +22,19 @@ class StepReasoningVariants:
2022
NOTE: do not change the variant values
2123
"""
2224

23-
correct_step: Variant = field(
24-
default_factory=lambda: Variant(id=0, name="Correct")
25+
correct_step: VariantWithActions = field(
26+
default_factory=lambda: VariantWithActions(
27+
id=0,
28+
name="Correct",
29+
actions=[],
30+
)
2531
)
26-
neutral_step: Variant = field(
27-
default_factory=lambda: Variant(id=1, name="Neutral")
32+
neutral_step: VariantWithActions = field(
33+
default_factory=lambda: VariantWithActions(
34+
id=1,
35+
name="Neutral",
36+
actions=[],
37+
)
2838
)
2939

3040
incorrect_step: VariantWithActions = field(
@@ -35,9 +45,8 @@ class StepReasoningVariants:
3545
action.value for action in IncorrectStepActions
3646
},
3747
actions=[
38-
IncorrectStepActions.REGENERATE_STEPS.value,
39-
IncorrectStepActions.GENERATE_AND_RATE_ALTERNATIVE_STEPS.value,
40-
], # action On by default
48+
action.value for action in IncorrectStepActions
49+
], # initialize to all IncorrectStepActions by default
4150
)
4251
)
4352

@@ -56,9 +65,9 @@ def from_dict(cls, dictionary: List[Dict[str, Any]]):
5665

5766
for variant in dictionary:
5867
if variant["id"] == 0:
59-
correct_step = Variant(**variant)
68+
correct_step = VariantWithActions(**variant)
6069
elif variant["id"] == 1:
61-
neutral_step = Variant(**variant)
70+
neutral_step = VariantWithActions(**variant)
6271
elif variant["id"] == 2:
6372
incorrect_step = VariantWithActions(**variant)
6473

libs/labelbox/tests/integration/test_ontology.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,17 @@ def test_step_reasoning_ontology(chat_evaluation_ontology):
335335
break
336336
assert step_reasoning_tool is not None
337337
assert step_reasoning_tool["definition"]["variants"] == [
338-
{"id": 0, "name": "Correct"},
339-
{"id": 1, "name": "Neutral"},
338+
{"id": 0, "name": "Correct", "actions": []},
339+
{"id": 1, "name": "Neutral", "actions": []},
340340
{
341341
"id": 2,
342342
"name": "Incorrect",
343-
"actions": ["regenerateSteps", "generateAndRateAlternativeSteps"],
343+
"actions": [
344+
"regenerateSteps",
345+
"generateAndRateAlternativeSteps",
346+
"rewriteStep",
347+
"justification",
348+
],
344349
},
345350
]
346351
assert step_reasoning_tool["definition"]["version"] == 1
@@ -357,15 +362,22 @@ def test_step_reasoning_ontology(chat_evaluation_ontology):
357362
{
358363
"id": 0,
359364
"name": "Correct",
365+
"actions": [],
360366
},
361367
{
362368
"id": 1,
363369
"name": "Neutral",
370+
"actions": [],
364371
},
365372
{
366373
"id": 2,
367374
"name": "Incorrect",
368-
"actions": ["regenerateSteps", "generateAndRateAlternativeSteps"],
375+
"actions": [
376+
"regenerateSteps",
377+
"generateAndRateAlternativeSteps",
378+
"rewriteStep",
379+
"justification",
380+
],
369381
},
370382
]
371383

libs/labelbox/tests/unit/test_unit_step_reasoning_tool.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ def test_step_reasoning_as_dict_default():
2020
"featureSchemaId": None,
2121
"definition": {
2222
"variants": [
23-
{"id": 0, "name": "Correct"},
24-
{"id": 1, "name": "Neutral"},
23+
{"id": 0, "name": "Correct", "actions": []},
24+
{"id": 1, "name": "Neutral", "actions": []},
2525
{
2626
"id": 2,
2727
"name": "Incorrect",
2828
"actions": [
2929
"regenerateSteps",
3030
"generateAndRateAlternativeSteps",
31+
"rewriteStep",
32+
"justification",
3133
],
3234
},
3335
],
@@ -47,8 +49,8 @@ def test_step_reasoning_as_dict_with_actions():
4749
"featureSchemaId": None,
4850
"definition": {
4951
"variants": [
50-
{"id": 0, "name": "Correct"},
51-
{"id": 1, "name": "Neutral"},
52+
{"id": 0, "name": "Correct", "actions": []},
53+
{"id": 1, "name": "Neutral", "actions": []},
5254
{
5355
"id": 2,
5456
"name": "Incorrect",

0 commit comments

Comments
 (0)