Labels
Create, list, get, delete, add, and remove annotation labels.
create_label
Creates an annotation label. Labels define what annotators evaluate (e.g. sentiment, quality, relevance).
def create_label(
self,
name: str,
type: str,
*,
settings: Optional[Dict[str, Any]] = None,
description: Optional[str] = None,
project: Optional[str] = None,
timeout: Optional[int] = None,
) -> AnnotationLabel
- Arguments:
name(str): Label name. Must be unique per organization, type, and project.type(str): Label type —"categorical","text","numeric","star", or"thumbs_up_down".settings(Optional[Dict[str, Any]]): Type-specific configuration. See Label Settings by Type below.description(Optional[str]): Description of the label.project(Optional[str]): Project ID to scope the label to. If omitted, the label is organization-wide.timeout(Optional[int]): Request timeout in seconds.
- Returns:
AnnotationLabelinstance
Label Settings by Type
{
"rule_prompt": "Classify the sentiment", # str, required
"multi_choice": False, # bool, required
"options": [ # list, required (min 2)
{"label": "Positive"},
{"label": "Negative"},
{"label": "Neutral"},
],
"auto_annotate": False, # bool, required
"strategy": None, # "Rag" or None, required
} {
"placeholder": "Enter your feedback...", # str, required
"max_length": 500, # int, required
"min_length": 1, # int, required
} {
"min": 0, # number, required
"max": 10, # number, required
"step_size": 1, # number, required
"display_type": "slider", # "slider" or "button", required
} {
"no_of_stars": 5, # int, required (>= 1)
} {} # No settings required list_labels
Lists annotation labels available to the organization.
def list_labels(
self,
*,
project_id: Optional[str] = None,
timeout: Optional[int] = None,
) -> List[AnnotationLabel]
- Arguments:
project_id(Optional[str]): Filter labels by project ID.timeout(Optional[int]): Request timeout in seconds.
- Returns:
List[AnnotationLabel]
get_label
Gets a single annotation label by ID or name.
def get_label(
self,
label_id: Optional[str] = None,
*,
label_name: Optional[str] = None,
timeout: Optional[int] = None,
) -> AnnotationLabel
- Arguments:
label_id(Optional[str]): UUID of the annotation label.label_name(Optional[str]): Name of the annotation label (alternative tolabel_id).timeout(Optional[int]): Request timeout in seconds.
- Returns:
AnnotationLabelinstance
delete_label
Deletes an annotation label.
def delete_label(
self,
label_id: Optional[str] = None,
*,
label_name: Optional[str] = None,
timeout: Optional[int] = None,
) -> Dict[str, Any]
- Arguments:
label_id(Optional[str]): UUID of the annotation label.label_name(Optional[str]): Name of the annotation label (alternative tolabel_id).timeout(Optional[int]): Request timeout in seconds.
- Returns:
Dict[str, Any]
add_label
Attaches an existing annotation label to the queue.
def add_label(
self,
queue_id: Optional[str] = None,
label_id: Optional[str] = None,
*,
queue_name: Optional[str] = None,
label_name: Optional[str] = None,
timeout: Optional[int] = None,
) -> Dict[str, Any]
- Arguments:
queue_id(Optional[str]): UUID of the annotation queue.label_id(Optional[str]): UUID of the annotation label.queue_name(Optional[str]): Name of the annotation queue (alternative toqueue_id).label_name(Optional[str]): Name of the annotation label (alternative tolabel_id).timeout(Optional[int]): Request timeout in seconds.
- Returns:
Dict[str, Any]
remove_label
Removes an annotation label from the queue.
def remove_label(
self,
queue_id: Optional[str] = None,
label_id: Optional[str] = None,
*,
queue_name: Optional[str] = None,
label_name: Optional[str] = None,
timeout: Optional[int] = None,
) -> Dict[str, Any]
- Arguments:
queue_id(Optional[str]): UUID of the annotation queue.label_id(Optional[str]): UUID of the annotation label.queue_name(Optional[str]): Name of the annotation queue (alternative toqueue_id).label_name(Optional[str]): Name of the annotation label (alternative tolabel_id).timeout(Optional[int]): Request timeout in seconds.
- Returns:
Dict[str, Any]
Was this page helpful?
Questions & Discussion