🚀 feat(loading.py): add support for MongoDBAtlasVectorSearch vector store
The `instantiate_vectorstore` function now supports the `MongoDBAtlasVectorSearch` vector store. This allows for the use of MongoDB Atlas as a vector store for Langflow. The `search_kwargs` parameter is now supported for all vector stores that have a `as_retriever` method. This allows for the configuration of the vector store's search parameters.
This commit is contained in:
parent
ea0231025f
commit
fb7bcb50e5
1 changed files with 17 additions and 8 deletions
|
|
@ -9,6 +9,7 @@ from langchain.agents.tools import BaseTool
|
||||||
from langflow.interface.initialize.vector_store import (
|
from langflow.interface.initialize.vector_store import (
|
||||||
initialize_chroma,
|
initialize_chroma,
|
||||||
initialize_faiss,
|
initialize_faiss,
|
||||||
|
initialize_mongodb,
|
||||||
initialize_pinecone,
|
initialize_pinecone,
|
||||||
initialize_qdrant,
|
initialize_qdrant,
|
||||||
initialize_supabase,
|
initialize_supabase,
|
||||||
|
|
@ -149,29 +150,37 @@ def instantiate_embedding(class_object, params):
|
||||||
|
|
||||||
|
|
||||||
def instantiate_vectorstore(class_object, params):
|
def instantiate_vectorstore(class_object, params):
|
||||||
|
search_kwargs = params.pop("search_kwargs", {})
|
||||||
# could be documents or texts
|
# could be documents or texts
|
||||||
if class_object.__name__ == "Pinecone":
|
if class_object.__name__ == "Pinecone":
|
||||||
return initialize_pinecone(class_object, params)
|
vecstore = initialize_pinecone(class_object, params)
|
||||||
# Chroma requires all metadata values to not be None
|
# Chroma requires all metadata values to not be None
|
||||||
elif class_object.__name__ == "Chroma":
|
elif class_object.__name__ == "Chroma":
|
||||||
return initialize_chroma(class_object, params)
|
vecstore = initialize_chroma(class_object, params)
|
||||||
|
|
||||||
elif class_object.__name__ == "Qdrant":
|
elif class_object.__name__ == "Qdrant":
|
||||||
return initialize_qdrant(class_object, params)
|
vecstore = initialize_qdrant(class_object, params)
|
||||||
|
|
||||||
elif class_object.__name__ == "Weaviate":
|
elif class_object.__name__ == "Weaviate":
|
||||||
return initialize_weaviate(class_object, params)
|
vecstore = initialize_weaviate(class_object, params)
|
||||||
elif class_object.__name__ == "FAISS":
|
elif class_object.__name__ == "FAISS":
|
||||||
return initialize_faiss(class_object, params)
|
vecstore = initialize_faiss(class_object, params)
|
||||||
elif class_object.__name__ == "SupabaseVectorStore":
|
elif class_object.__name__ == "SupabaseVectorStore":
|
||||||
return initialize_supabase(class_object, params)
|
vecstore = initialize_supabase(class_object, params)
|
||||||
|
elif class_object.__name__ == "MongoDBAtlasVectorSearch":
|
||||||
|
vecstore = initialize_mongodb(class_object, params)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if "texts" in params:
|
if "texts" in params:
|
||||||
params["documents"] = params.pop("texts")
|
params["documents"] = params.pop("texts")
|
||||||
|
|
||||||
vector_store = class_object.from_documents(**params)
|
vecstore = class_object.from_documents(**params)
|
||||||
return vector_store
|
|
||||||
|
# ! This might not work. Need to test
|
||||||
|
if search_kwargs and hasattr(vecstore, "as_retriever"):
|
||||||
|
vecstore = vecstore.as_retriever(search_kwargs=search_kwargs)
|
||||||
|
|
||||||
|
return vecstore
|
||||||
|
|
||||||
|
|
||||||
def instantiate_documentloader(class_object, params):
|
def instantiate_documentloader(class_object, params):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue