From 89284b0a8b68a16afb8ea2b8e10f5f59c47ef6ff Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Fri, 27 Feb 2026 10:34:43 +0800 Subject: [PATCH] fix: Fixed the problem that multiple labels cannot be selected when creating annotation tasks in text multi-label templates. --- .../datamate-python/app/module/annotation/schema/template.py | 1 + .../app/module/annotation/service/template.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/datamate-python/app/module/annotation/schema/template.py b/runtime/datamate-python/app/module/annotation/schema/template.py index a36d1f3ef..891b2d25b 100644 --- a/runtime/datamate-python/app/module/annotation/schema/template.py +++ b/runtime/datamate-python/app/module/annotation/schema/template.py @@ -14,6 +14,7 @@ class LabelDefinition(BaseModel): options: Optional[List[str]] = Field(None, description="选项列表(用于choices类型)") labels: Optional[List[str]] = Field(None, description="标签列表(用于rectanglelabels等类型)") required: bool = Field(False, description="是否必填") + choice: Optional[str] = Field(None, description="选项设置") description: Optional[str] = Field(None, description="标签描述") model_config = ConfigDict(populate_by_name=True) diff --git a/runtime/datamate-python/app/module/annotation/service/template.py b/runtime/datamate-python/app/module/annotation/service/template.py index e5474924d..e9b5976e0 100644 --- a/runtime/datamate-python/app/module/annotation/service/template.py +++ b/runtime/datamate-python/app/module/annotation/service/template.py @@ -55,7 +55,10 @@ def generate_label_studio_config(config: TemplateConfiguration) -> str: # 添加可选属性 if label.required: label_attrs.append('required="true"') - + + if label.choice: + label_attrs.append(f'choice="{label.choice}"') + tag_type = label.type.capitalize() if label.type else "Choices" # 检查是否需要子元素