Skip to content

Commit

Permalink
feat: add mongo db integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai krishna committed Dec 6, 2024
1 parent db810a1 commit 54baa0d
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 98 deletions.
5 changes: 3 additions & 2 deletions backend/modules/vector_db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from backend.modules.vector_db.base import BaseVectorDB
from backend.modules.vector_db.mongo import MongoVectorDB

# from backend.modules.vector_db.mongo import MongoVectorDB
from backend.modules.vector_db.qdrant import QdrantVectorDB

# from backend.modules.vector_db.singlestore import SingleStoreVectorDB
Expand All @@ -8,7 +9,7 @@

SUPPORTED_VECTOR_DBS = {
"qdrant": QdrantVectorDB,
"mongo": MongoVectorDB,
# "mongo": MongoVectorDB,
# "weaviate": WeaviateVectorDB,
# "singlestore": SingleStoreVectorDB,
}
Expand Down
8 changes: 7 additions & 1 deletion backend/modules/vector_db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from langchain.schema.vectorstore import VectorStore

from backend.constants import DEFAULT_BATCH_SIZE_FOR_VECTOR_STORE
from backend.logger import logger
from backend.types import DataPointVector


Expand Down Expand Up @@ -88,4 +89,9 @@ def get_embedding_dimensions(self, embeddings: Embeddings) -> int:
"""
Fetch embedding dimensions
"""
raise NotImplementedError()
# Calculate embedding size
logger.debug(f"[VectorDB] Embedding a dummy doc to get vector dimensions")
partial_embeddings = embeddings.embed_documents(["Initial document"])
vector_size = len(partial_embeddings[0])
logger.debug(f"Vector size: {vector_size}")
return vector_size
Loading

0 comments on commit 54baa0d

Please sign in to comment.