相似匹配接口
This commit is contained in:
25
app/api/api_similar_match.py
Normal file
25
app/api/api_similar_match.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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": []}
|
||||
Reference in New Issue
Block a user