Spaces:
Paused
Paused
Commit ·
f92d3ff
1
Parent(s): 4bf1625
add feature limit ranking
Browse files
app/api/v1/endpoints/search.py
CHANGED
|
@@ -13,6 +13,7 @@ router = APIRouter()
|
|
| 13 |
@router.get("/")
|
| 14 |
async def calculate_similarity(
|
| 15 |
description: str = Query(..., description="คำบรรยายลักษณะใบหน้า"),
|
|
|
|
| 16 |
db: AsyncSession = Depends(deps.get_db),
|
| 17 |
current_user: User = Depends(deps.get_current_active_user),
|
| 18 |
):
|
|
@@ -35,4 +36,4 @@ async def calculate_similarity(
|
|
| 35 |
|
| 36 |
results.sort(key=lambda x: x["similarity_score"], reverse=True)
|
| 37 |
|
| 38 |
-
return results[:
|
|
|
|
| 13 |
@router.get("/")
|
| 14 |
async def calculate_similarity(
|
| 15 |
description: str = Query(..., description="คำบรรยายลักษณะใบหน้า"),
|
| 16 |
+
limit: int = Query(4, ge=1, le=6, description="จำนวนผลลัพธ์สูงสุดที่ต้องการแสดง"),
|
| 17 |
db: AsyncSession = Depends(deps.get_db),
|
| 18 |
current_user: User = Depends(deps.get_current_active_user),
|
| 19 |
):
|
|
|
|
| 36 |
|
| 37 |
results.sort(key=lambda x: x["similarity_score"], reverse=True)
|
| 38 |
|
| 39 |
+
return results[:limit]
|