Dateien nach "app/core" hochladen
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
This commit is contained in:
parent
21924541dc
commit
62f8f4b313
|
|
@ -143,13 +143,45 @@ def _coerce_for_collection(client: QdrantClient, collection_name: str, points: L
|
||||||
except Exception:
|
except Exception:
|
||||||
return points
|
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 ---------------------
|
# --------------------- Qdrant ops ---------------------
|
||||||
|
|
||||||
def upsert_batch(client: QdrantClient, collection: str, points: List[rest.PointStruct]) -> None:
|
def upsert_batch(client: QdrantClient, collection: str, points: List[rest.PointStruct]) -> None:
|
||||||
if not points:
|
if not points:
|
||||||
return
|
return
|
||||||
pts = _coerce_for_collection(client, collection, points)
|
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 ---
|
# --- Optional search helpers ---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user