Bootstrap architecture rules from task history
This commit is contained in:
@@ -44,6 +44,52 @@ TASK_SPECS: tuple[TaskSpec, ...] = (
|
||||
TASK_SPEC_BY_TYPE = {task.task_type: task for task in TASK_SPECS}
|
||||
|
||||
|
||||
TASK_TYPE_BY_MODEL_TASK_LEVEL_ID = {
|
||||
"0": "text-generation",
|
||||
"2": "visual-multi-modal",
|
||||
"21": "text-to-image-generation",
|
||||
"23": "text-generation",
|
||||
"29": "feature_emb",
|
||||
"34": "feature_emb",
|
||||
"39": "question_answering",
|
||||
"54": "asr",
|
||||
"116": "vision_classification",
|
||||
"198": "vision_classification",
|
||||
"207": "reinforcement_learning",
|
||||
"213": "text-to-image-generation",
|
||||
}
|
||||
|
||||
TASK_TYPE_BY_MODEL_TASK_LEVEL = {
|
||||
"文本生成": "text-generation",
|
||||
"视觉多模态理解": "visual-multi-modal",
|
||||
"图片生成图片": "text-to-image-generation",
|
||||
"文生图": "text-to-image-generation",
|
||||
"特征抽取": "feature_emb",
|
||||
"句子相似度": "feature_emb",
|
||||
"问答": "question_answering",
|
||||
"语音识别": "asr",
|
||||
"视觉分类": "vision_classification",
|
||||
"零样本图像分类": "vision_classification",
|
||||
"强化学习": "reinforcement_learning",
|
||||
}
|
||||
|
||||
|
||||
def task_type_from_history_task(task: dict) -> str | None:
|
||||
"""Recover the API task type from current or legacy history fields."""
|
||||
task_type = task.get("taskType")
|
||||
if task_type and str(task_type) in TASK_SPEC_BY_TYPE:
|
||||
return str(task_type)
|
||||
level_id = task.get("modelTaskLevelId")
|
||||
if level_id is not None:
|
||||
mapped = TASK_TYPE_BY_MODEL_TASK_LEVEL_ID.get(str(level_id))
|
||||
if mapped:
|
||||
return mapped
|
||||
level_name = task.get("modelTaskLevel")
|
||||
if level_name:
|
||||
return TASK_TYPE_BY_MODEL_TASK_LEVEL.get(str(level_name))
|
||||
return None
|
||||
|
||||
|
||||
def all_task_types() -> list[str]:
|
||||
return [task.task_type for task in TASK_SPECS]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user