feat: add qdrant vector adapter

This commit is contained in:
2026-08-08 17:43:15 +02:00
parent c875fa52ce
commit 7109ee15c4
8 changed files with 830 additions and 6 deletions
+27 -3
View File
@@ -3,14 +3,15 @@ from unittest.mock import MagicMock
import pytest
from tht.adapters.vector.thoth_http import ThothHttpVectorStore
from tht.adapters.vector.legacy_direct import LegacyDirectVectorStore
from tht.adapters.vector.qdrant import QdrantVectorStore
from tht.adapters.vector.thoth_http import ThothHttpVectorStore
from tht.evidence.model import EvidenceDoc
from tht.ports.vector import (
VectorHit,
VectorReadUnavailable,
VectorRecord,
VectorStore,
VectorReadUnavailable,
VectorWriteRecord,
VectorWriteUnavailable,
)
@@ -158,11 +159,13 @@ def test_http_store_is_runtime_vector_store():
def test_vector_contract_is_exported_from_public_packages():
from tht.adapters.vector import QdrantVectorStore as PublicQdrantStore
from tht.adapters.vector import ThothHttpVectorStore as PublicHttpStore
from tht.ports import VectorReadUnavailable as PublicVectorReadUnavailable
from tht.ports import VectorStore as PublicVectorStore
from tht.ports import VectorWriteRecord as PublicVectorWriteRecord
from tht.ports import VectorReadUnavailable as PublicVectorReadUnavailable
assert PublicQdrantStore is QdrantVectorStore
assert PublicHttpStore is ThothHttpVectorStore
assert PublicVectorStore is VectorStore
assert PublicVectorWriteRecord is VectorWriteRecord
@@ -248,3 +251,24 @@ def test_legacy_direct_search_requires_a_strict_positive_integer_limit(limit):
with pytest.raises(ValueError, match="positive integer"):
store.search(["memory"], [0.1], limit=limit)
def test_qdrant_store_is_runtime_vector_store():
store = QdrantVectorStore(
base_url="http://qdrant:6333",
collection="workspace-semantic",
workspace_id="demo",
expected_dimension=1024,
request=lambda *args, **kwargs: MagicMock(
ok=True,
status_code=200,
text='{"result":{"config":{"params":{"vectors":{"size":1024,"distance":"Cosine"}}},"payload_schema":{}}}',
json=lambda: {
"result": {
"config": {"params": {"vectors": {"size": 1024, "distance": "Cosine"}}},
"payload_schema": {},
}
},
),
)
assert isinstance(store, VectorStore)