Skip to content

Commit

Permalink
remove deprecated langchain imports and switch to langchain-huggingfa…
Browse files Browse the repository at this point in the history
…ce (#417)

* remrove deprecated imports and switch to langchain-huggingface

Signed-off-by: rbrugaro <[email protected]>

* fix typo

Signed-off-by: rbrugaro <[email protected]>

* set requirements to langchain latest release

Signed-off-by: rbrugaro <[email protected]>

* remove version for langchain in requirements

Signed-off-by: rbrugaro <[email protected]>

---------

Signed-off-by: rbrugaro <[email protected]>
  • Loading branch information
rbrugaro committed Aug 12, 2024
1 parent 7c9f77b commit 055404a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion comps/embeddings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,6 @@ curl http://localhost:6000/v1/health_check\
```bash
curl http://localhost:6000/v1/embeddings\
-X POST \
-d '{"input":"Hello, world!"}' \
-d '{"text":"Hello, world!"}' \
-H 'Content-Type: application/json'
```
4 changes: 2 additions & 2 deletions comps/embeddings/langchain/embedding_tei.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import time
from typing import Union

from langchain_community.embeddings import HuggingFaceHubEmbeddings
from langchain_huggingface import HuggingFaceEndpointEmbeddings
from langsmith import traceable

from comps import (
Expand Down Expand Up @@ -61,6 +61,6 @@ def embedding(

if __name__ == "__main__":
tei_embedding_endpoint = os.getenv("TEI_EMBEDDING_ENDPOINT", "http://localhost:8080")
embeddings = HuggingFaceHubEmbeddings(model=tei_embedding_endpoint)
embeddings = HuggingFaceEndpointEmbeddings(model=tei_embedding_endpoint)
print("TEI Gaudi Embedding initialized.")
opea_microservices["opea_service@embedding_tei_langchain"].start()
4 changes: 2 additions & 2 deletions comps/embeddings/langchain/local_embedding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from langchain_community.embeddings import HuggingFaceBgeEmbeddings
from langchain_huggingface import HuggingFaceEmbeddings

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

Expand All @@ -23,5 +23,5 @@ def embedding(input: TextDoc) -> EmbedDoc:


if __name__ == "__main__":
embeddings = HuggingFaceBgeEmbeddings(model_name="BAAI/bge-large-en-v1.5")
embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-large-en-v1.5")
opea_microservices["opea_service@local_embedding"].start()
1 change: 1 addition & 0 deletions comps/embeddings/langchain/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ docarray[full]
fastapi
huggingface_hub
langchain
langchain_huggingface
langsmith
opentelemetry-api
opentelemetry-exporter-otlp
Expand Down

0 comments on commit 055404a

Please sign in to comment.