Skip to content

Commit a1f310f

Browse files
author
Val Brodsky
committed
Update for the latest api
1 parent 450cdc2 commit a1f310f

File tree

7 files changed

+51
-16
lines changed

7 files changed

+51
-16
lines changed

libs/labelbox/src/labelbox/schema/ontology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
from labelbox.orm.db_object import DbObject
1212
from labelbox.orm.model import Field, Relationship
13-
from labelbox.schema.ontology_building.prompt_issue_tool import PromptIssueTool
1413
from labelbox.schema.tool_building.classification import (
1514
Classification,
1615
PromptResponseClassification,
1716
)
1817
from labelbox.schema.tool_building.fact_checking_tool import (
1918
FactCheckingTool,
2019
)
20+
from labelbox.schema.tool_building.prompt_issue_tool import PromptIssueTool
2121
from labelbox.schema.tool_building.step_reasoning_tool import (
2222
StepReasoningTool,
2323
)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import labelbox.schema.tool_building.tool_type
2-
import labelbox.schema.ontology_building.variant
32
import labelbox.schema.tool_building.step_reasoning_tool
43
import labelbox.schema.tool_building.fact_checking_tool
54
import labelbox.schema.tool_building.prompt_issue_tool

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from lbox.exceptions import InconsistentOntologyException
77

8-
from labelbox.schema.ontology_building.types import FeatureSchemaId
8+
from labelbox.schema.tool_building.types import FeatureSchemaId
99

1010

1111
@dataclass

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
from labelbox.schema.tool_building.classification import (
55
Classification,
6+
Option,
67
)
78
from labelbox.schema.tool_building.tool_type import ToolType
89

910

1011
def _supported_classifications() -> List[Classification]:
11-
option_1_text = "This prompt cannot be rated (eg. contains PII, a nonsense prompt, a foreign language, or other scenario that makes the responses impossible to assess reliably). If you simply do not have expertise to tackle this prompt, please skip the task; do not mark it as not rateable"
12-
option_2_text = 'This prompt contains a false, offensive, or controversial premise (eg. "why does 1+1=3"?)'
13-
option_3_text = "This prompt is not self-contained (i.e. the prompt cannot be understood without additional context about previous turns, account information or images)."
12+
option_1_text = "This prompt cannot be rated (eg. contains PII, a nonsense prompt, a foreign language, or other scenario that makes the responses impossible to assess reliably). However, if you simply do not have expertise to tackle this prompt, please skip the task; do not mark it as not rateable."
13+
option_2_text = "This prompt contains a false, offensive, or controversial premise (eg. why does 1+1=3”?)"
14+
option_3_text = "This prompt is not self-contained, i.e. the prompt cannot be understood without additional context about previous turns, account information or images."
1415
options = [
1516
Option(label=option_1_text, value="not_rateable"),
1617
Option(label=option_2_text, value="false_offensive_controversial"),

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
from labelbox.schema.ontology_building.fact_checking_tool import (
1+
from labelbox.schema.tool_building.fact_checking_tool import (
22
FactCheckingTool,
33
)
4-
from labelbox.schema.ontology_building.step_reasoning_tool import (
4+
from labelbox.schema.tool_building.prompt_issue_tool import PromptIssueTool
5+
from labelbox.schema.tool_building.step_reasoning_tool import (
56
StepReasoningTool,
67
)
7-
from labelbox.schema.ontology_building.tool_type import ToolType
8+
from labelbox.schema.tool_building.tool_type import ToolType
89

910

1011
def map_tool_type_to_tool_cls(tool_type_str: str):

libs/labelbox/tests/integration/conftest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@
1616
MediaType,
1717
OntologyBuilder,
1818
Option,
19+
PromptIssueTool,
1920
PromptResponseClassification,
2021
ResponseOption,
2122
StepReasoningTool,
2223
Tool,
2324
)
2425
from labelbox.schema.data_row import DataRowMetadataField
25-
from labelbox.schema.ontology_building.prompt_issue_tool import PromptIssueTool
2626
from labelbox.schema.ontology_kind import OntologyKind
27-
from labelbox.schema.tool_building.fact_checking_tool import (
28-
FactCheckingTool,
29-
)
30-
from labelbox.schema.tool_building.step_reasoning_tool import (
31-
StepReasoningTool,
32-
)
3327
from labelbox.schema.user import User
3428

3529

libs/labelbox/tests/integration/test_ontology.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55

66
from labelbox import MediaType, OntologyBuilder, Tool
77
from labelbox.orm.model import Entity
8+
from labelbox.schema.tool_building.classification import Classification
89
from labelbox.schema.tool_building.fact_checking_tool import (
910
FactCheckingTool,
1011
)
12+
from labelbox.schema.tool_building.prompt_issue_tool import PromptIssueTool
1113
from labelbox.schema.tool_building.step_reasoning_tool import (
1214
StepReasoningTool,
1315
)
16+
from labelbox.schema.tool_building.tool_type import ToolType
1417

1518

1619
def test_feature_schema_is_not_archived(client, ontology):
@@ -448,3 +451,40 @@ def test_fact_checking_ontology(chat_evaluation_ontology):
448451
],
449452
"version": 1,
450453
}
454+
455+
456+
def test_prompt_issue_ontology(chat_evaluation_ontology):
457+
ontology = chat_evaluation_ontology
458+
prompt_issue = None
459+
for tool in ontology.normalized["tools"]:
460+
if tool["tool"] == "prompt-issue":
461+
prompt_issue = tool
462+
break
463+
assert prompt_issue is not None
464+
465+
assert prompt_issue["definition"] == {
466+
"title": "prompt issue",
467+
"value": "prompt_issue",
468+
"color": "#ff00ff",
469+
}
470+
assert prompt_issue["schemaNodeId"] is not None
471+
assert prompt_issue["featureSchemaId"] is not None
472+
assert len(prompt_issue["classifications"]) == 1
473+
474+
prompt_issue_tool = None
475+
for tool in ontology.tools():
476+
if isinstance(tool, PromptIssueTool):
477+
prompt_issue_tool = tool
478+
break
479+
assert prompt_issue_tool is not None
480+
# Assertions
481+
assert prompt_issue_tool.name == "prompt issue"
482+
assert prompt_issue_tool.type == ToolType.PROMPT_ISSUE
483+
assert prompt_issue_tool.schema_id is not None
484+
assert prompt_issue_tool.feature_schema_id is not None
485+
486+
# Check classifications
487+
assert len(prompt_issue_tool.classifications) == 1
488+
classification = prompt_issue_tool.classifications[0]
489+
assert classification.class_type == Classification.Type.CHECKLIST
490+
assert len(classification.options) == 3 # Check number of options

0 commit comments

Comments
 (0)