feat(documents): add GET /documents endpoint and improve models

Why:
- Need to list documents to get document IDs for queries
- ProcessRequest should default to all 5 strategies
- paragraph_count should be optional (not always stored)

Changes:
- Added GET /documents endpoint with pagination
- Added DocumentListResponse model
- ProcessRequest now defaults to all 5 strategies
- DocumentResponse.paragraph_count now defaults to 0
This commit is contained in:
2026-07-26 12:06:14 +03:30
parent 496a58c62a
commit cbaa72b420
3 changed files with 37 additions and 8 deletions

View File

@@ -14,6 +14,7 @@ from src.core.models import PaginatedResponse, StrategyName
from src.documents.models import (
DeleteResponse,
DocumentResponse,
DocumentListResponse,
ProcessRequest,
ProcessResponse,
StrategiesResponse,
@@ -24,6 +25,18 @@ from src.documents import service
router = APIRouter()
@router.get("/documents", response_model=DocumentListResponse)
async def list_documents(offset: int = 0, limit: int = 50):
"""List all uploaded documents with pagination."""
result = service.list_documents(offset=offset, limit=limit)
return DocumentListResponse(
items=[DocumentResponse(**doc) for doc in result["items"]],
total=result["total"],
offset=result["offset"],
limit=result["limit"],
)
@router.post("/documents", response_model=DocumentResponse, status_code=201)
async def upload_document(file: UploadFile = File(...)):
"""Upload a .docx file. Parses it, stores the document tree in SQLite."""