Skip to content

Commit

Permalink
Merge pull request #413 from truefoundry/feat/mongo-integration
Browse files Browse the repository at this point in the history
[Vector Store] Mongo DB Integration
  • Loading branch information
mnvsk97 authored Dec 6, 2024
2 parents d9b4269 + 54baa0d commit efe8a21
Show file tree
Hide file tree
Showing 5 changed files with 434 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/modules/vector_db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from backend.modules.vector_db.base import BaseVectorDB

# 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 @@ -7,6 +9,7 @@

SUPPORTED_VECTOR_DBS = {
"qdrant": QdrantVectorDB,
# "mongo": MongoVectorDB,
# "weaviate": WeaviateVectorDB,
# "singlestore": SingleStoreVectorDB,
}
Expand Down
12 changes: 12 additions & 0 deletions 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 @@ -83,3 +84,14 @@ def delete_data_point_vectors(
Delete vectors from the collection
"""
raise NotImplementedError()

def get_embedding_dimensions(self, embeddings: Embeddings) -> int:
"""
Fetch embedding dimensions
"""
# 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 efe8a21

Please sign in to comment.