This commit is contained in:
root
2026-05-27 18:31:51 +00:00
parent 351f330db0
commit 6a39dc7ee2
2 changed files with 14 additions and 35 deletions

View File

@@ -24,23 +24,7 @@ FORMAT_META = {
"ExtendedGuide": {"pages": "47-60 Seiten", "time": "~5h"}, "ExtendedGuide": {"pages": "47-60 Seiten", "time": "~5h"},
} }
REVIEW_TIMEOUTS = { AGENT_TIMEOUT = 3600
"OnePager": 120,
"Cheatsheet": 120,
"MiniGuide": 180,
"BeginnerGuide": 600,
"IntermediateGuide": 600,
"ExtendedGuide": 900,
}
GENERATION_TIMEOUTS = {
"OnePager": 900,
"Cheatsheet": 900,
"MiniGuide": 1200,
"BeginnerGuide": 1800,
"IntermediateGuide": 2400,
"ExtendedGuide": 3000,
}
MAX_CONCURRENT_GENERATIONS = 6 MAX_CONCURRENT_GENERATIONS = 6
CONTENT_REVIEW_ITERATIONS = { CONTENT_REVIEW_ITERATIONS = {

View File

@@ -8,12 +8,11 @@ from datetime import datetime, timezone
from pathlib import Path from pathlib import Path
from config import ( from config import (
AGENT_TIMEOUT,
CLAUDE_CLI, CLAUDE_CLI,
CONTENT_REVIEW_ITERATIONS, CONTENT_REVIEW_ITERATIONS,
TEMPLATES_DIR, TEMPLATES_DIR,
GENERATION_TIMEOUTS,
MAX_CONCURRENT_GENERATIONS, MAX_CONCURRENT_GENERATIONS,
REVIEW_TIMEOUTS,
STORAGE_DIR, STORAGE_DIR,
) )
from database import ( from database import (
@@ -229,21 +228,19 @@ async def generate_guide(guide_id: str, topic: str, format_name: str, instructio
html_path = STORAGE_DIR / "html" / f"{guide_id}.html" html_path = STORAGE_DIR / "html" / f"{guide_id}.html"
pdf_path = STORAGE_DIR / "pdf" / f"{guide_id}.pdf" pdf_path = STORAGE_DIR / "pdf" / f"{guide_id}.pdf"
preview_dir = STORAGE_DIR / "preview" / guide_id preview_dir = STORAGE_DIR / "preview" / guide_id
timeout = GENERATION_TIMEOUTS.get(format_name, 600)
content_iters = CONTENT_REVIEW_ITERATIONS.get(format_name, 2) content_iters = CONTENT_REVIEW_ITERATIONS.get(format_name, 2)
review_timeout = REVIEW_TIMEOUTS.get(format_name, 120)
try: try:
if guide_id in _cancelled: if guide_id in _cancelled:
return return
current_step = "Generierung" current_step = "Generierung"
current_timeout = timeout current_timeout = AGENT_TIMEOUT
# Step 1: Generator-Agent erstellt HTML # Step 1: Generator-Agent erstellt HTML
await _set_progress(guide_id, "Generiere HTML…") await _set_progress(guide_id, "Generiere HTML…")
gen_prompt = _build_generator_prompt(topic, format_name, html_path, instructions) gen_prompt = _build_generator_prompt(topic, format_name, html_path, instructions)
returncode, stdout, stderr = await _run_claude(guide_id, gen_prompt, timeout) returncode, stdout, stderr = await _run_claude(guide_id, gen_prompt, AGENT_TIMEOUT)
if guide_id in _cancelled: if guide_id in _cancelled:
return return
@@ -262,9 +259,9 @@ async def generate_guide(guide_id: str, topic: str, format_name: str, instructio
await _set_progress(guide_id, f"Prüfe Inhalt… ({iteration}/{content_iters})") await _set_progress(guide_id, f"Prüfe Inhalt… ({iteration}/{content_iters})")
current_step = f"Inhalts-Review ({iteration}/{content_iters})" current_step = f"Inhalts-Review ({iteration}/{content_iters})"
current_timeout = review_timeout current_timeout = AGENT_TIMEOUT
content_prompt = _build_content_review_prompt(topic, format_name, html_path) content_prompt = _build_content_review_prompt(topic, format_name, html_path)
returncode, review_out, review_err = await _run_claude(guide_id, content_prompt, review_timeout) returncode, review_out, review_err = await _run_claude(guide_id, content_prompt, AGENT_TIMEOUT)
if returncode != 0: if returncode != 0:
await _fail(guide_id, f"Inhalts-Review-Fehler: {review_err[:1000]}") await _fail(guide_id, f"Inhalts-Review-Fehler: {review_err[:1000]}")
@@ -280,9 +277,9 @@ async def generate_guide(guide_id: str, topic: str, format_name: str, instructio
feedback = review_text.replace("FAIL", "").strip() feedback = review_text.replace("FAIL", "").strip()
await _set_progress(guide_id, f"Korrigiere Inhalt… ({iteration}/{content_iters})") await _set_progress(guide_id, f"Korrigiere Inhalt… ({iteration}/{content_iters})")
current_step = f"Inhalts-Korrektur ({iteration}/{content_iters})" current_step = f"Inhalts-Korrektur ({iteration}/{content_iters})"
current_timeout = timeout current_timeout = AGENT_TIMEOUT
fix_prompt = _build_fix_prompt(topic, format_name, html_path, feedback) fix_prompt = _build_fix_prompt(topic, format_name, html_path, feedback)
returncode, _, fix_err = await _run_claude(guide_id, fix_prompt, timeout) returncode, _, fix_err = await _run_claude(guide_id, fix_prompt, AGENT_TIMEOUT)
if returncode != 0: if returncode != 0:
await _fail(guide_id, f"Fix-Fehler: {fix_err[:1000]}") await _fail(guide_id, f"Fix-Fehler: {fix_err[:1000]}")
@@ -303,9 +300,9 @@ async def generate_guide(guide_id: str, topic: str, format_name: str, instructio
page_count = len(pngs) page_count = len(pngs)
current_step = "Stil-Review" current_step = "Stil-Review"
current_timeout = review_timeout current_timeout = AGENT_TIMEOUT
review_prompt = _build_review_prompt(format_name, pngs, page_count) review_prompt = _build_review_prompt(format_name, pngs, page_count)
returncode, review_out, review_err = await _run_claude(guide_id, review_prompt, review_timeout) returncode, review_out, review_err = await _run_claude(guide_id, review_prompt, AGENT_TIMEOUT)
if returncode != 0: if returncode != 0:
await _fail(guide_id, f"Stil-Review-Fehler: {review_err[:1000]}") await _fail(guide_id, f"Stil-Review-Fehler: {review_err[:1000]}")
@@ -316,9 +313,9 @@ async def generate_guide(guide_id: str, topic: str, format_name: str, instructio
feedback = review_text.replace("FAIL", "").strip() feedback = review_text.replace("FAIL", "").strip()
await _set_progress(guide_id, "Korrigiere Layout…") await _set_progress(guide_id, "Korrigiere Layout…")
current_step = "Stil-Korrektur" current_step = "Stil-Korrektur"
current_timeout = timeout current_timeout = AGENT_TIMEOUT
fix_prompt = _build_fix_prompt(topic, format_name, html_path, feedback) fix_prompt = _build_fix_prompt(topic, format_name, html_path, feedback)
returncode, _, fix_err = await _run_claude(guide_id, fix_prompt, timeout) returncode, _, fix_err = await _run_claude(guide_id, fix_prompt, AGENT_TIMEOUT)
if returncode != 0: if returncode != 0:
await _fail(guide_id, f"Fix-Fehler: {fix_err[:1000]}") await _fail(guide_id, f"Fix-Fehler: {fix_err[:1000]}")
@@ -362,17 +359,15 @@ async def rework_guide(guide_id: str, topic: str, format_name: str, instructions
html_path = STORAGE_DIR / "html" / f"{guide_id}.html" html_path = STORAGE_DIR / "html" / f"{guide_id}.html"
pdf_path = STORAGE_DIR / "pdf" / f"{guide_id}.pdf" pdf_path = STORAGE_DIR / "pdf" / f"{guide_id}.pdf"
timeout = GENERATION_TIMEOUTS.get(format_name, 600)
try: try:
if guide_id in _cancelled: if guide_id in _cancelled:
return return
current_step = "Überarbeitung" current_step = "Überarbeitung"
current_timeout = timeout current_timeout = AGENT_TIMEOUT
rework_prompt = _build_rework_prompt(topic, format_name, html_path, instructions) rework_prompt = _build_rework_prompt(topic, format_name, html_path, instructions)
returncode, stdout, stderr = await _run_claude(guide_id, rework_prompt, timeout) returncode, stdout, stderr = await _run_claude(guide_id, rework_prompt, AGENT_TIMEOUT)
if guide_id in _cancelled: if guide_id in _cancelled:
return return