Skip to content

Commit

Permalink
Add local_embedding return 768 length to align with chatqna example (o…
Browse files Browse the repository at this point in the history
…pea-project#313)

Signed-off-by: Chendi.Xue <[email protected]>
  • Loading branch information
xuechendi authored and sharanshirodkar7 committed Sep 3, 2024
1 parent 30aaedd commit fb43647
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions comps/embeddings/langchain/local_embedding_768.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from langchain_community.embeddings import HuggingFaceBgeEmbeddings

from comps import EmbedDoc768, ServiceType, TextDoc, opea_microservices, opea_telemetry, register_microservice


@register_microservice(
name="opea_service@local_embedding",
service_type=ServiceType.EMBEDDING,
endpoint="/v1/embeddings",
host="0.0.0.0",
port=6000,
input_datatype=TextDoc,
output_datatype=EmbedDoc768,
)
@opea_telemetry
def embedding(input: TextDoc) -> EmbedDoc768:
embed_vector = embeddings.embed_query(input.text)
res = EmbedDoc768(text=input.text, embedding=embed_vector)
return res


if __name__ == "__main__":
embeddings = HuggingFaceBgeEmbeddings(model_name="BAAI/bge-base-en-v1.5")
opea_microservices["opea_service@local_embedding"].start()

0 comments on commit fb43647

Please sign in to comment.