-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce proper dependency management.
- Loading branch information
Showing
7 changed files
with
67 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import logging | ||
|
||
from fastapi import APIRouter | ||
from fastapi import APIRouter, Depends | ||
|
||
from aitestdrive.service.document import document_service | ||
from aitestdrive.service.document import DocumentService | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
api = APIRouter(prefix="/documents", tags=["Documents"]) | ||
|
||
|
||
@api.post("/re-vectorize-from-storage") | ||
async def re_vectorize_documents_from_storage(): | ||
async def re_vectorize_documents_from_storage(document_service=Depends(DocumentService)): | ||
log.info(f"Request received to re-vectorize documents from storage") | ||
await document_service.re_vectorize_documents_from_storage() | ||
log.info("Re-vectorization of documents done.") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from google.cloud import storage | ||
|
||
|
||
def create_storage_client(): | ||
return storage.Client() # cannot be created automatically by FastAPI's Depends(...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from aitestdrive.persistence.qdrant import QdrantService | ||
|
||
__singletons = { | ||
QdrantService: QdrantService() | ||
} | ||
|
||
|
||
def get(clazz): | ||
return __singletons[clazz] | ||
|
||
|
||
def depends(clazz): | ||
async def async_dep(): | ||
return get(clazz) | ||
|
||
return async_dep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters