Upload app\models\chunk.py with huggingface_hub
Browse files- app//models//chunk.py +52 -0
app//models//chunk.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
청크 관련 Pydantic 모델
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from typing import Optional, List
|
| 6 |
+
from pydantic import BaseModel, Field
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class ChunkMetadata(BaseModel):
|
| 10 |
+
"""청크 메타데이터 모델"""
|
| 11 |
+
|
| 12 |
+
pov: Optional[str] = Field(None, description="화자/시점")
|
| 13 |
+
characters: Optional[List[str]] = Field(default_factory=list, description="등장인물 목록")
|
| 14 |
+
time_background: Optional[str] = Field(None, description="시간적 배경")
|
| 15 |
+
chapter: Optional[int] = Field(None, description="챕터 번호")
|
| 16 |
+
|
| 17 |
+
class Config:
|
| 18 |
+
"""Pydantic 설정"""
|
| 19 |
+
json_schema_extra = {
|
| 20 |
+
"example": {
|
| 21 |
+
"pov": "1인칭 주인공",
|
| 22 |
+
"characters": ["홍길동", "김철수"],
|
| 23 |
+
"time_background": "현재 시점",
|
| 24 |
+
"chapter": 1
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class ChunkCreate(BaseModel):
|
| 30 |
+
"""청크 생성 요청 모델"""
|
| 31 |
+
|
| 32 |
+
file_id: int = Field(..., description="파일 ID")
|
| 33 |
+
chunk_index: int = Field(..., description="청크 인덱스")
|
| 34 |
+
content: str = Field(..., min_length=1, description="청크 내용")
|
| 35 |
+
metadata: Optional[ChunkMetadata] = Field(None, description="청크 메타데이터")
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class ChunkResponse(BaseModel):
|
| 39 |
+
"""청크 응답 모델"""
|
| 40 |
+
|
| 41 |
+
id: int
|
| 42 |
+
file_id: int
|
| 43 |
+
chunk_index: int
|
| 44 |
+
content: str
|
| 45 |
+
metadata: Optional[ChunkMetadata] = None
|
| 46 |
+
|
| 47 |
+
class Config:
|
| 48 |
+
"""Pydantic 설정"""
|
| 49 |
+
from_attributes = True
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|