import enum
from typing import Any, Dict, List, Literal, Optional, Union
from pydantic import BaseModel, Field, field_validator
from uuid import uuid4
from datetime import datetime
from broai.utils import get_timestamp
from enum import Enum

class Context(BaseModel):
    id:str = Field(description="unique id generated by system", default_factory=lambda: str(uuid4()))
    context:str = Field(description="context or chunk of information that will be stored and used in RAG system") 
    metadata:Optional[Dict[str, Any]] = Field(description="", default=None)
    type:Literal["document"] = Field(description="type of ducument", default="document")
    created_at: datetime = Field(description="Timestamp Asia/Bangkok", default_factory=get_timestamp)

class TaskStatus(str, Enum):
    NOT_STARTED = "not_started"
    PENDING = "pending"
    PROCESSING = "processing"
    DONE = "done"
    ERROR = "error"
    CANCELED = "canceled"           # Optional: User/system canceled
    TIMEOUT = "timeout"             # Optional: Process timed out
    RETRYING = "retrying"           # Optional: Retry attempt in progress