Files
xiaoxia-saas/packages/domain/classification.py
T
xiaoxia 926d0fa272
Tests / test (push) Failing after 0s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
fix: 为所有 ORM 模型添加外键约束及级联删除策略 (#65)
2026-06-28 08:47:51 +08:00

70 lines
1.8 KiB
Python

from __future__ import annotations
from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import StrEnum
from typing import Any
from uuid import uuid4
class AssetLibraryKind(StrEnum):
VIDEO = "video"
VOICE = "voice"
class IngestJobStatus(StrEnum):
PENDING = "pending"
PROCESSING = "processing"
COMPLETED = "completed"
FAILED = "failed"
class ClassificationJobStatus(StrEnum):
PENDING = "pending"
PROCESSING = "processing"
COMPLETED = "completed"
FAILED = "failed"
class AssetClassification(StrEnum):
"""Asset classification categories."""
SCENIC = "scenic" # 风景
PRODUCT = "product" # 产品
PERSON = "person" # 人物
ANIMAL = "animal" # 动物
FOOD = "food" # 美食
TECH = "tech" # 科技
SPORT = "sport" # 运动
MUSIC = "music" # 音乐
OTHER = "other" # 其他
@dataclass(slots=True)
class ClassificationJob:
id: str
project_id: str
asset_id: str
status: ClassificationJobStatus = ClassificationJobStatus.PENDING
classification: str = "" # Result: AssetClassification value
confidence: float = 0.0 # 0.0 - 1.0
error_message: str = ""
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
updated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
@classmethod
def create(
cls,
project_id: str,
asset_id: str,
) -> "ClassificationJob":
if not project_id.strip():
raise ValueError("project_id 不能为空")
if not asset_id.strip():
raise ValueError("asset_id 不能为空")
return cls(
id=uuid4().hex,
project_id=project_id.strip(),
asset_id=asset_id.strip(),
)