Skip to content

Commit

Permalink
community: fix typo in the module imported when using GPU with FastEm…
Browse files Browse the repository at this point in the history
…bedEmbeddings (#29631)

Made a mistake in the module to import (the module stay the same only
the installed package changes), fixed it and tested it

#29627

@ccurme
  • Loading branch information
vemonet authored Feb 6, 2025
1 parent f8fd65d commit db8201d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libs/community/langchain_community/embeddings/fastembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ def validate_environment(cls, values: Dict) -> Dict:
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(
Expand Down

0 comments on commit db8201d

Please sign in to comment.