This commit is contained in:
team3
2026-07-08 18:55:36 +02:00
parent 224ba1ed4f
commit 9a6ab0937b
15 changed files with 172 additions and 55 deletions

View File

@@ -9,7 +9,7 @@ from datetime import datetime, timedelta, timezone
from fastapi import APIRouter, HTTPException
from fastapi.responses import Response
from agents import active_agents, provider_available
from agents import active_agents, agent_ebene, provider_available
from config import DEFAULT_PROVIDER, PROJECTS_DIR, UNI_DIR, PROVIDERS
from database import (
create_guide, delete_guide, get_guide, list_guides, update_guide,
@@ -168,7 +168,7 @@ async def create_blocks(req: BlocksCreateRequest):
asyncio.create_task(generate_blocks(topic, req.instructions.strip(), req.provider,
research=req.research, qa_force=req.qa_force,
auto_inventory=req.auto_inventory, auto_artefacts=req.auto_artefacts,
auto_guide=req.auto_guide))
auto_guide=req.auto_guide, only_artefacts=req.only_artefacts))
return {"ok": True}
@@ -180,7 +180,8 @@ async def get_blocks_board(topic: str):
snap["generating"] = status["generating"]
snap["progress"] = status["progress"]
snap["error"] = status["error"]
snap["agents"] = [{"key": a["key"], "label": a["label"] or a["key"].removeprefix(f"blocks-{topic}-"), "runtime": a["runtime"]}
snap["agents"] = [{"key": a["key"], "label": a["label"] or a["key"].removeprefix(f"blocks-{topic}-"),
"runtime": a["runtime"], "ebene": agent_ebene(a["key"])}
for a in active_agents(f"blocks-{topic}-")]
return snap
@@ -201,11 +202,13 @@ async def run_qa_route(req: QaRunRequest):
raise HTTPException(status_code=404, detail="keine fertigen Bausteine")
await qa.write_report(report)
note_guide = None
# ebene-scoped: ein Inventar-/Artefakt-QA-Klick misst NICHT den (teuren) Guide mit.
guide_scope = req.ebene in (None, "guide")
try: # fertiger Guide vorhanden → mitmessen (ein Klick, drei Noten); best-effort
import guide_qa
from database import list_guide_cards
if any(c["stage"] == "done" and (c.get("md") or "").strip()
for c in await list_guide_cards(req.topic)):
if guide_scope and any(c["stage"] == "done" and (c.get("md") or "").strip()
for c in await list_guide_cards(req.topic)):
grep = await guide_qa.guide_qa_report(req.topic, llm=req.llm)
if grep:
await asyncio.to_thread(guide_qa._write_report, grep)
@@ -658,7 +661,13 @@ async def block_exam_route(req: BlockExamRequest):
@router.post("/guides", response_model=GuideResponse)
async def create(req: GuideCreateRequest):
guides, levels = await load_learnstate()
reason = guide_lock(req.topic.strip(), req.format, guides, levels)
from database import list_blocks
from paths import blocks_path
topic = req.topic.strip()
# DB is authoritative (generate_guide builds from it); blocks.md is only a legacy fallback
# and is absent when the inventory paused at the QA gate — don't lock the guide on the file.
has_blocks = bool(await list_blocks(topic, status="consensus")) or blocks_path(topic).exists()
reason = guide_lock(topic, req.format, guides, levels, has_blocks)
if reason:
raise HTTPException(400 if reason == "Erst Blocks erstellen" else 409, reason) # string matches rules.py contract
await create_topic(req.topic.strip())