Each Tool and Classification type requires a specific value to be passed when creating the feature.
Feature
Class
Value
Bounding box
Tool
BBOX
Polygon
Tool
POLYGON
Polyline
Tool
LINE
Point
Tool
POINT
Segmentation mask
Tool
RASTER_SEGMENTATION
Relationship
Tool
RELATIONSHIP
Entity
Tool
NER
Message ranking
Tool
MESSAGE_RANKING
Single message selection
Tool
MESSAGE_SINGLE_SELECTION
Multiple message selection
Tool
MESSAGE_MULTI_SELECTION
Message step reasoning
Tool
STEP_REASONING
Fact-checking
Tool
FACT_CHECKING
Prompt rating
Tool
PROMPT_ISSUE
Radio
Classification
RADIO
Checklist
Classification
CHECKLIST
Text
Classification
TEXT
When you create an ontology, specify the media_type parameter, which represents the modality of the data rows that the ontology will be used to label. Certain features are only compatible with certain media types.
You can define new features to build new ontologies. The following code sample shows how to create simple features for upserting into ontologies. To learn more about creating features, see Features.
If you already have features created, you can query them by name or by schema id. Re-using an existing feature is highly recommended.
## Search feature by name in your orgregulatory_sign_feature_schema = next(client.get_feature_schemas("regulatory-sign"))classification_feature = next(client.get_feature_schemas("Quality Issues"))## Get feature by feature schema ID. Alternatively you can get this from the UIregulatory_sign_feature_schema = client.get_feature_schema("FEATURE_SCHEMA_ID")ontology = client.create_ontology_from_feature_schemas("Ontology from existing features", [regulatory_sign_feature_schema.uid, classification_feature.uid], media_type=MediaType.Image)
You can create a child feature nested under a parent feature. Only classification features can be children of a nested ontology. For instance, if you want to create an ontology where a bounding box has a radio sub-classification, you will add a classificationsfield that contains a list of classification features as children.
# get by IDontology = client.get_ontology("<ontology_id>")# get by nameontology = next(client.get_ontologies("<ontology_name>"))# get multiple ontologies by keywordontologies = client.get_ontologies(name_contains="<keyword>")
# get (or create) a projectproject = client.get_project("<project_id>")# get (or create) an ontologyontology = client.get_ontology("<ontology_id>")# the argument must be an object of the Ontology classproject.connect_ontology(ontology)
# name (str)ontology.name# description (str)ontology.description# updated at (datetime)ontology.updated_at# created at (datetime)ontology.created_at# normalized output of the ontology (JSON)ontology.normalized# count of object tools in the ontology (int)ontology.object_schema_count# count of classifications in the ontology (int)ontology.classification_schema_count# created by (relationship to User object)user = ontology.created_by()