update
This commit is contained in:
@@ -16,6 +16,7 @@ from agents import run_agent, kill_process
|
||||
from config import MAX_CONCURRENT_GENERATIONS, TEMPLATES_DIR, TIMEOUTS
|
||||
from database import update_guide
|
||||
from jsonio import read_json_file as _json_datei
|
||||
from textkit import _STUFEN
|
||||
|
||||
log = logging.getLogger("creator.pipeline")
|
||||
|
||||
@@ -134,6 +135,29 @@ def _runde_schema(data, final: bool = False):
|
||||
return aufnehmen, rest
|
||||
|
||||
|
||||
def _stufen_schema(data, ids: set[int] | None = None):
|
||||
"""{"stufen": {"1": "einfach", …}} → {id: stufe} · sonst None.
|
||||
|
||||
Stufe ∈ {einfach, mittel, schwer}. Sind `ids` gegeben, müssen mindestens
|
||||
diese abgedeckt sein (Extras erlaubt); der Aufrufer filtert dann auf `ids`.
|
||||
"""
|
||||
if not isinstance(data, dict) or not isinstance(data.get("stufen"), dict) or not data["stufen"]:
|
||||
return None
|
||||
out: dict[int, str] = {}
|
||||
for k, v in data["stufen"].items():
|
||||
try:
|
||||
num = int(k)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
stufe = str(v).strip().casefold()
|
||||
if stufe not in _STUFEN:
|
||||
return None
|
||||
out[num] = stufe
|
||||
if ids is not None and not ids <= set(out):
|
||||
return None
|
||||
return out
|
||||
|
||||
|
||||
_MAX_RESTARTS = 2
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user