2026-05-18 16:32:42 +08:00
|
|
|
"""Define schema models for doc."""
|
|
|
|
|
|
2026-05-14 15:07:34 +08:00
|
|
|
from pydantic import BaseModel
|
|
|
|
|
from typing import Optional
|
|
|
|
|
from datetime import datetime
|
2026-05-18 16:32:42 +08:00
|
|
|
# Group related schema definitions so validation rules stay consistent.
|
|
|
|
|
|
2026-05-14 15:07:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentUploadResponse(BaseModel):
|
2026-05-18 16:32:42 +08:00
|
|
|
"""Define the Document Upload Response API model."""
|
2026-05-14 15:07:34 +08:00
|
|
|
doc_id: str
|
|
|
|
|
filename: str
|
|
|
|
|
size: int
|
|
|
|
|
status: str = "uploaded"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentInfo(BaseModel):
|
2026-05-18 16:32:42 +08:00
|
|
|
"""Define the Document Info API model."""
|
2026-05-14 15:07:34 +08:00
|
|
|
id: str
|
|
|
|
|
name: str
|
|
|
|
|
chunks: int
|
|
|
|
|
status: str
|
|
|
|
|
created_at: Optional[datetime] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentListResponse(BaseModel):
|
2026-05-18 16:32:42 +08:00
|
|
|
"""Define the Document List Response API model."""
|
2026-05-14 15:07:34 +08:00
|
|
|
docs: list[DocumentInfo]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChunkInfo(BaseModel):
|
2026-05-18 16:32:42 +08:00
|
|
|
"""Define the Chunk Info API model."""
|
2026-05-14 15:07:34 +08:00
|
|
|
chunk_id: str
|
|
|
|
|
doc_name: str
|
|
|
|
|
clause_id: Optional[str] = None
|
|
|
|
|
chapter: Optional[str] = None
|
|
|
|
|
content: str
|
|
|
|
|
token_count: int
|
|
|
|
|
chunk_index: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ParseResponse(BaseModel):
|
2026-05-18 16:32:42 +08:00
|
|
|
"""Define the Parse Response API model."""
|
2026-05-14 15:07:34 +08:00
|
|
|
doc_id: str
|
|
|
|
|
chunks: int
|
|
|
|
|
status: str = "parsed"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EmbedResponse(BaseModel):
|
2026-05-18 16:32:42 +08:00
|
|
|
"""Define the Embed Response API model."""
|
2026-05-14 15:07:34 +08:00
|
|
|
doc_id: str
|
|
|
|
|
vectors: int
|
|
|
|
|
status: str = "embedded"
|