diff --git a/mem0/configs/vector_stores/qdrant.py b/mem0/configs/vector_stores/qdrant.py index a610883884..c90eee707e 100644 --- a/mem0/configs/vector_stores/qdrant.py +++ b/mem0/configs/vector_stores/qdrant.py @@ -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") diff --git a/mem0/vector_stores/qdrant.py b/mem0/vector_stores/qdrant.py index a429627823..fa1ae25402 100644 --- a/mem0/vector_stores/qdrant.py +++ b/mem0/vector_stores/qdrant.py @@ -37,6 +37,7 @@ def __init__( path: str = None, url: str = None, api_key: str = None, + https: bool | None = None, on_disk: bool = False, ): """ @@ -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. """ @@ -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 diff --git a/tests/vector_stores/test_qdrant_config.py b/tests/vector_stores/test_qdrant_config.py new file mode 100644 index 0000000000..3da99be2eb --- /dev/null +++ b/tests/vector_stores/test_qdrant_config.py @@ -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, + )