update
This commit is contained in:
@@ -360,11 +360,11 @@ FORMAT-SPEZIFIKATION:
|
||||
REFERENZ-BEISPIEL:
|
||||
{reference}
|
||||
|
||||
Schlage bis zu 20 Bausteine vor. Antworte AUSSCHLIESSLICH mit einem JSON-Array. Jedes Element hat:
|
||||
Schlage 8 Bausteine vor. Antworte AUSSCHLIESSLICH mit einem JSON-Array. Jedes Element hat:
|
||||
- "title"
|
||||
- "description"
|
||||
- "purpose"
|
||||
- "examples": Array mit 4 Objekten {{"label": "...", "code": "..."}}
|
||||
- "examples": Array mit 1 Objekt {{"label": "...", "code": "..."}}
|
||||
|
||||
Orientiere dich an der Spezifikation und Referenz. NUR das JSON-Array, kein weiterer Text.
|
||||
"""
|
||||
@@ -383,7 +383,7 @@ REFERENZ-BEISPIEL:
|
||||
{reference}
|
||||
|
||||
Antworte AUSSCHLIESSLICH mit einem JSON-Objekt mit den Feldern "description", "purpose", "examples".
|
||||
"examples" ist ein Array mit 4 Objekten {{"label": "...", "code": "..."}}.
|
||||
"examples" ist ein Array mit 1 Objekt {{"label": "...", "code": "..."}}.
|
||||
Orientiere dich an der Spezifikation und Referenz. Kein weiterer Text, nur das JSON.
|
||||
"""
|
||||
|
||||
@@ -409,7 +409,7 @@ async def generate_suggestions(topic: str, html_paths: list[Path]) -> None:
|
||||
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
suggestions = []
|
||||
for item in items[:20]:
|
||||
for item in items[:8]:
|
||||
suggestions.append({
|
||||
"id": str(uuid.uuid4()),
|
||||
"topic": topic,
|
||||
@@ -450,3 +450,49 @@ async def generate_baustein_detail(baustein_id: str, topic: str, title: str) ->
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _build_baustein_rework_prompt(topic: str, title: str, current: dict, instructions: str) -> str:
|
||||
current_json = json.dumps({
|
||||
"title": title,
|
||||
"description": current.get("description", ""),
|
||||
"purpose": current.get("purpose", ""),
|
||||
"examples": current.get("examples", []),
|
||||
}, ensure_ascii=False, indent=2)
|
||||
|
||||
return f"""Überarbeite den Baustein "{title}" zum Thema "{topic}" gemäß den Anweisungen.
|
||||
|
||||
AKTUELLER STAND:
|
||||
{current_json}
|
||||
|
||||
ANWEISUNGEN VOM NUTZER:
|
||||
{instructions}
|
||||
|
||||
Antworte AUSSCHLIESSLICH mit einem JSON-Objekt mit den Feldern "description", "purpose", "examples".
|
||||
"examples" ist ein Array mit Objekten {{"label": "...", "code": "..."}}.
|
||||
Kein weiterer Text, nur das JSON.
|
||||
"""
|
||||
|
||||
|
||||
async def rework_baustein(baustein_id: str, topic: str, title: str, current: dict, instructions: str) -> None:
|
||||
try:
|
||||
prompt = _build_baustein_rework_prompt(topic, title, current, instructions)
|
||||
returncode, stdout, stderr = await _run_claude("baustein-" + baustein_id, prompt, 60, tools=None)
|
||||
|
||||
if returncode != 0:
|
||||
return
|
||||
|
||||
data = _parse_json(stdout)
|
||||
if not isinstance(data, dict):
|
||||
return
|
||||
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
await update_baustein(
|
||||
baustein_id,
|
||||
description=data.get("description", ""),
|
||||
purpose=data.get("purpose", ""),
|
||||
example=json.dumps(data.get("examples", []), ensure_ascii=False),
|
||||
updated_at=now,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -37,6 +37,10 @@ class BausteinCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=200)
|
||||
|
||||
|
||||
class BausteinReworkRequest(BaseModel):
|
||||
instructions: str = Field(min_length=1, max_length=2000)
|
||||
|
||||
|
||||
class BausteinResponse(BaseModel):
|
||||
id: str
|
||||
topic: str
|
||||
|
||||
@@ -11,10 +11,10 @@ from database import (
|
||||
create_baustein as db_create_baustein, list_bausteine, get_baustein, delete_baustein as db_delete_baustein,
|
||||
list_suggestions, get_suggestion, update_suggestion, delete_suggestion,
|
||||
)
|
||||
from generator import generate_guide, rework_guide, cancel_guide, generate_suggestions, generate_baustein_detail, is_suggestions_generating
|
||||
from generator import generate_guide, rework_guide, cancel_guide, generate_suggestions, generate_baustein_detail, rework_baustein, is_suggestions_generating
|
||||
from models import (
|
||||
GuideCreateRequest, GuideReworkRequest, GuideResponse,
|
||||
BausteinCreateRequest, BausteinResponse, SuggestionResponse,
|
||||
BausteinCreateRequest, BausteinReworkRequest, BausteinResponse, SuggestionResponse,
|
||||
)
|
||||
from paths import final_paths
|
||||
|
||||
@@ -148,6 +148,25 @@ async def remove_baustein(baustein_id: str):
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.post("/bausteine/{baustein_id}/rework")
|
||||
async def rework_baustein_route(baustein_id: str, req: BausteinReworkRequest):
|
||||
b = await get_baustein(baustein_id)
|
||||
if b is None:
|
||||
raise HTTPException(404, "Baustein nicht gefunden")
|
||||
import json
|
||||
try:
|
||||
examples = json.loads(b.get("example") or "[]")
|
||||
except Exception:
|
||||
examples = []
|
||||
current = {
|
||||
"description": b.get("description", ""),
|
||||
"purpose": b.get("purpose", ""),
|
||||
"examples": examples,
|
||||
}
|
||||
asyncio.create_task(rework_baustein(baustein_id, b["topic"], b["title"], current, req.instructions.strip()))
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
# --- Baustein Suggestions ---
|
||||
|
||||
@router.get("/bausteine/suggestions", response_model=list[SuggestionResponse])
|
||||
|
||||
Reference in New Issue
Block a user