Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 2 additions & 117 deletions libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,120 +755,6 @@ def create_offline_model_evaluation_project(
}
return self._create_project(_CoreProjectInput(**input))

def create_prompt_response_generation_project(
self,
name: str,
media_type: MediaType,
description: Optional[str] = None,
auto_audit_percentage: Optional[float] = None,
auto_audit_number_of_labels: Optional[int] = None,
quality_modes: Optional[Set[QualityMode]] = {
QualityMode.Benchmark,
QualityMode.Consensus,
},
is_benchmark_enabled: Optional[bool] = None,
is_consensus_enabled: Optional[bool] = None,
dataset_id: Optional[str] = None,
dataset_name: Optional[str] = None,
data_row_count: int = 100,
) -> Project:
"""
Use this method exclusively to create a prompt and response generation project.

Args:
dataset_name: When creating a new dataset, pass the name
dataset_id: When using an existing dataset, pass the id
data_row_count: The number of data row assets to use for the project
media_type: The type of assets that this project will accept. Limited to LLMPromptCreation and LLMPromptResponseCreation
See create_project for additional parameters
Returns:
Project: The created project

NOTE: Only a dataset_name or dataset_id should be included

Examples:
>>> client.create_prompt_response_generation_project(name=project_name, dataset_name="new data set", media_type=MediaType.LLMPromptResponseCreation)
>>> This creates a new dataset with a default number of rows (100), creates new prompt and response creation project and assigns a batch of the newly created data rows to the project.

>>> client.create_prompt_response_generation_project(name=project_name, dataset_name="new data set", data_row_count=10, media_type=MediaType.LLMPromptCreation)
>>> This creates a new dataset with 10 data rows, creates new prompt creation project and assigns a batch of the newly created datarows to the project.

>>> client.create_prompt_response_generation_project(name=project_name, dataset_id="clr00u8j0j0j0", media_type=MediaType.LLMPromptCreation)
>>> This creates a new prompt creation project, and adds 100 datarows to the dataset with id "clr00u8j0j0j0" and assigns a batch of the newly created data rows to the project.

>>> client.create_prompt_response_generation_project(name=project_name, dataset_id="clr00u8j0j0j0", data_row_count=10, media_type=MediaType.LLMPromptResponseCreation)
>>> This creates a new prompt and response creation project, and adds 100 datarows to the dataset with id "clr00u8j0j0j0" and assigns a batch of the newly created 10 data rows to the project.

"""
if not dataset_id and not dataset_name:
raise ValueError(
"dataset_name or dataset_id must be present and not be an empty string."
)

if dataset_id and dataset_name:
raise ValueError(
"Only provide a dataset_name or dataset_id, not both."
)

if dataset_id:
append_to_existing_dataset = True
dataset_name_or_id = dataset_id
else:
append_to_existing_dataset = False
dataset_name_or_id = dataset_name

if media_type not in [
MediaType.LLMPromptCreation,
MediaType.LLMPromptResponseCreation,
]:
raise ValueError(
"media_type must be either LLMPromptCreation or LLMPromptResponseCreation"
)

input = {
"name": name,
"description": description,
"media_type": media_type,
"auto_audit_percentage": auto_audit_percentage,
"auto_audit_number_of_labels": auto_audit_number_of_labels,
"quality_modes": quality_modes,
"is_benchmark_enabled": is_benchmark_enabled,
"is_consensus_enabled": is_consensus_enabled,
"dataset_name_or_id": dataset_name_or_id,
"append_to_existing_dataset": append_to_existing_dataset,
"data_row_count": data_row_count,
}
return self._create_project(_CoreProjectInput(**input))

def create_response_creation_project(
self,
name: str,
description: Optional[str] = None,
quality_modes: Optional[Set[QualityMode]] = {
QualityMode.Benchmark,
QualityMode.Consensus,
},
is_benchmark_enabled: Optional[bool] = None,
is_consensus_enabled: Optional[bool] = None,
) -> Project:
"""
Creates a project for response creation.
Args:
See create_project for parameters
Returns:
Project: The created project
"""
input = {
"name": name,
"description": description,
"media_type": MediaType.Text, # Only Text is supported
"quality_modes": quality_modes,
"is_benchmark_enabled": is_benchmark_enabled,
"is_consensus_enabled": is_consensus_enabled,
"editor_task_type": EditorTaskType.ResponseCreation.value, # Special editor task type for response creation projects
}
return self._create_project(_CoreProjectInput(**input))

def _create_project(self, input: _CoreProjectInput) -> Project:
params = input.model_dump(exclude_none=True)

Expand Down Expand Up @@ -1375,13 +1261,12 @@ def create_ontology(
name (str): Name of the ontology
normalized (dict): A normalized ontology payload. See above for details.
media_type (MediaType or None): Media type of a new ontology
ontology_kind (OntologyKind or None): set to OntologyKind.ModelEvaluation if the ontology is for chat evaluation or
OntologyKind.ResponseCreation if ontology is for response creation, leave as None otherwise.
ontology_kind (OntologyKind or None): set to OntologyKind.ModelEvaluation if the ontology is for chat evaluation, leave as None otherwise.

Returns:
The created Ontology

NOTE for chat evaluation, we currently force media_type to Conversational and for response creation, we force media_type to Text.
NOTE for chat evaluation, we currently force media_type to Conversational.
"""

media_type_value = None
Expand Down
12 changes: 0 additions & 12 deletions libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,6 @@ def service_type(self):
):
return "Live chat evaluation"

if (
self.editor_task_type == EditorTaskType.ResponseCreation
and self.media_type == MediaType.Text
):
return "Response creation"

if (
self.media_type == MediaType.LLMPromptCreation
or self.media_type == MediaType.LLMPromptResponseCreation
):
return "Prompt response creation"

return sentence_case(self.media_type.value)

@classmethod
Expand Down
2 changes: 0 additions & 2 deletions libs/labelbox/src/labelbox/schema/media_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class MediaType(Enum):
Geospatial_Tile = "TMS_GEO"
Html = "HTML"
Image = "IMAGE"
LLMPromptCreation = "LLM_PROMPT_CREATION"
LLMPromptResponseCreation = "LLM_PROMPT_RESPONSE_CREATION"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy API media types misclassified

Medium Severity

Removing LLMPromptCreation and LLMPromptResponseCreation from MediaType means API values such as LLM_PROMPT_CREATION no longer match any member in _missing_, so fetched projects deserialize to MediaType.Unsupported with value UNSUPPORTED instead of the backend’s stored type. That conflicts with keeping legacy prompt/response projects readable and can break callers that branch on project.media_type or its .value.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e1f77a8. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK but can confirm.

Pdf = "PDF"
Simple_Tile = "TMS_SIMPLE"
Text = "TEXT"
Expand Down
11 changes: 0 additions & 11 deletions libs/labelbox/src/labelbox/schema/ontology_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class OntologyKind(Enum):
"""

ModelEvaluation = "MODEL_EVALUATION"
ResponseCreation = "RESPONSE_CREATION"
Missing = None

@classmethod
Expand All @@ -34,10 +33,6 @@ def evaluate_ontology_kind_with_media_type(
MediaType.Conversational,
"For chat evaluation, media_type must be Conversational.",
),
OntologyKind.ResponseCreation: (
MediaType.Text,
"For response creation, media_type must be Text.",
),
}

if ontology_kind in ontology_to_media:
Expand All @@ -55,7 +50,6 @@ def evaluate_ontology_kind_with_media_type(

class EditorTaskType(str, Enum):
ModelChatEvaluation = "MODEL_CHAT_EVALUATION"
ResponseCreation = "RESPONSE_CREATION"
OfflineModelChatEvaluation = "OFFLINE_MODEL_CHAT_EVALUATION"
Missing = None

Expand Down Expand Up @@ -107,11 +101,6 @@ def map_to_editor_task_type(
and media_type == MediaType.Conversational
):
return EditorTaskType.ModelChatEvaluation
elif (
onotology_kind == OntologyKind.ResponseCreation
and media_type == MediaType.Text
):
return EditorTaskType.ResponseCreation
else:
return EditorTaskType.Missing

Expand Down
11 changes: 0 additions & 11 deletions libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,6 @@ def is_chat_evaluation(self) -> bool:
and self.editor_task_type == EditorTaskType.ModelChatEvaluation
)

def is_prompt_response(self) -> bool:
"""
Returns:
True if this project is a prompt response project, False otherwise
"""
return (
self.media_type == MediaType.LLMPromptResponseCreation
or self.media_type == MediaType.LLMPromptCreation
or self.editor_task_type == EditorTaskType.ResponseCreation
)

def is_auto_data_generation(self) -> bool:
return self.upload_type == UploadType.Auto # type: ignore

Expand Down
Loading
Loading