fix: make qdrant vector hit parsing total
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Qdrant-backed vector store for one workspace-owned semantic collection."""
|
||||
|
||||
import math
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from uuid import NAMESPACE_URL, uuid5
|
||||
@@ -477,16 +478,25 @@ class QdrantVectorStore:
|
||||
raise VectorResponseError("Qdrant returned malformed query response")
|
||||
payload = point.get("payload")
|
||||
score = point.get("score")
|
||||
required_payload_leaves = (
|
||||
"record_key", "record_kind", "kind", "ref", "title", "content"
|
||||
)
|
||||
if (
|
||||
not isinstance(payload, dict)
|
||||
or type(score) not in (int, float)
|
||||
or any(
|
||||
key in payload and not isinstance(payload[key], str)
|
||||
for key in ("record_key", "record_kind", "kind", "ref", "title", "content")
|
||||
key not in payload or not isinstance(payload[key], str)
|
||||
for key in required_payload_leaves
|
||||
)
|
||||
):
|
||||
raise VectorResponseError("Qdrant returned malformed query response")
|
||||
return hit_from_metadata(float(score), payload)
|
||||
try:
|
||||
similarity = float(score)
|
||||
except (OverflowError, ValueError) as exc:
|
||||
raise VectorResponseError("Qdrant returned malformed query response") from exc
|
||||
if not math.isfinite(similarity):
|
||||
raise VectorResponseError("Qdrant returned malformed query response")
|
||||
return hit_from_metadata(similarity, payload)
|
||||
|
||||
def _call(self, method: str, path: str, payload: dict | None, allow_missing: bool = False) -> dict | None:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user