This commit is contained in:
team3
2026-07-04 02:32:31 +02:00
parent 91b0d00aa1
commit c4caf31ed0
38 changed files with 3849 additions and 118 deletions

View File

@@ -29,7 +29,7 @@ from rules import FORMATE, formats_stats, guide_lock, ist_completed, load_learns
from models import (
GuideCreateRequest, GuideResponse,
TopicCreateRequest,
BlocksCreateRequest, BlocksResetStageRequest, BlocksCardRestartRequest, BlocksStatusResponse,
BlocksCreateRequest, BlocksResetStageRequest, BlocksCardRestartRequest, BlocksStatusResponse, QaRunRequest, RepairRequest,
GuideCardResetRequest, GuideFormatRequest,
GuideBoardResetRequest, GuideChatRequest, GuideChatResponse,
ProviderInfo,
@@ -140,7 +140,8 @@ async def create_blocks(req: BlocksCreateRequest):
raise HTTPException(400, "Link must start with http:// or https://.")
qp.parent.mkdir(parents=True, exist_ok=True)
atomic_write_json(qp, {"type": type, "location": location, "spec": req.instructions.strip()})
asyncio.create_task(generate_blocks(topic, req.instructions.strip(), req.provider, research=req.research))
asyncio.create_task(generate_blocks(topic, req.instructions.strip(), req.provider,
research=req.research, qa_force=req.qa_force))
return {"ok": True}
@@ -157,6 +158,48 @@ async def get_blocks_board(topic: str):
return snap
_qa_laeuft: set[str] = set()
@router.post("/blocks/qa")
async def run_qa_route(req: QaRunRequest):
"""Manual QA run (like the gate: incl. LLM samples); the badge reads the written report."""
if req.topic in _qa_laeuft:
return {"status": "läuft bereits"}
_qa_laeuft.add(req.topic)
try:
import qa
report = await qa.qa_report(req.topic, llm=req.llm)
if report is None:
raise HTTPException(status_code=404, detail="keine fertigen Bausteine")
await asyncio.to_thread(qa._write_report, report)
return {"note": report["note"], "note_artefakte": report["note_artefakte"]}
finally:
_qa_laeuft.discard(req.topic)
_repair_laeuft: set[str] = set()
@router.post("/blocks/repair")
async def run_repair_route(req: RepairRequest):
"""Fix the latest QA findings in place: hygiene, confirmed duplicates, foreign/unreal blocks."""
topic = req.topic.strip()
if (await blocks_status(topic))["generating"]:
return {"status": "generating"}
if topic in _repair_laeuft:
return {"status": "läuft bereits"}
_repair_laeuft.add(topic)
try:
import repair
res = await repair.repair_befunde(topic)
if "fehler" in res:
raise HTTPException(status_code=404, detail=res["fehler"])
return res
finally:
_repair_laeuft.discard(topic)
@router.post("/blocks/research")
async def add_blocks_research(topic: str, provider: str = "claude"):
"""Attach one more research agent — to the live flow, or attach-or-start."""