Fix migration workflow: upload as artifact instead of scp to practice EC2

This commit is contained in:
2026-08-13 11:14:25 +07:00
parent 7ebbe1f309
commit a4819b8653
51 changed files with 6830 additions and 8 deletions
+45 -6
View File
@@ -15,6 +15,45 @@ _LEXICAL_STOPWORDS = frozenset({
})
def _vector_search_points(
client: Any,
*,
collection_name: str,
vector: list[float],
query_filter: Any,
limit: int,
) -> list[Any]:
"""Run a dense lookup across supported qdrant-client generations.
qdrant-client 1.16 removed ``QdrantClient.search`` in favour of the
universal ``query_points`` API. Developer machines can still have an
older 1.x client because the project allows ``>=1.7,<2``. Prefer the new
API when present and retain the old call only as a compatibility path;
both return scored points with payloads.
"""
query_points = getattr(client, "query_points", None)
if callable(query_points):
response = query_points(
collection_name=collection_name,
query=vector,
query_filter=query_filter,
limit=limit,
with_payload=True,
)
return list(response.points)
search = getattr(client, "search", None)
if callable(search):
return list(search(
collection_name=collection_name,
query_vector=vector,
query_filter=query_filter,
limit=limit,
with_payload=True,
))
raise RuntimeError("qdrant client exposes neither query_points nor search")
class QueryEmbedder(Protocol):
@property
def dimensions(self) -> int: ...
@@ -133,14 +172,14 @@ class QdrantRetriever:
f"query vector has {len(vector)} dimensions; "
f"expected {self._embedder.dimensions}"
)
points = self._client.search(
points = _vector_search_points(
self._client,
collection_name=self._collection_name,
query_vector=vector,
vector=vector,
query_filter=Filter(
must=[FieldCondition(key="drug_id", match=MatchValue(value=drug_id))]
),
limit=limit,
with_payload=True,
)
return [
SearchHit(_document(dict(point.payload or {})), float(point.score))
@@ -410,9 +449,10 @@ class QdrantRetriever:
f"query vector has {len(vector)} dimensions; "
f"expected {self._embedder.dimensions}"
)
points = self._client.search(
points = _vector_search_points(
self._client,
collection_name=self._collection_name,
query_vector=vector,
vector=vector,
query_filter=Filter(
must=[
FieldCondition(key="section_key", match=MatchValue(value="chi_dinh")),
@@ -420,7 +460,6 @@ class QdrantRetriever:
]
),
limit=limit * 4,
with_payload=True,
)
hits: list[SearchHit] = []
for point in points: