41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
from datetime import datetime
|
|
from typing import Optional, List, Dict, Any, ClassVar
|
|
from pydantic import BaseModel, Field, HttpUrl
|
|
from bson import ObjectId
|
|
|
|
from src.models.team import PyObjectId
|
|
|
|
class ImageModel(BaseModel):
|
|
"""Database model for an image"""
|
|
id: Optional[PyObjectId] = Field(default_factory=PyObjectId, alias="_id")
|
|
filename: str
|
|
original_filename: str
|
|
file_size: int
|
|
content_type: str
|
|
storage_path: str
|
|
public_url: Optional[HttpUrl] = None
|
|
team_id: PyObjectId
|
|
uploader_id: PyObjectId
|
|
upload_date: datetime = Field(default_factory=datetime.utcnow)
|
|
last_accessed: Optional[datetime] = None
|
|
description: Optional[str] = None
|
|
tags: List[str] = []
|
|
metadata: Dict[str, Any] = {}
|
|
collection_id: Optional[PyObjectId] = None
|
|
|
|
# Fields for image understanding and semantic search
|
|
embedding_id: Optional[str] = None
|
|
embedding_model: Optional[str] = None
|
|
has_embedding: bool = False
|
|
embedding_status: str = "pending" # pending, processing, success, failed
|
|
embedding_error: Optional[str] = None
|
|
embedding_retry_count: int = 0
|
|
embedding_last_attempt: Optional[datetime] = None
|
|
|
|
model_config: ClassVar[dict] = {
|
|
"populate_by_name": True,
|
|
"arbitrary_types_allowed": True,
|
|
"json_encoders": {
|
|
ObjectId: str
|
|
}
|
|
} |