Dateien nach "app/core" hochladen
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s

This commit is contained in:
Lars 2025-11-08 16:42:33 +01:00
parent 21924541dc
commit 62f8f4b313

View File

@ -143,13 +143,45 @@ def _coerce_for_collection(client: QdrantClient, collection_name: str, points: L
except Exception:
return points
def _try_upsert_with_names(client: QdrantClient, collection: str, points: List[rest.PointStruct]) -> None:
schema = _get_vector_schema(client, collection)
if schema.get("kind") != "named":
raise
names = schema.get("names") or []
# prefer env-defined names first
pref = _preferred_name(names)
order = [pref] + [n for n in names if n != pref]
for name in order:
converted: List[rest.PointStruct] = []
for pt in points:
vec = getattr(pt, "vector", None)
if isinstance(vec, dict) and name in vec:
converted.append(pt)
elif vec is not None:
converted.append(rest.PointStruct(id=pt.id, vectors={name: vec}, payload=pt.payload))
else:
converted.append(pt)
try:
client.upsert(collection_name=collection, points=converted, wait=True)
return
except Exception:
continue
raise
# --------------------- Qdrant ops ---------------------
def upsert_batch(client: QdrantClient, collection: str, points: List[rest.PointStruct]) -> None:
if not points:
return
pts = _coerce_for_collection(client, collection, points)
client.upsert(collection_name=collection, points=pts, wait=True)
try:
client.upsert(collection_name=collection, points=pts, wait=True)
except Exception as e:
msg = str(e)
if "Not existing vector name" in msg or "named vector" in msg:
_try_upsert_with_names(client, collection, points)
else:
raise
# --- Optional search helpers ---