llm-api/exercise_router.py aktualisiert
All checks were successful
Deploy Trainer_LLM to llm-node / deploy (push) Successful in 2s
All checks were successful
Deploy Trainer_LLM to llm-node / deploy (push) Successful in 2s
This commit is contained in:
parent
380b361e70
commit
21ce1dc395
|
|
@ -1,13 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
exercise_router.py – v1.6.1
|
exercise_router.py – v1.6.2
|
||||||
|
|
||||||
Änderungen ggü. v1.6.0:
|
Fix:
|
||||||
- **Idempotenz-Fix:** Qdrant-Scroll liefert nun explizit den Payload (`WithPayloadSelector(enable=True)`)
|
- Entfernt Import von `WithPayloadSelector` (nicht in allen qdrant-client Builds exportiert)
|
||||||
für `/exercise/by-external-id` und `/exercise/{id}`. Dadurch kann der Importer den gespeicherten
|
- Scroll-Aufrufe liefern Payload jetzt über `with_payload=True` (breit kompatibel)
|
||||||
Fingerprint korrekt gegen den Recalc-Hash prüfen (keine Phantom-Updates mehr).
|
- Rest wie v1.6.1: Capability-Facetten + Listen-Normalisierung, Idempotenz via external_id
|
||||||
- Capability-Facetten & Listen-Normalisierung wie in v1.6.0.
|
|
||||||
- Keine API-Signaturänderungen.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from fastapi import APIRouter, HTTPException, Query
|
from fastapi import APIRouter, HTTPException, Query
|
||||||
|
|
@ -24,7 +22,6 @@ from qdrant_client.models import (
|
||||||
Filter,
|
Filter,
|
||||||
FieldCondition,
|
FieldCondition,
|
||||||
MatchValue,
|
MatchValue,
|
||||||
WithPayloadSelector,
|
|
||||||
)
|
)
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
@ -93,7 +90,7 @@ def _lookup_by_external_id(external_id: str) -> Optional[Dict[str, Any]]:
|
||||||
collection_name=COLLECTION,
|
collection_name=COLLECTION,
|
||||||
scroll_filter=flt,
|
scroll_filter=flt,
|
||||||
limit=1,
|
limit=1,
|
||||||
with_payload=WithPayloadSelector(enable=True),
|
with_payload=True,
|
||||||
)
|
)
|
||||||
if not pts:
|
if not pts:
|
||||||
return None
|
return None
|
||||||
|
|
@ -209,7 +206,7 @@ def get_exercise(exercise_id: str):
|
||||||
collection_name=COLLECTION,
|
collection_name=COLLECTION,
|
||||||
scroll_filter=Filter(must=[FieldCondition(key="id", match=MatchValue(value=exercise_id))]),
|
scroll_filter=Filter(must=[FieldCondition(key="id", match=MatchValue(value=exercise_id))]),
|
||||||
limit=1,
|
limit=1,
|
||||||
with_payload=WithPayloadSelector(enable=True),
|
with_payload=True,
|
||||||
)
|
)
|
||||||
if not pts:
|
if not pts:
|
||||||
raise HTTPException(status_code=404, detail="not found")
|
raise HTTPException(status_code=404, detail="not found")
|
||||||
|
|
@ -222,7 +219,7 @@ def get_exercise(exercise_id: str):
|
||||||
def delete_by_external_id(external_id: str = Query(...)):
|
def delete_by_external_id(external_id: str = Query(...)):
|
||||||
_ensure_collection()
|
_ensure_collection()
|
||||||
flt = Filter(must=[FieldCondition(key="external_id", match=MatchValue(value=external_id))])
|
flt = Filter(must=[FieldCondition(key="external_id", match=MatchValue(value=external_id))])
|
||||||
pts, _ = qdrant.scroll(collection_name=COLLECTION, scroll_filter=flt, limit=10000, with_payload=WithPayloadSelector(enable=False))
|
pts, _ = qdrant.scroll(collection_name=COLLECTION, scroll_filter=flt, limit=10000, with_payload=False)
|
||||||
ids = [str(p.id) for p in pts]
|
ids = [str(p.id) for p in pts]
|
||||||
if not ids:
|
if not ids:
|
||||||
return DeleteResponse(status="🔍 Keine Einträge gefunden.", count=0, collection=COLLECTION)
|
return DeleteResponse(status="🔍 Keine Einträge gefunden.", count=0, collection=COLLECTION)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user