From e03394276c1c5ab90f11a67537fb229198a29a8f Mon Sep 17 00:00:00 2001 From: EdgeNeko Date: Fri, 29 Dec 2023 16:10:32 +0800 Subject: [PATCH] Add index service --- app/Services/authentication.py | 4 +--- app/Services/index_service.py | 17 +++++++++++++++++ requirements.dev.txt | 4 ++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 app/Services/index_service.py create mode 100644 requirements.dev.txt diff --git a/app/Services/authentication.py b/app/Services/authentication.py index 953ec1e..e8143b7 100644 --- a/app/Services/authentication.py +++ b/app/Services/authentication.py @@ -7,9 +7,7 @@ def verify_access_token(token: str | None) -> bool: - if not config.access_protected: - return True - return token is not None and token == config.access_token + return (not config.access_protected) or (token is not None and token == config.access_token) def permissive_access_token_verify( diff --git a/app/Services/index_service.py b/app/Services/index_service.py new file mode 100644 index 0000000..867ba4d --- /dev/null +++ b/app/Services/index_service.py @@ -0,0 +1,17 @@ +from PIL import Image + +from app.Models.img_data import ImageData +from app.Services import TransformersService +from app.Services.ocr_services import OCRService + + +class IndexService: + def __init__(self, ocr_service: OCRService, transformers_service: TransformersService): + self._ocr_service = ocr_service + self._transformers_service = transformers_service + + def _calculate_vectors(self): + pass + + def index_image(self, image: Image.Image, image_data: ImageData): + pass diff --git a/requirements.dev.txt b/requirements.dev.txt new file mode 100644 index 0000000..04bb894 --- /dev/null +++ b/requirements.dev.txt @@ -0,0 +1,4 @@ +# Requirements for development and testing + +pytest +pylint \ No newline at end of file