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

@@ -1,5 +1,6 @@
const { app } = window.comfyAPI.app;
const { api } = window.comfyAPI.api;
const DEFAULT_ANALYZE_PROMPT = "Describe the character's physical appearance in two concise sentences. Specify their hair color/style, face details, and their clothing type/color. Keep the entire response very brief.";
function findWidget(node, name) {
return (node.widgets || []).find((widget) => widget.name === name);
@@ -369,15 +370,19 @@ function buildCharacterUi(node) {
const providerWidget = findWidget(node, "analyze_provider");
const baseUrlWidget = findWidget(node, "analyze_base_url");
const modelWidget = findWidget(node, "analyze_model");
const promptWidget = findWidget(node, "analyze_prompt");
const provider = window.prompt("Analyze provider: ollama, lmstudio, custom, off", providerWidget?.value || "ollama");
if (provider == null) return;
const baseUrl = window.prompt("Analyze base URL (blank = default)", baseUrlWidget?.value || "");
if (baseUrl == null) return;
const model = window.prompt("Analyze model (blank = provider default)", modelWidget?.value || "");
if (model == null) return;
const prompt = window.prompt("Analyze prompt (blank = default)", promptWidget?.value || DEFAULT_ANALYZE_PROMPT);
if (prompt == null) return;
setWidgetValue(node, providerWidget, provider.trim() || "ollama");
setWidgetValue(node, baseUrlWidget, baseUrl.trim());
setWidgetValue(node, modelWidget, model.trim());
setWidgetValue(node, promptWidget, prompt.trim());
syncFormFromWidgets(node);
node.setDirtyCanvas?.(true, true);
});
@@ -461,6 +466,7 @@ async function analyzeCharacterNode(node, buttonWidget) {
const providerWidget = findWidget(node, "analyze_provider");
const baseUrlWidget = findWidget(node, "analyze_base_url");
const modelWidget = findWidget(node, "analyze_model");
const promptWidget = findWidget(node, "analyze_prompt");
buttonWidget.label = "Analyzing...";
if (node._msrAnalyzeButton) {
@@ -489,6 +495,7 @@ async function analyzeCharacterNode(node, buttonWidget) {
provider: providerWidget?.value || "ollama",
base_url: baseUrlWidget?.value || "",
model: modelWidget?.value || "",
prompt: promptWidget?.value || "",
image_b64: images,
image_debug: imageDebug,
}),
@@ -560,6 +567,9 @@ app.registerExtension({
if (!findWidget(this, "analyze_model")) {
this.addWidget("text", "analyze_model", "");
}
if (!findWidget(this, "analyze_prompt")) {
this.addWidget("text", "analyze_prompt", DEFAULT_ANALYZE_PROMPT);
}
if (!this._msrPreviewWidget) {
const previewContainer = buildCharacterUi(this);
@@ -587,7 +597,7 @@ app.registerExtension({
return result;
};
["alias", "description", "analyze_provider", "analyze_base_url", "analyze_model"].forEach((widgetName) => {
["alias", "description", "analyze_provider", "analyze_base_url", "analyze_model", "analyze_prompt"].forEach((widgetName) => {
hideNodeWidget(findWidget(this, widgetName));
});
hideNodeWidget((this.widgets || []).find((widget) => widget.msrAnalyze));