update
This commit is contained in:
@@ -550,6 +550,36 @@ Kein weiterer Text, nur das JSON-Array.
|
||||
"""
|
||||
|
||||
|
||||
def _build_topic_suggest_prompt(problem: str, existing_topics: list[str]) -> str:
|
||||
template = (TEMPLATES_DIR / "Format" / "Suche.md").read_text(encoding="utf-8")
|
||||
existing = "\n".join(f"- {t}" for t in existing_topics) if existing_topics else "(keine)"
|
||||
return template.replace("{problem}", problem).replace("{existing}", existing)
|
||||
|
||||
|
||||
async def suggest_topics(problem: str, existing_topics: list[str] | None = None) -> list[dict]:
|
||||
try:
|
||||
prompt = _build_topic_suggest_prompt(problem, existing_topics or [])
|
||||
returncode, stdout, stderr = await _run_claude(
|
||||
"topic-suggest-" + str(uuid.uuid4()), prompt, 120, tools=None, model=MODEL_BAUSTEIN_GEN
|
||||
)
|
||||
if returncode != 0:
|
||||
return []
|
||||
items = _parse_json(stdout)
|
||||
if not isinstance(items, list):
|
||||
return []
|
||||
result = []
|
||||
for item in items:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
title = str(item.get("title", "")).strip()[:100]
|
||||
if not title:
|
||||
continue
|
||||
result.append({"title": title, "reason": str(item.get("reason", "")).strip()})
|
||||
return result
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
async def sort_bausteine(topic: str, bausteine: list[dict], instructions: str = "") -> None:
|
||||
_sorting.add(topic)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user