mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-16 17:53:37 +00:00
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.
This commit is contained in:
parent
590d47bff4
commit
9d663f31fa
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user