Fixed SD Promt
This commit is contained in:
+21
-4
@@ -63,6 +63,7 @@ def _row_to_persona(row: dict) -> dict:
|
||||
"lora_name": row["lora_name"] or "",
|
||||
"lora_weight": row["lora_weight"] if row["lora_weight"] is not None else 0.8,
|
||||
"appearance_tags": row["appearance_tags"] or "",
|
||||
"appearance_prose": row.get("appearance_prose", "") or "",
|
||||
"personality": row.get("personality", "") or "",
|
||||
"scenario": row.get("scenario", "") or "",
|
||||
"first_mes": row.get("first_mes", "") or "",
|
||||
@@ -117,6 +118,7 @@ async def create_persona(
|
||||
lora_name: str = "",
|
||||
lora_weight: float = 0.8,
|
||||
appearance_tags: str = "",
|
||||
appearance_prose: str = "",
|
||||
personality: str = "",
|
||||
scenario: str = "",
|
||||
first_mes: str = "",
|
||||
@@ -138,19 +140,19 @@ async def create_persona(
|
||||
await db.execute(
|
||||
"""INSERT INTO personas
|
||||
(persona_id, name, emoji, description, prompt, custom,
|
||||
sd_enabled, lora_name, lora_weight, appearance_tags,
|
||||
sd_enabled, lora_name, lora_weight, appearance_tags, appearance_prose,
|
||||
personality, scenario, first_mes, mes_example, lorebook_json, avatar_path,
|
||||
alternate_greetings_json)
|
||||
VALUES (?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
VALUES (?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
persona_id, name, emoji, description, final_prompt,
|
||||
1 if sd_enabled else 0, lora_name, lora_weight, appearance_tags,
|
||||
1 if sd_enabled else 0, lora_name, lora_weight, appearance_tags, appearance_prose,
|
||||
personality, scenario, first_mes, mes_example, lorebook_json, avatar_path,
|
||||
alternate_greetings_json,
|
||||
),
|
||||
)
|
||||
await db.commit()
|
||||
return {
|
||||
return {
|
||||
"name": name,
|
||||
"emoji": emoji,
|
||||
"description": description,
|
||||
@@ -160,6 +162,7 @@ async def create_persona(
|
||||
"lora_name": lora_name,
|
||||
"lora_weight": lora_weight,
|
||||
"appearance_tags": appearance_tags,
|
||||
"appearance_prose": appearance_prose,
|
||||
"personality": personality,
|
||||
"scenario": scenario,
|
||||
"first_mes": first_mes,
|
||||
@@ -226,6 +229,7 @@ async def patch_persona(persona_id: str, fields: dict) -> bool:
|
||||
"lora_name",
|
||||
"lora_weight",
|
||||
"appearance_tags",
|
||||
"appearance_prose",
|
||||
"personality",
|
||||
"scenario",
|
||||
"first_mes",
|
||||
@@ -255,6 +259,19 @@ async def patch_persona(persona_id: str, fields: dict) -> bool:
|
||||
merged = dict(existing)
|
||||
merged.update(updates)
|
||||
updates["prompt"] = build_persona_prompt(merged)
|
||||
|
||||
if "appearance_tags" in updates and "appearance_prose" not in updates:
|
||||
tags = updates["appearance_tags"].strip()
|
||||
if tags:
|
||||
from services.llm import send_message
|
||||
try:
|
||||
prose = await send_message([
|
||||
{"role": "system", "content": "Convert danbooru tags to natural English description. Output only the description, no markdown."},
|
||||
{"role": "user", "content": f"Tags: {tags}"}
|
||||
])
|
||||
updates["appearance_prose"] = prose.strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cols = ", ".join(f"{k} = ?" for k in updates)
|
||||
cur2 = await db.execute(
|
||||
|
||||
Reference in New Issue
Block a user