Skip to content

Commit 11e89eb

Browse files
committed
Port latest updates to step reasoning
1 parent cb08de3 commit 11e89eb

File tree

2 files changed

+72
-10
lines changed

2 files changed

+72
-10
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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,56 @@ def test_step_reasoning_ontology(chat_evaluation_ontology):
379379
],
380380
},
381381
]
382+
383+
384+
def test_fact_checking_ontology(chat_evaluation_ontology):
385+
ontology = chat_evaluation_ontology
386+
fact_checking = None
387+
for tool in ontology.normalized["tools"]:
388+
if tool["tool"] == "fact-checking":
389+
fact_checking = tool
390+
break
391+
assert fact_checking is not None
392+
assert fact_checking["definition"]["variants"] == [
393+
{"id": 0, "name": "Accurate"},
394+
{"id": 1, "name": "Inaccurate"},
395+
{"id": 2, "name": "Disputed"},
396+
{"id": 3, "name": "Unsupported", "actions": ["writeJustification"]},
397+
{
398+
"id": 4,
399+
"name": "Can't confidently assess",
400+
"actions": ["writeJustification"],
401+
},
402+
{
403+
"id": 5,
404+
"name": "No factual information",
405+
"actions": ["writeJustification"],
406+
},
407+
]
408+
assert fact_checking["definition"]["version"] == 1
409+
assert fact_checking["schemaNodeId"] is not None
410+
assert fact_checking["featureSchemaId"] is not None
411+
412+
fact_checking = None
413+
for tool in ontology.tools():
414+
if isinstance(tool, FactCheckingTool):
415+
fact_checking = tool
416+
break
417+
assert fact_checking is not None
418+
419+
assert fact_checking.definition.variants.asdict() == [
420+
{"id": 0, "name": "Accurate"},
421+
{"id": 1, "name": "Inaccurate"},
422+
{"id": 2, "name": "Disputed"},
423+
{"id": 3, "name": "Unsupported", "actions": ["writeJustification"]},
424+
{
425+
"id": 4,
426+
"name": "Can't confidently assess",
427+
"actions": ["writeJustification"],
428+
},
429+
{
430+
"id": 5,
431+
"name": "No factual information",
432+
"actions": ["writeJustification"],
433+
},
434+
]

0 commit comments

Comments
 (0)