Save cached character profiles without rerun

This commit is contained in:
2026-06-24 20:52:20 +02:00
parent 4172797b43
commit fba1825496
4 changed files with 176 additions and 8 deletions
+36 -1
View File
@@ -3,6 +3,13 @@ from __future__ import annotations
import json
import random
try:
from aiohttp import web
from server import PromptServer
except Exception:
web = None
PromptServer = None
try:
from .loop_nodes import ANY_TYPE, LOOP_NODE_CLASS_MAPPINGS, LOOP_NODE_DISPLAY_NAME_MAPPINGS
from .prompt_builder import (
@@ -49,6 +56,7 @@ try:
generation_profile_choices,
hardcore_detail_density_choices,
load_character_profile_json,
save_character_profile_payload,
seed_mode_choices,
subcategory_choices,
)
@@ -100,6 +108,7 @@ except ImportError:
generation_profile_choices,
hardcore_detail_density_choices,
load_character_profile_json,
save_character_profile_payload,
seed_mode_choices,
subcategory_choices,
)
@@ -107,6 +116,20 @@ except ImportError:
from krea_formatter import format_krea2_prompt
if PromptServer is not None and web is not None:
@PromptServer.instance.routes.post("/sxcp/profile/save_cached")
async def sxcp_save_cached_profile(request):
try:
payload = await request.json()
result = save_character_profile_payload(
profile_name=str(payload.get("profile_name") or ""),
profile_json=payload.get("profile_json") or "",
)
return web.json_response(result)
except Exception as exc:
return web.json_response({"error": str(exc)}, status=400)
class SxCPPromptBuilder:
@classmethod
def INPUT_TYPES(cls):
@@ -984,6 +1007,8 @@ class SxCPManSlot:
class SxCPCharacterProfileSave:
OUTPUT_NODE = True
@classmethod
def INPUT_TYPES(cls):
return {
@@ -1042,7 +1067,7 @@ class SxCPCharacterProfileSave:
figure=figure,
save_now=save_now,
)
return (
result = (
profile["profile_json"],
profile["descriptor"],
profile["profile_name"],
@@ -1050,6 +1075,16 @@ class SxCPCharacterProfileSave:
profile["status"],
profile["profile_json"],
)
return {
"ui": {
"profile_json": [profile["profile_json"]],
"descriptor": [profile["descriptor"]],
"profile_name": [profile["profile_name"]],
"saved_path": [profile["saved_path"]],
"status": [profile["status"]],
},
"result": result,
}
class SxCPCharacterProfileLoad: