This commit is contained in:
team3
2026-06-10 23:12:17 +02:00
parent 58fd209174
commit 54eaa1c89b
15 changed files with 367 additions and 41 deletions

View File

@@ -1396,6 +1396,8 @@ def _element_fields(data: dict) -> dict | None:
"description": str(data.get("description", "")).strip(),
"examples": listen["examples"],
"hints": listen["hints"],
"aufgabe": str(data.get("aufgabe", "")).strip(),
"loesung": str(data.get("loesung", "")).strip(),
}
@@ -1418,7 +1420,7 @@ def _topic_context(topic: str, limit: int = 12000) -> str:
async def generate_element(topic: str, hint: str, provider: str = DEFAULT_PROVIDER) -> dict:
"""Erstellt Element-Felder per KI. Fallback: nur Titel aus dem Stichwort."""
fallback = {"title": hint.strip() or "Neues Element", "description": "", "examples": [], "hints": []}
fallback = {"title": hint.strip() or "Neues Element", "description": "", "examples": [], "hints": [], "aufgabe": "", "loesung": ""}
try:
prompt = _prompt(
"Element-Create",
@@ -1454,7 +1456,7 @@ def _parse_suggestions(stdout: str) -> list[dict] | None:
text = str(s.get("text", "")).strip()
target = s.get("target")
content = str(s.get("content", "")).strip()
if text and content and target in ("description", "examples", "hints"):
if text and content and target in ("description", "examples", "hints", "aufgabe", "loesung"):
if target == "examples":
content = _fence(content)
suggestions.append({"text": text, "target": target, "content": content})
@@ -1465,7 +1467,7 @@ async def check_element(element: dict, provider: str = DEFAULT_PROVIDER) -> list
"""Zweischrittige Prüfung auf fehlende Infos: Recherche → Verifizieren. None bei Fehler."""
try:
element_json = json.dumps(
{k: element[k] for k in ("title", "description", "examples", "hints")},
{k: element[k] for k in ("title", "description", "examples", "hints", "aufgabe", "loesung")},
ensure_ascii=False, indent=1,
)
context = _topic_context(element["topic"])
@@ -1502,7 +1504,7 @@ async def check_element(element: dict, provider: str = DEFAULT_PROVIDER) -> list
def _element_json(element: dict) -> str:
return json.dumps(
{k: element[k] for k in ("title", "description", "examples", "hints")},
{k: element[k] for k in ("title", "description", "examples", "hints", "aufgabe", "loesung")},
ensure_ascii=False, indent=1,
)
@@ -1518,7 +1520,7 @@ def _validate_change(c, element: dict) -> dict | None:
content = str(c.get("content", "")).strip()
if not text or action not in ("entfernen", "anpassen", "hinzufuegen"):
return None
if target not in ("title", "description", "examples", "hints"):
if target not in ("title", "description", "examples", "hints", "aufgabe", "loesung"):
return None
if action in ("anpassen", "hinzufuegen") and not content:
return None