From d2e5df1e4d0d1ed08d43b3b1d897698a626fa291 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 07:28:09 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- comps/cores/proto/docarray.py | 2 +- comps/embeddings/multimodal_clip/embedding_multimodal.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/comps/cores/proto/docarray.py b/comps/cores/proto/docarray.py index 50871f7bf..79f961ca2 100644 --- a/comps/cores/proto/docarray.py +++ b/comps/cores/proto/docarray.py @@ -101,7 +101,7 @@ class EmbedDoc(BaseDoc): fetch_k: int = 20 lambda_mult: float = 0.5 score_threshold: float = 0.2 - constraints: Optional[Union[Dict[str, Any], List[Dict[str, Any]],None]] = None + constraints: Optional[Union[Dict[str, Any], List[Dict[str, Any]], None]] = None class EmbedMultimodalDoc(EmbedDoc): diff --git a/comps/embeddings/multimodal_clip/embedding_multimodal.py b/comps/embeddings/multimodal_clip/embedding_multimodal.py index a9fa88e5c..c791f1471 100644 --- a/comps/embeddings/multimodal_clip/embedding_multimodal.py +++ b/comps/embeddings/multimodal_clip/embedding_multimodal.py @@ -4,6 +4,7 @@ import datetime import time from typing import List, Optional, Union + from dateparser.search import search_dates from embeddings_clip import vCLIP @@ -23,9 +24,11 @@ EmbeddingResponse, EmbeddingResponseData, ) + logger = CustomLogger("embedding_multimodal") logflag = os.getenv("LOGFLAG", False) + def filtler_dates(prompt): base_date = datetime.datetime.today() @@ -108,11 +111,13 @@ async def embedding( logger.info(res) return res + async def get_embeddings(text: Union[str, List[str]]) -> List[List[float]]: texts = [text] if isinstance(text, str) else text embed_vector = embeddings.embed_query(texts).tolist() return embed_vector + if __name__ == "__main__": embeddings = vCLIP({"model_name": "openai/clip-vit-base-patch32", "num_frm": 4}) opea_microservices["opea_service@embedding_multimodal"].start()