update
This commit is contained in:
@@ -148,21 +148,22 @@ def _bewertung_schema(data) -> dict | None:
|
||||
return {"feedback": feedback, "niveau": niveau}
|
||||
|
||||
|
||||
async def _gen_call(name: str, role: str, schema, provider: str, timeout: int = PRUEFUNG_TIMEOUT, **kwargs) -> dict | None:
|
||||
"""Generator-Agent: Template füllen, laufen lassen, per schema parsen · None bei Fehler."""
|
||||
async def _gen_call(name: str, role: str, schema, provider: str, timeout: int = PRUEFUNG_TIMEOUT, lane: str = "interactive", **kwargs) -> dict | None:
|
||||
"""Generator-Agent: Template füllen, laufen lassen, per schema parsen · None bei Fehler.
|
||||
lane="batch" für Hintergrund (Vorladen, Genau-Bewertung) → eigene Slot-Schlange."""
|
||||
returncode, stdout, _ = await run_agent(
|
||||
name.lower() + "-" + str(uuid.uuid4()), _prompt(name, **kwargs), timeout,
|
||||
provider=provider, role=role, capabilities="none", lane="interactive",
|
||||
provider=provider, role=role, capabilities="none", lane=lane,
|
||||
)
|
||||
return schema(_parse_json_text(stdout)) if returncode == 0 else None
|
||||
|
||||
|
||||
async def _kritik_call(name: str, provider: str, role: str = "judge", timeout: int = PRUEFUNG_TIMEOUT, **kwargs) -> list[str]:
|
||||
async def _kritik_call(name: str, provider: str, role: str = "judge", timeout: int = PRUEFUNG_TIMEOUT, lane: str = "interactive", **kwargs) -> list[str]:
|
||||
"""Kritiker-Agent (Default role judge): leere Liste = in Ordnung. Fail-open: Ausfall des
|
||||
Kritikers darf den Turn nicht blockieren, also dann ebenfalls leere Liste."""
|
||||
returncode, stdout, _ = await run_agent(
|
||||
name.lower() + "-" + str(uuid.uuid4()), _prompt(name, **kwargs), timeout,
|
||||
provider=provider, role=role, capabilities="none", lane="interactive",
|
||||
provider=provider, role=role, capabilities="none", lane=lane,
|
||||
)
|
||||
if returncode != 0:
|
||||
return []
|
||||
@@ -204,7 +205,7 @@ async def _frage_mit_kritik(
|
||||
frage = None
|
||||
for _ in range(KRITIK_MAX_RUNDEN):
|
||||
data = await _gen_call(
|
||||
"Baustein-Frage", "guide", _frage_schema, provider,
|
||||
"Baustein-Frage", "guide", _frage_schema, provider, lane="batch",
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, transcript=transcript, vermeide_block=vermeide_block,
|
||||
typ_block=typ_block, fokus_block=fokus_block, kritik_block=kritik_block,
|
||||
@@ -213,7 +214,7 @@ async def _frage_mit_kritik(
|
||||
return None
|
||||
frage = data["frage"]
|
||||
probleme = await _kritik_call(
|
||||
"Baustein-Frage-Kritik", provider, role="guide", # starke KI prüft die Regeln
|
||||
"Baustein-Frage-Kritik", provider, role="guide", lane="batch", # starke KI prüft die Regeln
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, transcript=transcript, vermeide_block=vermeide_block,
|
||||
typ_block=typ_block, fokus_block=fokus_block, frage=frage,
|
||||
@@ -238,11 +239,13 @@ async def _bewertung_mit_kritik(
|
||||
`role` = "judge" (schnell) oder "guide" (gründlich, starkes Modell mit Thinking).
|
||||
"""
|
||||
timeout = GRUENDLICH_TIMEOUT if role == "guide" else PRUEFUNG_TIMEOUT
|
||||
# Gründlich (role guide) = Nutzer wartet → interaktiv. Hintergrund-Genau (judge) → batch.
|
||||
lane = "interactive" if role == "guide" else "batch"
|
||||
kritik_block = "(keine)"
|
||||
bew = None
|
||||
for _ in range(KRITIK_MAX_RUNDEN):
|
||||
bew = await _gen_call(
|
||||
"Baustein-Bewertung", role, _bewertung_schema, provider, timeout,
|
||||
"Baustein-Bewertung", role, _bewertung_schema, provider, timeout, lane=lane,
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, frage=frage, transcript=transcript,
|
||||
begruendung_block=begruendung_block, kritik_block=kritik_block,
|
||||
@@ -250,7 +253,7 @@ async def _bewertung_mit_kritik(
|
||||
if bew is None:
|
||||
return None
|
||||
probleme = await _kritik_call(
|
||||
"Baustein-Bewertung-Kritik", provider, role=role, timeout=timeout,
|
||||
"Baustein-Bewertung-Kritik", provider, role=role, timeout=timeout, lane=lane,
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, frage=frage, transcript=transcript,
|
||||
bewertung_block=_bewertung_text(bew),
|
||||
@@ -309,7 +312,7 @@ async def pruefung_frage_variante(
|
||||
try:
|
||||
section_block, kompakt_block = _bloecke(section, kompakt)
|
||||
data = await _gen_call(
|
||||
"Baustein-Frage-Variante", "guide", _frage_schema, provider,
|
||||
"Baustein-Frage-Variante", "guide", _frage_schema, provider, lane="batch",
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, muster=muster,
|
||||
)
|
||||
@@ -378,7 +381,7 @@ async def quiz_generieren(
|
||||
"GENAU EINE Option ist richtig, die anderen drei sind klar falsch."
|
||||
)
|
||||
return await _gen_call(
|
||||
"Baustein-Quiz", "guide", (lambda d: _quiz_schema(d, schwer=schwer)), provider,
|
||||
"Baustein-Quiz", "guide", (lambda d: _quiz_schema(d, schwer=schwer)), provider, lane="batch",
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, muster=muster, anzahl_block=anzahl_block,
|
||||
)
|
||||
@@ -396,7 +399,7 @@ async def lueckwahl_generieren(
|
||||
try:
|
||||
section_block, kompakt_block = _bloecke(section, kompakt)
|
||||
return await _gen_call(
|
||||
"Baustein-Lueckwahl", "guide", _lueckwahl_schema, provider,
|
||||
"Baustein-Lueckwahl", "guide", _lueckwahl_schema, provider, lane="batch",
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, muster=muster,
|
||||
)
|
||||
@@ -427,7 +430,7 @@ async def lueckentext_generieren(
|
||||
try:
|
||||
section_block, kompakt_block = _bloecke(section, kompakt)
|
||||
return await _gen_call(
|
||||
"Baustein-Lueckentext", "guide", _lueck_schema, provider,
|
||||
"Baustein-Lueckentext", "guide", _lueck_schema, provider, lane="batch",
|
||||
topic=topic, baustein=baustein, section_block=section_block,
|
||||
kompakt_block=kompakt_block, muster=muster,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user