update
This commit is contained in:
@@ -248,12 +248,17 @@ def _beispiel_pruefen(inh: dict) -> tuple[bool, dict]:
|
||||
return True, inh
|
||||
|
||||
|
||||
def _formen_gate(topic: str) -> None:
|
||||
def _formen_gate(topic: str, atom_ids: list[int] | None = None) -> None:
|
||||
"""Kandidat-Beispiele durch ihr Form-Gate: Syntax/Struktur ungültig → verworfen
|
||||
(fail-closed für den Inhalt; ein fehlendes Beispiel ist erlaubt, optional)."""
|
||||
for b in db.query(
|
||||
"SELECT ar.* FROM artefakte ar JOIN atome a ON a.id=ar.atom_id"
|
||||
" WHERE a.topic=? AND ar.typ='beispiel' AND ar.status='kandidat'", (topic,)):
|
||||
(fail-closed für den Inhalt; ein fehlendes Beispiel ist erlaubt, optional).
|
||||
atom_ids: optional auf einen Chunk beschränken (Pipeline pro Kette)."""
|
||||
sql = ("SELECT ar.* FROM artefakte ar JOIN atome a ON a.id=ar.atom_id"
|
||||
" WHERE a.topic=? AND ar.typ='beispiel' AND ar.status='kandidat'")
|
||||
params: tuple = (topic,)
|
||||
if atom_ids:
|
||||
sql += f" AND ar.atom_id IN ({','.join('?' * len(atom_ids))})"
|
||||
params += tuple(atom_ids)
|
||||
for b in db.query(sql, params):
|
||||
inh = db.uj(b["inhalt"], {})
|
||||
ok, inh_neu = _beispiel_pruefen(inh)
|
||||
if not ok:
|
||||
@@ -262,13 +267,22 @@ def _formen_gate(topic: str) -> None:
|
||||
db.update("artefakte", "id", b["id"], inhalt=db.j(inh_neu))
|
||||
|
||||
|
||||
async def _kette(ctx: llm.Kontext, chunk: list[dict]) -> None:
|
||||
"""gen→gate→verify EINES Chunks verkettet — der Verify braucht nur die eigenen
|
||||
Kandidaten, nicht die Generierung fremder Chunks (Stage-Barriere kostete
|
||||
Wall-Clock: 1 Nachzügler blockierte alle Verifies)."""
|
||||
ohne = [a for a in chunk if not db.one(
|
||||
"SELECT id FROM artefakte WHERE atom_id=? AND typ='flashcard'"
|
||||
" AND status!='verworfen' LIMIT 1", (a["id"],))]
|
||||
if ohne:
|
||||
await _generieren(ctx, ohne)
|
||||
_formen_gate(ctx.topic, [a["id"] for a in chunk])
|
||||
await _verifizieren(ctx, chunk)
|
||||
|
||||
|
||||
async def bauen(ctx: llm.Kontext) -> None:
|
||||
ctx.ebene = EBENE
|
||||
neu = _chunks(ctx.topic, nur_ohne=True)
|
||||
await llm.alle(_generieren(ctx, c) for c in neu)
|
||||
_formen_gate(ctx.topic) # form-spezifische Syntax/Struktur-Gates vor dem Panel
|
||||
alle = _chunks(ctx.topic, nur_ohne=False)
|
||||
await llm.alle(_verifizieren(ctx, c) for c in alle)
|
||||
await llm.alle(_kette(ctx, c) for c in _chunks(ctx.topic, nur_ohne=False))
|
||||
|
||||
|
||||
def messen(ctx: llm.Kontext) -> list[dict]:
|
||||
|
||||
Reference in New Issue
Block a user