"""
知识库标注 Schema
"""
from typing import Optional, List
from datetime import datetime

from pydantic import BaseModel, Field, ConfigDict

from app.base_schema import CSTDatetime


class AnnotationCreateInput(BaseModel):
    """创建标注"""
    question: str = Field(..., min_length=1, description="问题")
    answer: str = Field(..., min_length=1, description="答案")


class AnnotationUpdateInput(BaseModel):
    """更新标注"""
    question: Optional[str] = Field(None, min_length=1, description="问题")
    answer: Optional[str] = Field(None, min_length=1, description="答案")
    enabled: Optional[bool] = Field(None, description="是否启用")


class AnnotationResponse(BaseModel):
    """标注输出"""
    id: str
    knowledge_base_id: str
    question: str
    answer: str
    embedding_status: str = "pending"
    enabled: bool = True
    hit_count: int = 0
    sys_create_datetime: Optional[CSTDatetime] = None
    sys_update_datetime: Optional[CSTDatetime] = None

    model_config = ConfigDict(from_attributes=True)
