From 2891cc621c5f0bf3d3f7fbb224853f0300c1a50a Mon Sep 17 00:00:00 2001
From: rbrugaro
Date: Tue, 13 Aug 2024 01:28:21 -0700
Subject: [PATCH] fix HuggingFaceEmbedding deprecated in favor of
HuggingFaceInferenceAPIEmbedding (#466)
* Fix HuggingFaceEmbedding deprecated in favor of HuggingFaceInferenceAPIEmbedding
Signed-off-by: rbrugaro
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Signed-off-by: rbrugaro
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
---
comps/embeddings/llama_index/local_embedding.py | 4 ++--
comps/embeddings/llama_index/requirements.txt | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/comps/embeddings/llama_index/local_embedding.py b/comps/embeddings/llama_index/local_embedding.py
index bccec24ca9..f6a69afafd 100644
--- a/comps/embeddings/llama_index/local_embedding.py
+++ b/comps/embeddings/llama_index/local_embedding.py
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
from langsmith import traceable
-from llama_index.embeddings.huggingface import HuggingFaceEmbedding
+from llama_index.embeddings.huggingface_api import HuggingFaceInferenceAPIEmbedding
from comps import EmbedDoc, ServiceType, TextDoc, opea_microservices, register_microservice
@@ -24,5 +24,5 @@ def embedding(input: TextDoc) -> EmbedDoc:
if __name__ == "__main__":
- embeddings = HuggingFaceEmbedding(model_name="BAAI/bge-large-en-v1.5")
+ embeddings = HuggingFaceInferenceAPIEmbedding(model_name="BAAI/bge-large-en-v1.5")
opea_microservices["opea_service@local_embedding"].start()
diff --git a/comps/embeddings/llama_index/requirements.txt b/comps/embeddings/llama_index/requirements.txt
index b1d2beba9a..908c38b06b 100644
--- a/comps/embeddings/llama_index/requirements.txt
+++ b/comps/embeddings/llama_index/requirements.txt
@@ -2,6 +2,7 @@ docarray[full]
fastapi
huggingface_hub
langsmith
+llama-index-embeddings-huggingface-api
llama-index-embeddings-text-embeddings-inference
opentelemetry-api
opentelemetry-exporter-otlp