Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr_align_embedding_inputs_202411…
Browse files Browse the repository at this point in the history
…12' into pr_align_embedding_inputs_20241112
  • Loading branch information
XinyaoWa committed Nov 13, 2024
2 parents e9a6159 + d2e5df1 commit 9c209d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion comps/cores/proto/docarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions comps/embeddings/multimodal_clip/embedding_multimodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime
import time,os
from typing import List, Optional, Union

from dateparser.search import search_dates
from embeddings_clip import vCLIP

Expand All @@ -23,9 +24,11 @@
EmbeddingResponse,
EmbeddingResponseData,
)

logger = CustomLogger("embedding_multimodal")
logflag = os.getenv("LOGFLAG", False)


def filtler_dates(prompt):

base_date = datetime.datetime.today()
Expand Down Expand Up @@ -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()

0 comments on commit 9c209d1

Please sign in to comment.