Support modern Qdrant search API
This commit is contained in:
@@ -178,6 +178,40 @@ class TestSearchDocs:
|
||||
assert "title" in result
|
||||
assert "chunk_index" in result
|
||||
|
||||
def test_uses_modern_qdrant_query_points_api(self):
|
||||
"""New qdrant-client versions expose query_points instead of search."""
|
||||
from unittest.mock import patch
|
||||
from backend.app.search import search_docs
|
||||
|
||||
point = type("ScoredPoint", (), {
|
||||
"score": 0.91,
|
||||
"payload": {
|
||||
"id": "modern-result",
|
||||
"library_id": "documentation",
|
||||
"path": "docs/index.md",
|
||||
"title": "Index",
|
||||
"chunk_index": 0,
|
||||
},
|
||||
})()
|
||||
|
||||
class Response:
|
||||
points = [point]
|
||||
|
||||
class ModernClient:
|
||||
def query_points(self, **kwargs):
|
||||
assert kwargs["query"] == [0.1, 0.2]
|
||||
assert kwargs["limit"] == 3
|
||||
return Response()
|
||||
|
||||
with (
|
||||
patch("backend.app.search.embed_text", return_value=[0.1, 0.2]),
|
||||
patch("backend.app.search.get_client", return_value=ModernClient()),
|
||||
):
|
||||
results = search_docs("world generation", limit=3)
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0]["id"] == "modern-result"
|
||||
|
||||
|
||||
class TestGetLibraryDocs:
|
||||
"""Tests for get_library_docs() - document retrieval."""
|
||||
|
||||
Reference in New Issue
Block a user