from typing import Optional
from pydantic import BaseModel, Field
from datetime import datetime, timezone

class Doc(BaseModel):
    id: Optional[int] = Field(default=None, description="文档ID")
    name: str = Field(default="", description="文档名称")
    path: str = Field(default="", description="文档路径")
    markdown_files: list[str] = Field(default_factory=list, description="文档路径列表")
    version: Optional[str] = Field(default="", description="文档版本")

class Q_A(BaseModel):
    question: str = Field(default="", min_length=1,description="问题")
    answer: str = Field(default="", min_length=1, description="答案")

class DatasetItem(BaseModel):
    id: Optional[int] = Field(default=None, description="数据集项ID")
    message: list[Q_A] = Field(description="数据集项内容")

class Dataset(BaseModel):
    id: Optional[int] = Field(default=None, description="数据集ID")
    name: str = Field(default="", description="数据集名称")
    model_id: Optional[list[str]] = Field(default=None, description="数据集使用的模型ID")
    source_doc: Optional[Doc] = Field(default=None, description="数据集来源文档")
    description: Optional[str] = Field(default="", description="数据集描述")
    created_at: datetime = Field(
        default_factory=lambda: datetime.now(timezone.utc),
        description="记录创建时间"
    )
    dataset_items: list[DatasetItem] = Field(default_factory=list, description="数据集项列表")