feat: add POST /configbuilder/preview endpoint
Both runtime (generate_config) and preview now invoke state_to_configs_json — single source of truth, drift-proof. The Builder UI will fetch this endpoint instead of running a parallel JS transformer (next commit removes that JS code). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
3e9f9316c9
commit
9ff76dd8ab
@@ -1331,5 +1331,27 @@ async def save_lora_triggers_endpoint(request):
|
||||
|
||||
print(f"[ConfigBuilder] ✏️ Saved {len(triggers)} trigger words for: {normalized}")
|
||||
return web.json_response({"status": "saved", "lora_name": normalized, "triggers": triggers})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@server.PromptServer.instance.routes.post("/configbuilder/preview")
|
||||
async def preview_endpoint(request):
|
||||
"""
|
||||
Preview endpoint — runs state_to_configs_json on the POSTed builder UI
|
||||
state and returns the resulting configs_json string. The Builder UI's
|
||||
JSON Preview panel calls this. Single source of truth: this endpoint and
|
||||
generate_config() share state_to_configs_json, so they cannot disagree.
|
||||
"""
|
||||
try:
|
||||
body = await request.json()
|
||||
state = body.get("state")
|
||||
if not isinstance(state, dict):
|
||||
return web.json_response(
|
||||
{"error": "Missing or invalid 'state' object in request body"},
|
||||
status=400,
|
||||
)
|
||||
configs_json = UltimateConfigBuilder.state_to_configs_json(state)
|
||||
return web.json_response({"configs_json": configs_json})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
Reference in New Issue
Block a user