Allow custom character analyze prompts

This commit is contained in:
OpenClaw Agent
2026-07-20 14:02:28 +00:00
parent a711a9d34b
commit 3f24406697
2 changed files with 20 additions and 4 deletions

View File

@@ -512,6 +512,11 @@ _ANALYZE_PROMPT = (
)
def _resolve_analyze_prompt(data: dict) -> str:
prompt = (data.get("prompt") or "").strip()
return prompt or _ANALYZE_PROMPT
def _extract_ollama_generated_text(resp_json: dict) -> str:
if not isinstance(resp_json, dict):
return ""
@@ -621,6 +626,7 @@ async def analyze_character_endpoint(request):
image_debug = data.get("image_debug") or []
char_index = int(data.get("char_index", 0))
provider, base_url, model_name = _resolve_provider(data)
analyze_prompt = _resolve_analyze_prompt(data)
if provider == "off":
return web.json_response({"status": "error", "message": "Analyze is set to Off / Manual."})
@@ -652,7 +658,7 @@ async def analyze_character_endpoint(request):
payload = {
"model": model_name,
"system": _ANALYZE_SYSTEM_PROMPT,
"prompt": _ANALYZE_PROMPT,
"prompt": analyze_prompt,
"images": analysis_images,
"stream": False,
"keep_alive": 0,
@@ -691,7 +697,7 @@ async def analyze_character_endpoint(request):
},
{
"role": "user",
"content": _ANALYZE_PROMPT,
"content": analyze_prompt,
"images": analysis_images,
},
],
@@ -720,7 +726,7 @@ async def analyze_character_endpoint(request):
})
else:
# OpenAI-compatible vision chat (LM Studio / Custom).
content = [{"type": "text", "text": _ANALYZE_PROMPT}]
content = [{"type": "text", "text": analyze_prompt}]
for b64 in cleaned_b64_list:
content.append({"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}})
payload = {