updates UI

This commit is contained in:
mike
2026-07-01 05:42:20 +02:00
parent 251d9b1cc8
commit 94419d7673
5 changed files with 298 additions and 95 deletions

View File

@@ -1508,6 +1508,8 @@ def _write_all_static() -> None:
"anatomical_completeness": p[20],
"facial_direction": p[21],
"objects": obj_list,
"description": p[23],
"filepath": p[24],
})
print(f"[static] write_all: {len(db_images)} total images, {archived_count} archived")
try:
@@ -2144,16 +2146,15 @@ def start_multi_ref(req: MultiRefRequest):
class RefineRequest(BaseModel):
prompt: str
prompt: str = ""
filename: str | None = None
user_instruction: str | None = None
field: str | None = None
@app.post("/refine-prompt")
def refine_prompt(req: RefineRequest):
"""Refine a prompt using the external uncensored chat LLM."""
if not req.prompt:
raise HTTPException(400, "Prompt is required")
"""Refine or create a prompt/description using the external uncensored chat LLM."""
context_str = ""
if req.filename:
try:
@@ -2197,9 +2198,22 @@ def refine_prompt(req: RefineRequest):
except Exception as db_err:
print(f"[refine-prompt] database error for {req.filename}: {db_err}")
user_content = f"Refine this pose: {req.prompt}"
field_label = req.field if req.field else "text"
if req.prompt:
if req.user_instruction:
user_content = f"Refine this {field_label} according to the following instructions:\n{req.user_instruction}\n\nOriginal {field_label}:\n{req.prompt}"
else:
user_content = f"Refine this {field_label} to make it more descriptive, detailed, and high-quality.\n\nOriginal {field_label}:\n{req.prompt}"
else:
# Prompt/text is empty, so we are creating one from scratch!
if req.user_instruction:
user_content = f"Create a new {field_label} from scratch according to these instructions:\n{req.user_instruction}"
else:
user_content = f"Create a new detailed and high-quality {field_label} from scratch."
if context_str:
user_content += f"\n\nUse the following image context details to ensure the refined prompt matches the reference characteristics closely:\n{context_str}"
user_content += f"\n\nUse the following image context details to ensure the output matches the reference characteristics closely:\n{context_str}"
# Use the same API as gen_poses.py
llm_api = "http://192.168.1.160:8001/v1/chat/completions"
@@ -2221,7 +2235,8 @@ def refine_prompt(req: RefineRequest):
try:
database.save_db_prompt("refine", refined, {
"original": req.prompt,
"filename": req.filename
"filename": req.filename,
"field": req.field
})
except Exception as db_err:
print(f"[refine-prompt] failed to save to prompt table: {db_err}")
@@ -2712,6 +2727,7 @@ def list_images(archived: bool = False, bypass_static: bool = False):
"facial_direction": p[21],
"objects": obj_list,
"description": p[23] if len(p) > 23 else None,
"filepath": p[24] if len(p) > 24 else None,
})
db_images.sort(
key=lambda x: _get_cached_file_meta(x["filename"], output_dir)[1],