From db8201d4dafb533133cc51c87c7ef011e546e03f Mon Sep 17 00:00:00 2001 From: Vincent Emonet Date: Thu, 6 Feb 2025 16:26:08 +0100 Subject: [PATCH] community: fix typo in the module imported when using GPU with FastEmbedEmbeddings (#29631) Made a mistake in the module to import (the module stay the same only the installed package changes), fixed it and tested it https://github.com/langchain-ai/langchain/pull/29627 @ccurme --- .../langchain_community/embeddings/fastembed.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/community/langchain_community/embeddings/fastembed.py b/libs/community/langchain_community/embeddings/fastembed.py index cee8b40be61..12499adb1cd 100644 --- a/libs/community/langchain_community/embeddings/fastembed.py +++ b/libs/community/langchain_community/embeddings/fastembed.py @@ -84,21 +84,21 @@ class FastEmbedEmbeddings(BaseModel, Embeddings): cache_dir = values.get("cache_dir") threads = values.get("threads") gpu = values.get("gpu") - pkg_to_import = "fastembed-gpu" if gpu else "fastembed" + pkg_to_install = "fastembed-gpu" if gpu else "fastembed" try: - fastembed = importlib.import_module(pkg_to_import) + fastembed = importlib.import_module("fastembed") except ModuleNotFoundError: raise ImportError( - f"Could not import '{pkg_to_import}' Python package. " - f"Please install it with `pip install {pkg_to_import}`." + "Could not import 'fastembed' Python package. " + f"Please install it with `pip install {pkg_to_install}`." ) - if importlib.metadata.version(pkg_to_import) < MIN_VERSION: + if importlib.metadata.version(pkg_to_install) < MIN_VERSION: raise ImportError( f"FastEmbedEmbeddings requires " - f'`pip install -U "{pkg_to_import}>={MIN_VERSION}"`.' + f'`pip install -U "{pkg_to_install}>={MIN_VERSION}"`.' ) values["model"] = fastembed.TextEmbedding(