fix: prevent P2 from owning Qdrant lifecycle
This commit is contained in:
@@ -55,6 +55,7 @@ class QdrantVectorStore:
|
||||
workspace_id: str,
|
||||
workspace_revision: str | None = None,
|
||||
expected_dimension: int | None = None,
|
||||
collection_lifecycle: str = "create_if_missing",
|
||||
request: Callable[..., object] | None = None,
|
||||
connect_timeout: float = 2.0,
|
||||
read_timeout: float = 10.0,
|
||||
@@ -64,6 +65,9 @@ class QdrantVectorStore:
|
||||
self._workspace_id = workspace_id
|
||||
self._workspace_revision = workspace_revision
|
||||
self._expected_dimension = expected_dimension
|
||||
if collection_lifecycle not in ("create_if_missing", "require_existing"):
|
||||
raise ValueError("Unsupported Qdrant collection lifecycle")
|
||||
self._collection_lifecycle = collection_lifecycle
|
||||
self._request = request or requests.request
|
||||
self._timeout = (connect_timeout, read_timeout)
|
||||
|
||||
@@ -306,6 +310,8 @@ class QdrantVectorStore:
|
||||
if response is None:
|
||||
if not strict:
|
||||
raise VectorStoreError("Qdrant collection is missing")
|
||||
if self._collection_lifecycle == "require_existing":
|
||||
raise VectorStoreError("Qdrant collection configuration mismatch (semantic_index_incompatible)")
|
||||
self._call(
|
||||
"PUT",
|
||||
f"/collections/{self._collection}",
|
||||
@@ -328,11 +334,17 @@ class QdrantVectorStore:
|
||||
self._expected_dimension is not None
|
||||
and (size != self._expected_dimension or distance != "Cosine")
|
||||
):
|
||||
raise VectorStoreError("Qdrant collection configuration mismatch")
|
||||
raise VectorStoreError("Qdrant collection configuration mismatch (semantic_index_incompatible)")
|
||||
payload_schema = result.get("payload_schema")
|
||||
if not isinstance(payload_schema, dict):
|
||||
raise VectorStoreError("Qdrant returned malformed collection response")
|
||||
for field_name in _KEYWORD_INDEXES:
|
||||
if field_name not in result.get("payload_schema", {}):
|
||||
field = payload_schema.get(field_name)
|
||||
if not isinstance(field, dict) or field.get("data_type") != "keyword":
|
||||
if not strict:
|
||||
raise VectorStoreError("Qdrant collection payload indexes mismatch")
|
||||
if self._collection_lifecycle == "require_existing":
|
||||
raise VectorStoreError("Qdrant collection configuration mismatch (semantic_index_incompatible)")
|
||||
self._call(
|
||||
"PUT",
|
||||
f"/collections/{self._collection}/index",
|
||||
|
||||
Reference in New Issue
Block a user