| """ | |
| 청크 관련 Pydantic 모델 | |
| """ | |
| from typing import Optional, List | |
| from pydantic import BaseModel, Field | |
| class ChunkMetadata(BaseModel): | |
| """청크 메타데이터 모델""" | |
| pov: Optional[str] = Field(None, description="화자/시점") | |
| characters: Optional[List[str]] = Field(default_factory=list, description="등장인물 목록") | |
| time_background: Optional[str] = Field(None, description="시간적 배경") | |
| chapter: Optional[int] = Field(None, description="챕터 번호") | |
| class Config: | |
| """Pydantic 설정""" | |
| json_schema_extra = { | |
| "example": { | |
| "pov": "1인칭 주인공", | |
| "characters": ["홍길동", "김철수"], | |
| "time_background": "현재 시점", | |
| "chapter": 1 | |
| } | |
| } | |
| class ChunkCreate(BaseModel): | |
| """청크 생성 요청 모델""" | |
| file_id: int = Field(..., description="파일 ID") | |
| chunk_index: int = Field(..., description="청크 인덱스") | |
| content: str = Field(..., min_length=1, description="청크 내용") | |
| metadata: Optional[ChunkMetadata] = Field(None, description="청크 메타데이터") | |
| class ChunkResponse(BaseModel): | |
| """청크 응답 모델""" | |
| id: int | |
| file_id: int | |
| chunk_index: int | |
| content: str | |
| metadata: Optional[ChunkMetadata] = None | |
| class Config: | |
| """Pydantic 설정""" | |
| from_attributes = True | |