Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mem0/configs/vector_stores/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QdrantConfig(BaseModel):
path: Optional[str] = Field("/tmp/qdrant", description="Path for local Qdrant database")
url: Optional[str] = Field(None, description="Full URL for Qdrant server")
api_key: Optional[str] = Field(None, description="API key for Qdrant server")
https: Optional[bool] = Field(None, description="Whether to use HTTPS for host/port Qdrant connections")
on_disk: Optional[bool] = Field(False,description="Enables persistent storage. Vectors are kept on disk (True) or in memory (False). Does not delete the local database path.")

@model_validator(mode="before")
Expand Down
4 changes: 4 additions & 0 deletions mem0/vector_stores/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
path: str = None,
url: str = None,
api_key: str = None,
https: bool | None = None,
on_disk: bool = False,
):
"""
Expand All @@ -51,6 +52,7 @@ def __init__(
path (str, optional): Path for local Qdrant database. Defaults to None.
url (str, optional): Full URL for Qdrant server. Defaults to None.
api_key (str, optional): API key for Qdrant server. Defaults to None.
https (bool, optional): Whether to use HTTPS for host/port connections. Defaults to None.
on_disk (bool, optional): Enables persistent storage. Vectors are stored on disk (True) or in memory (False).
Does not delete the local database path. Defaults to False.
"""
Expand All @@ -66,6 +68,8 @@ def __init__(
if host and port:
params["host"] = host
params["port"] = port
if https is not None:
params["https"] = https

if not params:
params["path"] = path
Expand Down
37 changes: 37 additions & 0 deletions tests/vector_stores/test_qdrant_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from unittest.mock import MagicMock

from mem0.configs.vector_stores.qdrant import QdrantConfig
from mem0.vector_stores import qdrant as qdrant_module


def test_qdrant_config_accepts_explicit_https_false():
config = QdrantConfig(
host="127.0.0.1",
port=6333,
api_key="test-key",
https=False,
)

assert config.https is False


def test_qdrant_passes_explicit_https_to_client(monkeypatch):
client_cls = MagicMock()
monkeypatch.setattr(qdrant_module, "QdrantClient", client_cls)
monkeypatch.setattr(qdrant_module.Qdrant, "create_col", lambda *args, **kwargs: None)

qdrant_module.Qdrant(
collection_name="memories",
embedding_model_dims=1536,
host="127.0.0.1",
port=6333,
api_key="test-key",
https=False,
)

client_cls.assert_called_once_with(
api_key="test-key",
host="127.0.0.1",
port=6333,
https=False,
)