from pydantic import BaseModel, Field


class RagChatAppVO(BaseModel):
    appId: str = Field(..., description="应用ID")
    appName: str = Field(..., description="应用名称")
    description: str = Field("", description="应用描述")
    isDefault: bool = Field(False, description="是否默认应用")


class RagChatAppListVO(BaseModel):
    data: list[RagChatAppVO] = Field(default_factory=list)
    total: int = Field(0)


class RagConversationItemVO(BaseModel):
    id: str = Field(..., description="会话ID")
    name: str = Field(..., description="会话名称")
    introduction: str = Field("", description="会话简介")
    createdAt: int = Field(0, description="创建时间戳")
    updatedAt: int = Field(0, description="更新时间戳")


class RagConversationPageVO(BaseModel):
    data: list[RagConversationItemVO] = Field(default_factory=list)
    hasMore: bool = Field(False)
    limit: int = Field(20)


class RagMessageItemVO(BaseModel):
    id: str = Field(...)
    conversationId: str = Field(...)
    query: str = Field(...)
    answer: str = Field(...)
    feedback: dict | None = Field(None)
    retrieverResources: list[dict] | None = Field(None)
    createdAt: int = Field(0)


class RagMessagePageVO(BaseModel):
    data: list[RagMessageItemVO] = Field(default_factory=list)
    hasMore: bool = Field(False)
    limit: int = Field(20)


class RagConversationRenameVO(BaseModel):
    result: str = Field("success")
    name: str = Field(...)


class RagOperationResultVO(BaseModel):
    result: str = Field("success")


class RagAppParametersVO(BaseModel):
    openingStatement: str = Field("", description="开场白")
    suggestedQuestions: list[str] = Field(default_factory=list)
    userInputForm: list[dict] = Field(default_factory=list)
    fileUpload: dict = Field(default_factory=lambda: {"image": {"enabled": False}})
