Files
sora_python/app/api/api_similar_match.py
2024-03-27 18:08:59 +08:00

26 lines
772 B
Python

import logging
import time
from fastapi import APIRouter
from app.schemas.similar_match import SimilarMatchMItem
from app.service.similar_match.service import SimilarMatch
from app.service.utils.decorator import RunTime
logger = logging.getLogger()
router = APIRouter()
@RunTime
@router.post("similar_match")
def similar_match(request_item: SimilarMatchMItem):
try:
if request_item.result_number <= 0:
raise KeyError("result number can't be less than 0")
service = SimilarMatch(request_item)
search_response = service.match_features()
return {"message": "ok", "data": search_response}
except KeyError as e:
logger.warning(str(e))
return {"message": "result number can't be less than 0", "data": []}