From 9d663f31fa3f373c02b34931bf8c4b5082781b18 Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 1 Mar 2024 10:45:51 +0530 Subject: [PATCH] community[patch]: FastEmbed to latest (#18040) ## Description Updates the `langchain_community.embeddings.fastembed` provider as per the recent updates to [`FastEmbed`](https://github.com/qdrant/fastembed) library. --- .../langchain_community/embeddings/fastembed.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/community/langchain_community/embeddings/fastembed.py b/libs/community/langchain_community/embeddings/fastembed.py index 0a29a784004..65ed5b16c26 100644 --- a/libs/community/langchain_community/embeddings/fastembed.py +++ b/libs/community/langchain_community/embeddings/fastembed.py @@ -44,8 +44,7 @@ class FastEmbedEmbeddings(BaseModel, Embeddings): doc_embed_type: Literal["default", "passage"] = "default" """Type of embedding to use for documents - "default": Uses FastEmbed's default embedding method - "passage": Prefixes the text with "passage" before embedding. + The available options are: "default" and "passage" """ _model: Any # : :meta private: @@ -59,13 +58,13 @@ class FastEmbedEmbeddings(BaseModel, Embeddings): def validate_environment(cls, values: Dict) -> Dict: """Validate that FastEmbed has been installed.""" try: - from fastembed.embedding import FlagEmbedding + from fastembed import TextEmbedding model_name = values.get("model_name") max_length = values.get("max_length") cache_dir = values.get("cache_dir") threads = values.get("threads") - values["_model"] = FlagEmbedding( + values["_model"] = TextEmbedding( model_name=model_name, max_length=max_length, cache_dir=cache_dir, @@ -73,7 +72,7 @@ class FastEmbedEmbeddings(BaseModel, Embeddings): ) except ImportError as ie: raise ImportError( - "Could not import 'fastembed' Python package. " + "'FastEmbedEmbeddings' requires 'fastembed==v0.2.0' or above. " "Please install it with `pip install fastembed`." ) from ie return values