fix for issue #821: deferring optional SDK imports to runtime for provider modules (#828)

This commit is contained in:
Syed Ishmum Ahnaf 2026-04-18 16:14:52 +06:00 committed by GitHub
parent 290922858f
commit b341bf5ea1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 31 deletions

View file

@ -7,8 +7,6 @@ Input is text, output is embeddings vector.
import logging
from ... base import EmbeddingsService
from langchain_huggingface import HuggingFaceEmbeddings
# Module logger
logger = logging.getLogger(__name__)
@ -38,6 +36,7 @@ class Processor(EmbeddingsService):
def _load_model(self, model_name):
"""Load a model, caching it for reuse"""
if self.cached_model_name != model_name:
from langchain_huggingface import HuggingFaceEmbeddings
logger.info(f"Loading HuggingFace embeddings model: {model_name}")
self.embeddings = HuggingFaceEmbeddings(model_name=model_name)
self.cached_model_name = model_name