llm-api/plan_session_router.py aktualisiert
All checks were successful
Deploy Trainer_LLM to llm-node / deploy (push) Successful in 1s
All checks were successful
Deploy Trainer_LLM to llm-node / deploy (push) Successful in 1s
This commit is contained in:
parent
36c82ac942
commit
ff58caaad0
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
plan_session_router.py – v0.1.0 (WP-15)
|
plan_session_router.py – v0.2.0 (WP-15)
|
||||||
|
|
||||||
CRUD-Minimum für Plan-Sessions (POST/GET).
|
CRUD-Minimum für Plan-Sessions (POST/GET) mit Referenz-Validierung.
|
||||||
Kompatibel zum Qdrant-Client-Stil der bestehenden Router.
|
Kompatibel zum Qdrant-Client-Stil der bestehenden Router.
|
||||||
"""
|
"""
|
||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
|
|
@ -21,6 +21,7 @@ router = APIRouter(tags=["plan_sessions"])
|
||||||
# Konfiguration
|
# Konfiguration
|
||||||
# -----------------
|
# -----------------
|
||||||
PLAN_SESSION_COLLECTION = os.getenv("PLAN_SESSION_COLLECTION", "plan_sessions")
|
PLAN_SESSION_COLLECTION = os.getenv("PLAN_SESSION_COLLECTION", "plan_sessions")
|
||||||
|
PLAN_COLLECTION = os.getenv("PLAN_COLLECTION", "plans")
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# Modelle
|
# Modelle
|
||||||
|
|
@ -86,6 +87,10 @@ def _get_by_field(collection: str, key: str, value: Any) -> Optional[Dict[str, A
|
||||||
@router.post("/plan_sessions", response_model=PlanSession)
|
@router.post("/plan_sessions", response_model=PlanSession)
|
||||||
def create_plan_session(s: PlanSession):
|
def create_plan_session(s: PlanSession):
|
||||||
_ensure_collection(PLAN_SESSION_COLLECTION)
|
_ensure_collection(PLAN_SESSION_COLLECTION)
|
||||||
|
# Referenz auf Plan prüfen
|
||||||
|
if not _get_by_field(PLAN_COLLECTION, "id", s.plan_id):
|
||||||
|
raise HTTPException(status_code=422, detail=f"Unknown plan_id: {s.plan_id}")
|
||||||
|
|
||||||
# Normalisieren
|
# Normalisieren
|
||||||
s.used_equipment = _norm_list(s.used_equipment)
|
s.used_equipment = _norm_list(s.used_equipment)
|
||||||
payload = s.model_dump()
|
payload = s.model_dump()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user