1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1212# implied. See the License for the specific language governing
1313# permissions and limitations under the License.
14+
1415"""The embeddings module implements the supported vector databases.
1516
1617The common abstraction for all supported vector databases is the EmbeddingHandler class, which supports
2627import time
2728import uuid
2829import itertools
30+ from importlib import util
2931
30- from pymilvus import connections , utility , FieldSchema , CollectionSchema , DataType , Collection
3132from pymongo import MongoClient
3233
34+ try :
35+ from pymilvus import connections , utility , FieldSchema , CollectionSchema , DataType , Collection
36+ except ImportError :
37+ pass
38+
3339try :
3440 import faiss
3541except ImportError :
@@ -384,6 +390,7 @@ def unset_text_index(self):
384390
385391
386392class EmbeddingMilvus :
393+
387394 """Implements the vector database Milvius.
388395
389396 ``EmbeddingMivlus`` implements the interface to the ``Milvus`` vector store. It is used by the
@@ -408,6 +415,7 @@ class EmbeddingMilvus:
408415 embedding_milvus : EmbeddingMilvus
409416 A new ``EmbeddingMilvus`` object.
410417 """
418+
411419 def __init__ (self , library , model = None , model_name = None , embedding_dims = None ):
412420
413421 self .library = library
@@ -416,6 +424,10 @@ def __init__(self, library, model=None, model_name=None, embedding_dims=None):
416424 self .milvus_alias = "default"
417425
418426 # Connect to milvus
427+ # Instantiate client.
428+ if not util .find_spec ("pymilvus" ):
429+ raise DependencyNotInstalledException ("pip3 install pymilvus" )
430+
419431 connections .connect (self .milvus_alias ,
420432 host = MilvusConfig .get_config ("host" ),
421433 port = MilvusConfig .get_config ("port" ),
@@ -2400,6 +2412,9 @@ def __init__(self, library, model=None, model_name=None, embedding_dims=None):
24002412 host = ChromaDBConfig .get_config ('host' )
24012413
24022414 # Instantiate client.
2415+ if not util .find_spec ("chromadb" ):
2416+ raise DependencyNotInstalledException ("pip3 install chromadb" )
2417+
24032418 if host is None and persistent_path is None :
24042419 self .client = chromadb .EphemeralClient ()
24052420
0 commit comments