Compare commits

...
1 Commits
Author SHA1 Message Date
ketle-manandClaude Sonnet 5 dfb33e831d release: v0.3.73 — Chat image generation via Tool Calling, Default Checkpoint safeguard
Adds LLM Tool Calling-driven image generation to the AI TOOL Chat pane
(generate_image tool, GenerateUI pipeline reuse, dedicated workflow option,
allow-toggle), plus a Settings > Default Checkpoint safeguard and a fix for
convertUiToApi() silently substituting missing checkpoints without warning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 13:03:06 +09:00
12 changed files with 433 additions and 25 deletions
+36
View File
@@ -2,6 +2,42 @@
---
## v0.3.73
### AI TOOL Chatペインからの対話式画像生成(Tool Calling)+ Checkpoint関連の安全策
ユーザーからの「OpenWebUIのような対話式画像生成をこのプラグインで実現できないか」という相談から着手。既存のOllama/LM Studioチャット機能(`static/js/ai-tab.js`)とGenerateUIタブの生成機能(`static/js/generate-tab.js`)は別々に存在していたが、両者をLLM Tool Calling経由で接続した。実装・検証の過程で、GenerateUIのModelタブに以前から存在した「保存済みワークフローのCheckpointが実在しない場合、無警告で別モデルに差し替わる」という表示バグも発見・修正した。
**対象ファイル:** `static/js/ai-tab.js`, `static/js/generate-tab.js`, `static/js/settings-tab.js`, `static/js/comfyui-editor.js`, `static/js/comfyui-workflow.js`, `static/css/main.css`, `static/js/i18n.js`, `static/js/app.js`, `templates/index.html`
**Chatペイン画像生成(Tool Calling):**
- `generate_image`ツール(`prompt`/`negative_prompt`引数)をOllama/LM Studio双方のchat APIに渡し、呼び出すかどうかはLLM自身が判断する設計(合意事項: 画像生成後、結果はLLMに送り返さず会話は一旦区切る/SPA版のみ対応、サイドパネル版は対象外)
- `callChat()`の戻り値を`string`から`{content, toolCalls}`へ変更。Ollamaの`tool_calls[].function.arguments`はオブジェクト、LM Studio(OpenAI互換)はJSON文字列という差異は`_parseToolArgs()`で吸収
- 生成処理は既存の`window._wfmGenerateTab.generate(workflowOverride)`(Image Edit「Inpaint」の外部呼び出しと同じ橋渡しパターン)をそのまま再利用。ワークフローはディープクローンしてから`comfyEditor.setPromptText()`で書き込むため、GenerateUIタブの表示状態は一切汚染しない
- **既存コードの欠落を修正:** `_coreGenerate`/`handleGenerate`(`generate-tab.js`)が生成結果`{images, seed}`を計算していながら`return`していなかったため、戻り値を追加(既存呼び出し元は戻り値を使っていないため影響なし)
- Chatペイン下部(Send/Clearボタンの隣)に「画像生成を許可する」チェックボックス(デフォルトON、`wfm_ai_settings`に永続化)。OFF時は`callChat()`に`tools`を渡さずLLMには一切提示しない
**SETTINGSペイン — Chat画像生成の専用ワークフロー:**
- Image Edit「Inpaint」の「Use dedicated workflow」と同一パターンを踏襲。OFF(デフォルト)はGenerateUIの読み込み中ワークフロー、ONは選択した保存済みワークフローを`/api/wfm/workflows/raw`経由でその都度ロード・変換(`comfyWorkflow.detectFormat`/`convertUiToApi`/`analyzeWorkflow`)して使用
**バグ修正: Checkpoint未一致時の無警告差し替え(`comfyui-workflow.js`):**
- `convertUiToApi()`のCOMBO値フォールバック処理(Impact Packのワイルドカード等、動的な選択肢がインスタンス間でズレて生成エラーになるのを防ぐため既存)が、`ckpt_name`にも無差別に適用されており、保存されたCheckpointパスが現在の環境に存在しない場合、無警告でCombo選択肢の先頭(たまたまアルファベット順で最初のFluxモデル)に差し替えられていた。この製品の「なぜかいつもFluxが表示される」という混乱の直接的な原因だった
- `getLastCheckpointSubstitutions()`を追加し、`ckpt_name`の差し替えが発生した場合のみ元の値・ノードIDを記録。`loadWorkflowIntoEditor`(`generate-tab.js`)で検知し、通常の「読み込み完了」トーストの代わりに、差し替え前のモデル名を含む警告トースト(`error`スタイル)を表示する
- GenerateUI Modelタブ(`comfyui-editor.js`の`renderModelTab`)にも、保存値が現在のモデル一覧に存在しない場合に警告付きの選択肢を先頭表示する対応を追加(API形式で保存され`convertUiToApi`を経由しないワークフローに対して有効。UI形式ワークフローは上記の差し替えにより「一致している」ように見えるため、この表示だけでは検知できないケースがある)
**設定タブ — デフォルトCheckpoint:**
- チェックボックスで有効化すると、GenerateUIへのワークフロー読み込み時に全Checkpointローダー系ノード(`CheckpointLoaderSimple`/`CheckpointLoader`/`ImageMetadataPromptLoader`)の`ckpt_name`を指定モデルへ強制上書き。サーバー側`/api/wfm/settings`に永続化(複数ブラウザ間で共有)
- **実装中に判明した順序依存の不具合:** 上書き処理を`analyzeWorkflow()`実行後に行っていたため、Raw JSON上のデータは正しく上書きされてもModelタブの表示(`analysis.checkpoint_nodes`由来)が古い値のまま残る不具合があった。`analyzeWorkflow()`実行前に上書きする順序に修正
**ヘルプ更新(3点セット):** `templates/index.html`/`static/js/i18n.js`(EN/JA/ZH)/`static/js/app.js`の`helpIdMap` — `helpAi3`(Chat画像生成機能+許可トグルの説明を追記)、`helpAi6`(SETTINGSペインの専用ワークフロー設定を追記)、`helpTrouble8`(新規: 「ModelタブのCheckpointが想定と違う」症状の原因と対処法)
**検証**(Kapture、実機ブラウザ + Ollama qwen3.5:9b):
- Chatペインから「〜の画像を生成して」で`generate_image`が呼ばれ、実際に画像が生成されチャット内に表示されることを確認(初回は無関係のワークフロー設定に起因するVAEチャンネル数不一致エラーが発生したが、ワークフロー側の修正後に正常動作を確認)
- SETTINGSペインの専用ワークフロー機能: 選択したワークフロー(UI形式、`ws_sdxl_t2i_basic.json`)が正しくロード・変換され、Chat経由の生成に使われることを確認
- 「画像生成を許可する」チェックボックスの位置変更(ヘッダー→下部の操作行)を反映
- デフォルトCheckpointのON/OFF切り替えでModelタブの表示が正しく変わることを確認(ON: 指定モデル、OFF: 元の壊れた表示に復帰)
- 実際に不一致のあるワークフロー(`op_sdxl_ill_lora.json`、保存値`anime\animozalyca_v10.safetensors`が未インストール)で、差し替え警告トーストが元のモデル名を含めて正しく表示されることを確認
## v0.3.72
### Comic Creator連携用の外部Inpaintエントリポイントを追加
+19 -1
View File
@@ -21,7 +21,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- Built-in AI tools (translation and more)
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.3.71-green)
![Version](https://img.shields.io/badge/version-0.3.73-green)
## Screenshots
@@ -164,6 +164,7 @@ Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons
- **CivitAI Host** — choose which site opens when clicking a model link: `civitai.com` (SFW only) or `civitai.red` (unrestricted); saved to `settings.json` and synced to `localStorage` for the Models tab to use without extra fetches
- **CivitAI API Key** — optional Bearer token for authenticated CivitAI access; stored in `settings.json` (excluded from data exports); environment variable `CIVITAI_API_KEY` takes priority if set
- **Default workflow** — set a workflow to auto-load on startup
- **Default Checkpoint** (v0.3.73) — optional checkbox to force every checkpoint loader node's model to a chosen default whenever a workflow is loaded into GenerateUI; a safeguard against generation errors or garbled images from a stale/mismatched checkpoint saved in the workflow file
- **Data Management** — export all plugin data (settings, metadata, prompts, etc.) to a single JSON file; import to restore data (useful when migrating or reinstalling); API keys are excluded from exports for security
- **Text Size** — one slider (10–28 px) adjusts font size for all prompt and chat textareas at once: Generate UI positive/negative prompts, AI Assistant chat input, Preset prompts, Wildcard prompt and file editor, and Metadata prompt full preview; takes effect immediately and saved with Save Settings
- **RAW JSON Colors** — customize the 6 syntax highlight colors for the Raw JSON editor in Generate UI: Default Text (base), Name/Scheduler (yellow), Title (pink), Width/Height (green), Prompt/Text (cyan), Image/File (red); changes apply immediately on color pick; Reset Defaults restores the original scheme; saved to `localStorage` under `wfm_settings.jsonColors` and applied on startup
@@ -273,9 +274,11 @@ Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons
- **4-pane layout** — Translation | Chat | TOOLS | Settings; all panes always visible simultaneously; no sub-tab switching required
- **Translation pane** — translate text between Japanese, English, Chinese, or a custom Free language using Ollama or LM Studio; language selectors with ⇄ swap button (swaps both language selectors and text content); selections saved automatically
- **Chat pane** (v0.3.40) — multi-turn conversation with the LLM; full conversation history sent each turn for context; Enter to send, Shift+Enter for a newline; Clear button resets history; Ollama uses `/api/chat`, LM Studio uses `/v1/chat/completions`
- **Chat pane — image generation via Tool Calling** (v0.3.73) — if the selected model supports tool calling and the user asks for an image, a `generate_image` tool is invoked and the request runs through the same generation pipeline as the GenerateUI Generate button, with the result shown inline in the chat; an "Allow image generation" checkbox in the input row toggles this on/off (default on); the workflow used is the one currently loaded in GenerateUI, or a dedicated saved workflow configured in the Settings pane
- **TOOLS pane (VLM)** — drop an image into the 110px drop zone, select a task (Describe Image / Create Prompt / Create Tags), and click Run to analyze with a vision model; result shown in the output area with a Copy button
- **TOOLS pane (Wildcards)** (v0.3.40) — select "Create wildcards" from the task dropdown; enter a category name and count; click Run to generate plain-text wildcard entries one per line (no markdown, no numbering); result can be copied directly into wildcard `.txt` files
- **Settings pane** — choose backend (Ollama / LM Studio), set the API URL, test connection, select a model (with refresh button), and configure Free language names for translation source and destination
- **Settings pane — Chat Image Generation** (v0.3.73) — "Use dedicated workflow" checkbox lets Chat-triggered image generation use a saved workflow of your choice instead of the one currently loaded in GenerateUI, without disturbing what's shown there (same pattern as Image Edit's Inpaint dedicated workflow)
- **Settings shared** — settings saved to `localStorage` under `wfm_ai_settings`; shared with the Library panel's AI TOOL tab so configuration is consistent across both interfaces
- **Backend support** — Ollama (`/api/generate` for text, `/api/chat` for conversations, `/api/tags` for model list); LM Studio OpenAI-compatible API (`/v1/chat/completions`, `/v1/models`); VLM images sent as base64 (`images:[]` for Ollama, `image_url` content block for LM Studio)
- **URL security** — backend URL validated via `new URL()` to enforce `http://` or `https://` scheme
@@ -398,6 +401,21 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
## Changelog
### v0.3.73
- **AI TOOL Chat — image generation via Tool Calling** — if the selected Ollama/LM Studio model supports tool calling, asking Chat for an image (e.g. "generate a picture of a cat") invokes a `generate_image` tool and runs the request through the same generation pipeline as the GenerateUI Generate button (`window._wfmGenerateTab.generate()`); the result is shown inline in the chat as an image bubble; the conversation is not sent back to the LLM after generation
- **AI TOOL Chat — "Allow image generation" toggle** — checkbox next to the Send/Clear buttons (default on, persisted to `wfm_ai_settings`); when off, the `generate_image` tool is not offered to the LLM at all
- **AI TOOL Settings — Chat Image Generation dedicated workflow** — "Use dedicated workflow" checkbox + saved-workflow picker; when off (default), Chat-triggered generation uses the workflow currently loaded in GenerateUI; when on, it loads the selected saved workflow fresh each time via `/api/wfm/workflows/raw`, without touching what's shown in GenerateUI (same pattern as Image Edit's Inpaint dedicated workflow)
- **Settings — Default Checkpoint** — optional checkbox to force every checkpoint loader node (`CheckpointLoaderSimple` / `CheckpointLoader` / `ImageMetadataPromptLoader`) to a chosen model whenever a workflow is loaded into GenerateUI; a safeguard for environments with many saved workflows referencing models that were later moved/renamed
- **Bug fix — silent checkpoint substitution now surfaced** — `convertUiToApi()`'s COMBO-value fallback (originally added to tolerate drifting Impact Pack wildcard options) was silently replacing *any* unrecognized `ckpt_name` with the first entry in the installed-checkpoints list, making the Model tab show an unrelated model with no indication anything was wrong; workflow loading now detects this specific case and shows a warning toast naming the missing checkpoint instead of the usual "workflow loaded" toast
- **GenerateUI — return value for programmatic generation** — `_coreGenerate`/`handleGenerate` now return `{images, seed}` on success (previously void); existing callers are unaffected, and this enables features like the new Chat image bridge to retrieve the generated image without scraping the DOM
### v0.3.72
- **Comic Creator integration — Inpaint via external entry point** — the Image tab in Comic Creator (`comfyui-comic-creator`) can now trigger Inpaint the same way it already triggers I2I, via `window._wfmReceiveInpaintRequest(imageBlob, maskBlob, params, workflowData?, workflowFilename?)` called across the same-origin iframe boundary; common Inpaint logic was factored out into `_runInpaintWithImages()` and shared by the UI-driven flow and this new external entry point
- **Bug fix — cross-realm Blob detection** — images/masks generated in a different window (Comic Creator) failed to load (`[object Blob]` was interpreted as a URL string, causing a 404) because `instanceof Blob` checks fail across window realms; switched to a `typeof src !== "string"` check
- Hidden mask layers are now excluded from Inpaint in both the UI-driven and external-call paths
### v0.3.71
- **Image Edit — Inpaint tool (🩹)** — new tool composites the canvas (all non-mask layers) plus the active mask layer, uploads to an inpaint-capable LoadImage node (or a Mask Editor One node) in the GenerateUI workflow, applies Positive/Negative prompts, Grow Mask By, and Denoise, then triggers generation — all without leaving the Image Edit tab; the result is shown in the Properties pane
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-workflow-studio"
description = "A comprehensive workflow, asset management, and generation UI plugin for ComfyUI. Manage workflows, models, images, and prompts; batch generation and Image Feeder in the GenerateUI tab; library side panel with canvas drag & drop and AI tools."
version = "0.3.72"
version = "0.3.73"
license = "MIT"
requires-python = ">= 3.10"
dependencies = ["jinja2"]
+35
View File
@@ -511,6 +511,18 @@ body {
transition: border-color 0.2s ease;
}
.wfm-select-missing {
border-color: var(--wfm-warning);
color: var(--wfm-warning);
}
.wfm-model-missing-hint {
font-size: 11px;
color: var(--wfm-warning);
margin-top: 2px;
margin-bottom: 4px;
}
.wfm-input:focus,
.wfm-textarea:focus,
.wfm-select:focus {
@@ -5242,6 +5254,9 @@ body {
.wfm-ai-pane-settings { flex: 2; }
.wfm-ai-pane-header {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 12px;
font-weight: 600;
color: var(--wfm-text-secondary);
@@ -5253,6 +5268,19 @@ body {
background: var(--wfm-surface);
}
.wfm-ai-chat-toggle-label {
display: flex;
align-items: center;
gap: 4px;
margin-left: auto;
font-size: 11px;
font-weight: 400;
color: var(--wfm-text-secondary);
text-transform: none;
letter-spacing: normal;
cursor: pointer;
}
.wfm-ai-pane-divider {
width: 1px;
background: var(--wfm-border);
@@ -5546,6 +5574,13 @@ body {
color: var(--wfm-text);
}
.wfm-ai-chat-img {
max-width: 100%;
border-radius: 6px;
margin-top: 6px;
display: block;
}
.wfm-ai-chat-input-area {
display: flex;
flex-direction: column;
+142 -11
View File
@@ -6,6 +6,9 @@
import { showToast } from "./app.js";
import { t } from "./i18n.js";
import { readJsonStorage } from "./util.js";
import { comfyUI } from "./comfyui-client.js";
import { comfyEditor } from "./comfyui-editor.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
const SETTINGS_KEY = "wfm_ai_settings";
@@ -341,6 +344,29 @@ function initSettingsTab() {
if (freeSrcInput && saved.freeSrcLang) freeSrcInput.value = saved.freeSrcLang;
if (freeDstInput && saved.freeDstLang) freeDstInput.value = saved.freeDstLang;
// Chat image generation — dedicated workflow selection
const chatGenCheckbox = document.getElementById("wfm-ai-chatgen-dedicated-checkbox");
const chatGenRow = document.getElementById("wfm-ai-chatgen-dedicated-row");
const chatGenSelect = document.getElementById("wfm-ai-chatgen-dedicated-select");
if (chatGenCheckbox) chatGenCheckbox.checked = !!saved.chatGenDedicatedEnabled;
if (chatGenRow) chatGenRow.style.display = saved.chatGenDedicatedEnabled ? "" : "none";
chatGenCheckbox?.addEventListener("change", () => {
if (chatGenRow) chatGenRow.style.display = chatGenCheckbox.checked ? "" : "none";
});
if (chatGenSelect) {
fetch(`${comfyUI.baseUrl}/api/wfm/workflows`)
.then((r) => (r.ok ? r.json() : []))
.then((list) => {
const filenames = (list || []).map((w) => w.filename).filter(Boolean);
chatGenSelect.innerHTML = `<option value="">-- select workflow --</option>` +
filenames.map((f) => `<option value="${f}" ${f === saved.chatGenDedicatedFilename ? "selected" : ""}>${f}</option>`).join("");
})
.catch(() => {});
}
// Save settings
document.getElementById("wfm-ai-settings-save-btn")?.addEventListener("click", () => {
const backend = document.querySelector("input[name='wfm-ai-backend']:checked")?.value || "ollama";
@@ -348,13 +374,15 @@ function initSettingsTab() {
const model = document.getElementById("wfm-ai-model-select")?.value || "";
const freeSrcLang = freeSrcInput?.value?.trim() || "";
const freeDstLang = freeDstInput?.value?.trim() || "";
const chatGenDedicatedEnabled = !!chatGenCheckbox?.checked;
const chatGenDedicatedFilename = chatGenSelect?.value || "";
if (url && !isValidBackendUrl(url)) {
showToast(t("aiToastInvalidUrl"), "error");
return;
}
saveAiSettings({ backend, backendUrl: url, model, freeSrcLang, freeDstLang });
saveAiSettings({ backend, backendUrl: url, model, freeSrcLang, freeDstLang, chatGenDedicatedEnabled, chatGenDedicatedFilename });
showToast(t("aiToastSettingsSaved"), "success");
});
@@ -368,30 +396,104 @@ function initSettingsTab() {
// Chat tab
// ============================================
async function callChat(url, backend, model, messages) {
const IMAGE_GEN_TOOLS = [{
type: "function",
function: {
name: "generate_image",
description: "Generate an image using the currently loaded ComfyUI workflow. Call this when the user asks to create, draw, paint, or generate an image.",
parameters: {
type: "object",
properties: {
prompt: { type: "string", description: "Positive prompt describing the desired image." },
negative_prompt: { type: "string", description: "What to avoid in the image. Optional." },
},
required: ["prompt"],
},
},
}];
async function callChat(url, backend, model, messages, tools) {
if (backend === "ollama") {
const body = { model, messages, stream: false };
if (tools) body.tools = tools;
const res = await fetch(`${url}/api/chat`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model, messages, stream: false }),
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return (await res.json()).message?.content || "";
const message = (await res.json()).message || {};
return { content: message.content || "", toolCalls: message.tool_calls || null };
} else {
const body = { model, messages, stream: false };
if (tools) { body.tools = tools; body.tool_choice = "auto"; }
const res = await fetch(`${url}/v1/chat/completions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model, messages, stream: false }),
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return (await res.json()).choices?.[0]?.message?.content || "";
const message = (await res.json()).choices?.[0]?.message || {};
return { content: message.content || "", toolCalls: message.tool_calls || null };
}
}
function appendChatBubble(messagesEl, role, content) {
function _parseToolArgs(toolCall) {
const raw = toolCall.function?.arguments ?? toolCall.arguments;
if (typeof raw === "string") {
try { return JSON.parse(raw); } catch { return {}; }
}
return raw || {};
}
async function _loadDedicatedChatGenWorkflow(filename) {
const resp = await fetch(`${comfyUI.baseUrl}/api/wfm/workflows/raw?filename=${encodeURIComponent(filename)}`);
if (!resp.ok) throw new Error(`Failed to load workflow (HTTP ${resp.status})`);
let workflow = await resp.json();
const format = comfyWorkflow.detectFormat(workflow, filename);
if (format === "ui") {
workflow = await comfyWorkflow.convertUiToApi(workflow);
} else if (format !== "api") {
throw new Error("Unsupported or unrecognized workflow format");
}
return { workflow, analysis: comfyWorkflow.analyzeWorkflow(workflow) };
}
async function generateImageFromChat(prompt, negativePrompt) {
if (!window._wfmGenerateTab?.generate) throw new Error(t("aiChatGenerateNotReady"));
const settings = loadAiSettings();
let workflow, analysis;
if (settings.chatGenDedicatedEnabled && settings.chatGenDedicatedFilename) {
({ workflow, analysis } = await _loadDedicatedChatGenWorkflow(settings.chatGenDedicatedFilename));
} else {
if (!comfyUI.currentWorkflow || !comfyUI.currentAnalysis) throw new Error(t("aiChatNoWorkflowLoaded"));
workflow = JSON.parse(JSON.stringify(comfyUI.currentWorkflow));
analysis = comfyUI.currentAnalysis;
}
comfyEditor.setPromptText("positive", prompt || "", { workflow, analysis });
if (negativePrompt) comfyEditor.setPromptText("negative", negativePrompt, { workflow, analysis });
const result = await window._wfmGenerateTab.generate(workflow);
const images = result?.images || [];
if (images.length === 0) throw new Error(t("aiChatNoImageProduced"));
const img = images[0];
return `/view?filename=${encodeURIComponent(img.filename)}&subfolder=${encodeURIComponent(img.subfolder || "")}&type=${encodeURIComponent(img.type || "output")}`;
}
function appendChatBubble(messagesEl, role, content, opts = {}) {
const div = document.createElement("div");
div.className = `wfm-ai-chat-msg wfm-ai-chat-msg-${role}`;
div.textContent = content;
if (content) div.textContent = content;
if (opts.imageUrl) {
const img = document.createElement("img");
img.src = opts.imageUrl;
img.className = "wfm-ai-chat-img";
div.appendChild(img);
}
messagesEl.appendChild(div);
messagesEl.scrollTop = messagesEl.scrollHeight;
return div;
@@ -403,9 +505,18 @@ function initChatTab() {
const sendBtn = document.getElementById("wfm-ai-chat-send-btn");
const clearBtn = document.getElementById("wfm-ai-chat-clear-btn");
const statusEl = document.getElementById("wfm-ai-chat-status");
const imgGenToggle = document.getElementById("wfm-ai-chat-imggen-toggle");
if (!messagesEl || !inputEl || !sendBtn) return;
if (imgGenToggle) {
const savedToggle = loadAiSettings();
imgGenToggle.checked = savedToggle.chatImageGenEnabled !== false;
imgGenToggle.addEventListener("change", () => {
saveAiSettings({ chatImageGenEnabled: imgGenToggle.checked });
});
}
let chatHistory = [];
async function sendMessage() {
@@ -435,9 +546,29 @@ function initChatTab() {
statusEl.className = "wfm-ai-trans-status wfm-ai-status-working";
try {
const reply = await callChat(url, backend, model, chatHistory);
chatHistory.push({ role: "assistant", content: reply });
appendChatBubble(messagesEl, "assistant", reply);
const tools = imgGenToggle?.checked !== false ? IMAGE_GEN_TOOLS : undefined;
const reply = await callChat(url, backend, model, chatHistory, tools);
const toolCall = reply.toolCalls?.find(
(tc) => (tc.function?.name || tc.name) === "generate_image"
);
if (toolCall) {
chatHistory.push({ role: "assistant", content: reply.content || "" });
if (reply.content) appendChatBubble(messagesEl, "assistant", reply.content);
statusEl.textContent = t("aiStatusGeneratingImage");
const args = _parseToolArgs(toolCall);
try {
const imageUrl = await generateImageFromChat(args.prompt, args.negative_prompt);
appendChatBubble(messagesEl, "assistant", "", { imageUrl });
} catch (genErr) {
appendChatBubble(messagesEl, "assistant", `${t("aiToastImageGenFailed")}${genErr.message}`);
showToast(t("aiToastImageGenFailed") + genErr.message, "error");
}
} else {
chatHistory.push({ role: "assistant", content: reply.content });
appendChatBubble(messagesEl, "assistant", reply.content);
}
statusEl.textContent = "";
statusEl.className = "wfm-ai-trans-status";
} catch (err) {
+7 -1
View File
@@ -310,6 +310,12 @@ function applyI18nToHtml() {
if (aiFreeDstLabel) aiFreeDstLabel.textContent = t("aiSettingsOutputLang");
const aiSaveBtn = document.getElementById("wfm-ai-settings-save-btn");
if (aiSaveBtn) aiSaveBtn.textContent = t("aiSettingsSaveBtn");
const aiChatImgGenLabel = document.getElementById("wfm-ai-chat-imggen-label-text");
if (aiChatImgGenLabel) aiChatImgGenLabel.textContent = t("aiChatImgGenToggle");
const aiChatGenTitle = document.getElementById("wfm-ai-settings-chatgen-title");
if (aiChatGenTitle) aiChatGenTitle.textContent = t("aiSettingsChatGenTitle");
const aiChatGenDedicatedLabel = document.getElementById("wfm-ai-chatgen-dedicated-label");
if (aiChatGenDedicatedLabel) aiChatGenDedicatedLabel.textContent = t("aiSettingsChatGenDedicated");
// Group panel labels
const propTitle = document.querySelector("#wfm-side-tab-group .wfm-group-section-title");
@@ -482,7 +488,7 @@ function applyI18nToHtml() {
"wfm-help-trouble-1": "helpTrouble1", "wfm-help-trouble-2": "helpTrouble2",
"wfm-help-trouble-3": "helpTrouble3", "wfm-help-trouble-4": "helpTrouble4",
"wfm-help-trouble-5": "helpTrouble5", "wfm-help-trouble-6": "helpTrouble6",
"wfm-help-trouble-7": "helpTrouble7",
"wfm-help-trouble-7": "helpTrouble7", "wfm-help-trouble-8": "helpTrouble8",
"wfm-help-support-title": "helpSupportTitle",
"wfm-help-support-desc": "helpSupportDesc",
"wfm-help-github-desc": "helpGithubDesc",
+5 -1
View File
@@ -5,6 +5,7 @@
import { comfyUI } from "./comfyui-client.js";
import { syncJsonHighlight } from "./json-highlight.js";
import { t } from "./i18n.js";
import { escapeHtml } from "./util.js";
// ── Latent Image preset state ─────────────────────────────
const _LATENT_PRESET_KEY = "wfm_latent_presets";
@@ -522,6 +523,7 @@ export const comfyEditor = {
.map((s) => {
const models = this.models[s.key] || [];
const currentVal = s.nodes?.[0]?.[s.inputKey] || "";
const isMissing = !!currentVal && !models.includes(currentVal);
const targetOpts = s.nodes
.map((n) => `<option value="${n.id}">ID:${n.id} (${n.title})</option>`)
.join("");
@@ -540,9 +542,11 @@ export const comfyEditor = {
<div class="wfm-form-group" style="border-bottom:1px solid var(--wfm-border);padding-bottom:12px;">
<label>${s.label}</label>
<input type="text" class="wfm-input wfm-model-filter" placeholder="Filter..." data-target="wfm-model-${s.key}" style="margin-bottom:4px;">
<select class="wfm-select" id="wfm-model-${s.key}" style="margin-bottom:4px;">
<select class="wfm-select ${isMissing ? "wfm-select-missing" : ""}" id="wfm-model-${s.key}" style="margin-bottom:4px;">
${isMissing ? `<option value="${escapeHtml(currentVal)}" selected>⚠ ${escapeHtml(currentVal)} (${t("modelNotFound")})</option>` : ""}
${models.map((m) => `<option value="${m}" ${m === currentVal ? "selected" : ""}>${m}</option>`).join("")}
</select>
${isMissing ? `<div class="wfm-model-missing-hint">${t("modelNotFoundHint")}</div>` : ""}
${extrasHtml}
<div style="display:flex;gap:8px;align-items:center;margin-top:4px;">
<select class="wfm-select" id="wfm-model-${s.key}-target" style="flex:1;">${targetOpts}</select>
+18
View File
@@ -5,6 +5,11 @@
// Cache for /object_info (loaded once, shared)
let _objectInfoCache = null;
// convertUiToApi() の COMBO フォールバック(未一致時に選択肢の先頭へ無警告で差し替え)が
// ckpt_name に対して発生した場合の記録。呼び出し元が読み込み直後に確認して警告表示できるよう、
// 直近の convertUiToApi() 呼び出し分だけを保持する。
let _lastCheckpointSubstitutions = [];
async function _loadObjectInfo() {
if (_objectInfoCache) return _objectInfoCache;
try {
@@ -267,7 +272,12 @@ export const comfyWorkflow = {
/**
* Convert UI-format workflow to API-format using /object_info for accurate widget mapping.
*/
getLastCheckpointSubstitutions() {
return _lastCheckpointSubstitutions;
},
async convertUiToApi(workflow) {
_lastCheckpointSubstitutions = [];
if (!workflow.nodes || !workflow.links) return {};
// Flatten subgraphs before conversion
@@ -379,6 +389,14 @@ export const comfyWorkflow = {
if (spec) {
const choices = Array.isArray(spec[0]) ? spec[0] : null;
if (choices && choices.length > 0 && !choices.includes(val)) {
if (name === "ckpt_name") {
_lastCheckpointSubstitutions.push({
nodeId: String(node.id),
title: node.title || node.type,
original: val,
replaced: choices[0],
});
}
val = choices[0];
}
}
+39 -2
View File
@@ -218,21 +218,52 @@ async function saveCurrentWorkflow() {
// Workflow Loading
// ============================================
// ワークフロー読み込み時、設定タブで有効化されていれば checkpoint loader 系ノード全件の
// ckpt_name をデフォルトモデルへ強制上書きする(保存済みワークフローのモデルが
// 環境と合わず生成エラー/不鮮明な画像になるのを防ぐ回避策)。
// analyzeWorkflow() より前に apiWorkflow 自体を書き換える必要がある — analysis後に
// 書き換えると Model タブの表示(analysis.checkpoint_nodes 由来)が古い値のまま残るため。
async function _applyDefaultCheckpointIfEnabled(apiWorkflow) {
try {
const res = await fetch("/api/wfm/settings");
if (!res.ok) return;
const settings = await res.json();
if (!settings.default_checkpoint_enabled || !settings.default_checkpoint_name) return;
let applied = false;
for (const node of Object.values(apiWorkflow)) {
const ct = node?.class_type || "";
if (node?.inputs && (ct.includes("CheckpointLoader") || ct === "Checkpoint Loader" || ct === "ImageMetadataPromptLoader")) {
node.inputs.ckpt_name = settings.default_checkpoint_name;
applied = true;
}
}
if (applied) showToast(t("defaultCheckpointApplied", settings.default_checkpoint_name), "info");
} catch { /* non-critical, ignore */ }
}
export async function loadWorkflowIntoEditor(workflow, filename) {
let apiWorkflow = workflow;
const format = comfyWorkflow.detectFormat(workflow, filename);
let ckptWarning = null;
if (format === "app") {
showToast(t("appFormatNotSupported"), "error");
return false;
} else if (format === "ui") {
apiWorkflow = await comfyWorkflow.convertUiToApi(workflow);
const ckptSubs = comfyWorkflow.getLastCheckpointSubstitutions();
if (ckptSubs.length > 0) {
const names = [...new Set(ckptSubs.map((s) => s.original))].join(", ");
ckptWarning = t("checkpointSubstitutedWarning", names);
}
} else if (format === "unknown") {
showToast(t("unknownWorkflowFormat"), "error");
return false;
}
comfyUI.currentWorkflow = apiWorkflow;
await _applyDefaultCheckpointIfEnabled(apiWorkflow);
comfyUI.currentAnalysis = comfyWorkflow.analyzeWorkflow(apiWorkflow);
// Render editor tabs
@@ -260,7 +291,11 @@ export async function loadWorkflowIntoEditor(workflow, filename) {
refreshFeederNodeList();
showToast(t("workflowLoadedName", filename || ""), "success");
if (ckptWarning) {
showToast(ckptWarning, "error");
} else {
showToast(t("workflowLoadedName", filename || ""), "success");
}
return true;
}
@@ -1468,6 +1503,8 @@ async function _coreGenerate(silent = false, workflowOverride = null) {
}
if (!silent) showToast(t("generationComplete"), "success");
return { images, seed };
}
// ============================================
@@ -1762,7 +1799,7 @@ async function handleGenerate(workflowOverride = null) {
await _runBatchGenerate();
} else {
try {
await _coreGenerate(false, workflowOverride);
return await _coreGenerate(false, workflowOverride);
} catch (err) {
const progressText = document.getElementById("wfm-gen-progress-text");
if (progressText) progressText.textContent = "Error";
+57 -6
View File
@@ -207,6 +207,8 @@ const LANGUAGES = {
unknownWorkflowFormat: "Unknown workflow format",
generationComplete: "Generation complete",
generationError: (msg) => `Generation error: ${msg}`,
defaultCheckpointApplied: (name) => `Default checkpoint applied: ${name}`,
checkpointSubstitutedWarning: (names) => `Checkpoint not found in this workflow, silently replaced with another model: ${names}. Please check the Model tab.`,
batchNoneSelected: (what) => `No ${what} selected`,
batchItemFailed: (i, total, msg) => `[${i}/${total}] Failed: ${msg}`,
batchStopped: (completed, failed) => `Batch stopped — ${completed} completed, ${failed} failed`,
@@ -602,6 +604,14 @@ const LANGUAGES = {
aiStatusChatting: "Thinking...",
aiToastChatFailed: "Chat failed: ",
aiToastWcNoName: "Please enter a wildcard name",
aiStatusGeneratingImage: "Generating image...",
aiChatNoWorkflowLoaded: "No workflow loaded in GenerateUI",
aiChatGenerateNotReady: "GenerateUI is not ready yet",
aiChatNoImageProduced: "Generation completed but no image was produced",
aiToastImageGenFailed: "Image generation failed: ",
aiChatImgGenToggle: "Allow image generation",
aiSettingsChatGenTitle: "Chat Image Generation",
aiSettingsChatGenDedicated: "Use dedicated workflow",
// -- Help & Support --
tabHelp: "Help",
@@ -751,10 +761,10 @@ const LANGUAGES = {
helpAiTitle: "AI Tab (A)",
helpAi1: "4-pane layout — Translation | Chat | TOOLS | Settings — all panes are always visible simultaneously",
helpAi2: "Translation pane: translate between Japanese, English, Chinese, or Free language; ⇄ swap button swaps both language selectors and text content; selections are saved automatically",
helpAi3: "Chat pane: multi-turn conversation with the LLM; Enter to send a message, Shift+Enter for a newline; Clear button resets the conversation history",
helpAi3: "Chat pane: multi-turn conversation with the LLM; Enter to send a message, Shift+Enter for a newline; Clear button resets the conversation history; if the model supports tool calling and asks for an image (\"generate a cat picture\", etc.) it will run generation on the workflow currently loaded in GenerateUI and show the result inline; the \"Allow image generation\" checkbox in the pane header toggles this on/off",
helpAi4: "TOOLS pane — VLM: drop an image (PNG/JPG/WebP) and select a task (Describe Image, Create Prompt, Create Tags), click Run; or select \"Create wildcards\", enter a category name and count to generate plain-text entries one per line",
helpAi5: "Settings pane: choose backend (Ollama / LM Studio), set API URL, test connection, select model, configure Free language names for translation",
helpAi6: "Settings are saved to localStorage and shared with the Library panel's A tab",
helpAi6: "Settings pane: choose backend (Ollama / LM Studio), set API URL, test connection, select model, configure Free language names; Chat Image Generation section lets you enable a dedicated workflow for Chat-triggered generation instead of the one currently loaded in GenerateUI; settings are shared with the Library panel's A tab via localStorage",
helpImageEditTitle: "Image Edit Tab",
helpImageEdit1: "Layer-based image editor — compose images with multiple layers (Image, Text, Draw, Mask types) and export the composite",
helpImageEdit2: "Loading images: drag & drop onto the canvas, Upload button, or send from the Gallery tab via the Image Edit button in the Gallery toolbar; the first image becomes Layer 1 (auto-locked); subsequent images are added as new layers scaled to fit the canvas",
@@ -847,6 +857,7 @@ const LANGUAGES = {
helpTrouble5: "LoRA Stack fails with 'No such file or directory' error: The LoRA may not be recognized by comfyui-lora-manager (known issue). Try a different LoRA or check if the file appears in Lora Manager's own UI",
helpTrouble6: "Model loading error after moving or deleting models: ComfyUI caches file paths and may still reference old locations. Perform a Hard Reset from the ComfyUI menu (Queue → Hard Reset) or restart ComfyUI to clear the cache.",
helpTrouble7: "Tagger tab shows no models: verify the model folder exists at ComfyUI/models/tagger/<model-name>/ and contains a .onnx or .h5 file; if onnxruntime is not installed, run: python_embeded\\python.exe -m pip install onnxruntime",
helpTrouble8: "Model tab shows a checkpoint you didn't expect (e.g. always the same model regardless of the loaded workflow): the checkpoint saved in the workflow file is not installed, so it was silently replaced with another available model during loading — an error toast reports the original (missing) model name when this happens. Select the correct checkpoint manually in the Model tab, or enable \"Default Checkpoint\" in Settings to force a known-good model on every load.",
helpSupportTitle: "Support",
helpSupportDesc: "If you find this plugin useful, please consider supporting its development!",
helpGithubDesc: "Report issues, request features, and contribute",
@@ -870,6 +881,10 @@ const LANGUAGES = {
comfyuiConnection: "ComfyUI Connection",
comfyuiUrl: "ComfyUI URL",
comfyuiUrlHint: "When running as ComfyUI plugin, leave empty to use same origin. Only set if ComfyUI is on a different server.",
defaultCheckpointSettings: "Default Checkpoint",
defaultCheckpointEnable: "Force default checkpoint on workflow load",
defaultCheckpointModel: "Default checkpoint model",
defaultCheckpointHint: "When enabled, the Checkpoint of every checkpoint loader node is overridden with this model whenever a workflow is loaded into GenerateUI — useful to avoid errors or garbled images caused by a mismatched model saved in the workflow file.",
connectedCheck: "Connected \u2713",
failedConnect: "Failed to connect \u2717",
ollamaSettings: "AI Assistant Settings (Prompt Tab)",
@@ -878,6 +893,8 @@ const LANGUAGES = {
selectModel: "Select model...",
noModelsFound: "No models found",
failedLoadModels: "Failed to load models",
modelNotFound: "not found",
modelNotFoundHint: "The model saved in this workflow was not found among the installed models. Please select the correct one from the list.",
saveOllama: "Save AI Assistant Settings",
testConnection: "Test Connection",
ollamaConnected: "Connected \u2713",
@@ -1191,6 +1208,8 @@ const LANGUAGES = {
unknownWorkflowFormat: "不明なワークフロー形式です",
generationComplete: "生成が完了しました",
generationError: (msg) => `生成エラー: ${msg}`,
defaultCheckpointApplied: (name) => `デフォルトCheckpointを適用しました: ${name}`,
checkpointSubstitutedWarning: (names) => `このワークフローのCheckpoint「${names}」が見つからず、無警告で別のモデルに差し替えられました。Modelタブを確認してください。`,
batchNoneSelected: (what) => `${what}が選択されていません`,
batchItemFailed: (i, total, msg) => `[${i}/${total}] 失敗: ${msg}`,
batchStopped: (completed, failed) => `バッチ停止 — 完了${completed}件、失敗${failed}件`,
@@ -1586,6 +1605,14 @@ const LANGUAGES = {
aiStatusChatting: "考え中...",
aiToastChatFailed: "チャット失敗: ",
aiToastWcNoName: "ワイルドカード名を入力してください",
aiStatusGeneratingImage: "画像を生成中...",
aiChatNoWorkflowLoaded: "GenerateUIにワークフローが読み込まれていません",
aiChatGenerateNotReady: "GenerateUIの準備ができていません",
aiChatNoImageProduced: "生成は完了しましたが画像が出力されませんでした",
aiToastImageGenFailed: "画像生成に失敗しました: ",
aiChatImgGenToggle: "画像生成を許可する",
aiSettingsChatGenTitle: "Chat画像生成",
aiSettingsChatGenDedicated: "専用ワークフローを使用",
// -- Help & Support --
tabHelp: "ヘルプ",
@@ -1735,10 +1762,10 @@ const LANGUAGES = {
helpAiTitle: "AI タブ(A)",
helpAi1: "4ペインレイアウト — Translation | Chat | TOOLS | Settings — 全ペインが常時表示される",
helpAi2: "翻訳ペイン:Ollama または LM Studio を使って日本語・英語・中国語・カスタム言語(Free)間でテキストを翻訳;⇄ ボタンで言語とテキストを同時入替;選択は自動保存",
helpAi3: "Chat ペイン:LLM とのマルチターン会話;Enter で送信、Shift+Enter で改行;Clear ボタンで会話履歴をリセット",
helpAi3: "Chat ペイン:LLM とのマルチターン会話;Enter で送信、Shift+Enter で改行;Clear ボタンで会話履歴をリセット;モデルがtool callingに対応している場合、「猫の画像を作って」のように頼むとGenerateUIに読み込み中のワークフローで生成を実行し、結果をチャット内に表示する;ペインヘッダーの「画像生成を許可する」チェックボックスでこの機能のON/OFFを切り替えられる",
helpAi4: "TOOLS ペイン — VLM:画像(PNG/JPG/WebP)をドロップしてタスク(画像解説 / プロンプト作成 / タグ作成)を選んで Run;または「Create wildcards」を選んでカテゴリ名と件数を入力すると1行1エントリのワイルドカードを生成",
helpAi5: "設定ペイン:バックエンド(Ollama / LM Studio)・API URL・接続テスト・モデル選択・Free 言語名を設定",
helpAi6: "設定は localStorage に保存され、Library パネルの A タブと共有される",
helpAi6: "Settings ペイン:バックエンド(Ollama / LM Studio)の選択、APIのURL設定、接続テスト、モデル選択、Free言語名の設定;Chat Image Generationセクションでは、Chatからの画像生成にGenerateUIの現在の読み込みワークフローの代わりに専用ワークフローを使うよう設定できる;設定は localStorage に保存され、Library パネルの A タブと共有される",
helpImageEditTitle: "Image Edit タブ",
helpImageEdit1: "レイヤーベースの画像エディタ — 複数のレイヤー(画像・テキスト・描画・マスク)を重ね合わせて画像を合成・エクスポート",
helpImageEdit2: "画像の読み込み:キャンバスへのドラッグ&ドロップ、Uploadボタン、またはGalleryタブのImage Editボタンから送信;最初の画像はLayer 1として自動ロック;以降の画像はキャンバスサイズに合わせてスケールされ新規レイヤーとして追加",
@@ -1830,6 +1857,7 @@ const LANGUAGES = {
helpTrouble5: "LoRAスタック実行時に「No such file or directory」エラー:comfyui-lora-managerが該当LoRAを認識していない可能性があります(既知の問題)。別のLoRAを試すか、Lora Manager自体のUIで該当ファイルが表示されるか確認してください",
helpTrouble6: "モデルの移動・削除後にモデル読み込みエラーが発生する:ComfyUIがファイルパスをキャッシュしており、古い場所を参照することがあります。ComfyUIメニューのHard Reset(Queue → Hard Reset)またはComfyUIを再起動してキャッシュをクリアしてください。",
helpTrouble7: "Taggerタブにモデルが表示されない:ComfyUI/models/tagger/<モデル名>/ フォルダの存在と .onnx または .h5 ファイルの有無を確認;onnxruntimeが未インストールの場合は python_embeded\\python.exe -m pip install onnxruntime を実行",
helpTrouble8: "ModelタブのCheckpointが想定と違うモデルになっている(どのワークフローを読み込んでも同じモデルになる等):ワークフローファイルに保存されたCheckpointが実際にはインストールされておらず、読み込み時に無警告で別のインストール済みモデルに差し替えられています。この場合、元の(見つからなかった)モデル名を含むエラートーストが表示されます。Modelタブで正しいCheckpointを手動選択するか、設定タブの「デフォルトCheckpoint」を有効にして、読み込み時に常に動作確認済みのモデルを強制適用してください。",
helpSupportTitle: "サポート",
helpSupportDesc: "このプラグインが役に立ったら、開発を支援していただけると嬉しいです!",
helpGithubDesc: "バグ報告、機能リクエスト、コントリビュート",
@@ -1853,6 +1881,10 @@ const LANGUAGES = {
comfyuiConnection: "ComfyUI 接続",
comfyuiUrl: "ComfyUI URL",
comfyuiUrlHint: "ComfyUIプラグインとして動作する場合は空欄(同一オリジン推奨)。別サーバーの場合のみ設定してください。",
defaultCheckpointSettings: "デフォルトCheckpoint",
defaultCheckpointEnable: "ワークフロー読み込み時にデフォルトCheckpointを強制適用する",
defaultCheckpointModel: "デフォルトCheckpointモデル",
defaultCheckpointHint: "有効にすると、GenerateUIにワークフローを読み込むたびに、すべてのCheckpointローダーノードのモデルがこの値で上書きされます。ワークフローファイルに保存されたモデルが環境と合わず、生成エラーや不鮮明な画像が発生するのを防ぐための設定です。",
connectedCheck: "接続成功 \u2713",
failedConnect: "接続失敗 \u2717",
ollamaSettings: "AI Assistant設定(プロンプトタブ)",
@@ -1861,6 +1893,8 @@ const LANGUAGES = {
selectModel: "モデルを選択...",
noModelsFound: "モデルが見つかりません",
failedLoadModels: "モデル一覧の取得に失敗",
modelNotFound: "見つかりません",
modelNotFoundHint: "このワークフローに保存されているモデルが、インストール済みモデルの中に見つかりませんでした。正しいモデルを一覧から選択してください。",
saveOllama: "AI Assistant設定を保存",
testConnection: "接続テスト",
ollamaConnected: "接続成功 \u2713",
@@ -2174,6 +2208,8 @@ const LANGUAGES = {
unknownWorkflowFormat: "未知的工作流格式",
generationComplete: "生成完成",
generationError: (msg) => `生成错误: ${msg}`,
defaultCheckpointApplied: (name) => `已应用默认 Checkpoint:${name}`,
checkpointSubstitutedWarning: (names) => `此工作流中的 Checkpoint「${names}」未找到,已被静默替换为其他模型。请检查 Model 标签页。`,
batchNoneSelected: (what) => `未选择${what}`,
batchItemFailed: (i, total, msg) => `[${i}/${total}] 失败: ${msg}`,
batchStopped: (completed, failed) => `批处理已停止 — 完成${completed}个,失败${failed}个`,
@@ -2569,6 +2605,14 @@ const LANGUAGES = {
aiStatusChatting: "思考中...",
aiToastChatFailed: "聊天失败:",
aiToastWcNoName: "请输入通配符名称",
aiStatusGeneratingImage: "正在生成图像...",
aiChatNoWorkflowLoaded: "GenerateUI 中未加载工作流",
aiChatGenerateNotReady: "GenerateUI 尚未就绪",
aiChatNoImageProduced: "生成完成但未产生图像",
aiToastImageGenFailed: "图像生成失败:",
aiChatImgGenToggle: "允许生成图像",
aiSettingsChatGenTitle: "Chat 图像生成",
aiSettingsChatGenDedicated: "使用专用工作流",
// -- Help & Support --
tabHelp: "帮助",
@@ -2718,10 +2762,10 @@ const LANGUAGES = {
helpAiTitle: "AI 标签页(A)",
helpAi1: "4 面板布局 — Translation | Chat | TOOLS | Settings — 所有面板始终可见",
helpAi2: "翻译面板:使用 Ollama 或 LM Studio 在日语、英语、中文或自定义语言(Free)之间翻译;⇄ 按钮同时互换语言和文本内容;选择自动保存",
helpAi3: "Chat 面板:与 LLM 进行多轮对话;Enter 发送消息,Shift+Enter 换行;Clear 按钮重置对话历史",
helpAi3: "Chat 面板:与 LLM 进行多轮对话;Enter 发送消息,Shift+Enter 换行;Clear 按钮重置对话历史;如果模型支持 tool calling,当你要求生成图像(例如\"生成一张猫的图片\")时,会使用 GenerateUI 中当前加载的工作流执行生成,并在对话中显示结果;面板标题栏的\"允许生成图像\"复选框可开关此功能",
helpAi4: "TOOLS 面板 — VLM:拖放图像(PNG/JPG/WebP)并选择任务(图像描述 / 提示词生成 / 标签生成),点击 Run;或选择「Create wildcards」,输入类别名称和数量生成纯文本通配符条目(每行一条)",
helpAi5: "设置面板:选择后端(Ollama / LM Studio)、设置 API URL、测试连接、选择模型、配置 Free 语言名称",
helpAi6: "设置保存至 localStorage,并与 Library 面板的 A 标签共享",
helpAi6: "Settings 面板:选择后端(Ollama / LM Studio)、设置 API URL、测试连接、选择模型、配置 Free 语言名称;Chat 图像生成部分可让 Chat 触发的生成使用专用工作流,而不是 GenerateUI 中当前加载的工作流;设置保存至 localStorage,并与 Library 面板的 A 标签共享",
helpImageEditTitle: "图像编辑选项卡",
helpImageEdit1: "基于图层的图像编辑器 — 通过多个图层(图像、文字、绘制、遮罩类型)合成图像并导出",
helpImageEdit2: "加载图像:拖放到画布、点击Upload按钮、或通过Gallery标签工具栏的Image Edit按钮发送;第一张图像成为图层1(自动锁定);后续图像缩放至画布大小作为新图层添加",
@@ -2813,6 +2857,7 @@ const LANGUAGES = {
helpTrouble5: "LoRA Stack出现「No such file or directory」错误:该LoRA可能未被comfyui-lora-manager识别(已知问题)。请尝试其他LoRA,或检查该文件是否显示在Lora Manager自身的界面中",
helpTrouble6: "移动或删除模型后出现模型加载错误:ComfyUI会缓存文件路径,可能仍引用旧位置。请通过ComfyUI菜单执行Hard Reset(Queue → Hard Reset)或重启ComfyUI以清除缓存。",
helpTrouble7: "Tagger标签不显示模型:确认ComfyUI/models/tagger/<模型名>/文件夹存在且包含.onnx或.h5文件;如未安装onnxruntime,请运行:python_embeded\\python.exe -m pip install onnxruntime",
helpTrouble8: "Model 标签页显示的 Checkpoint 与预期不符(例如无论加载哪个工作流都显示相同模型):工作流文件中保存的 Checkpoint 实际未安装,加载时已被静默替换为其他已安装模型,此时会弹出包含原始(未找到)模型名称的错误提示。请在 Model 标签页手动选择正确的 Checkpoint,或在设置标签页启用\"默认 Checkpoint\",在每次加载时强制应用一个已验证可用的模型。",
helpSupportTitle: "支持",
helpSupportDesc: "如果您觉得这个插件有用,请考虑支持它的开发!",
helpGithubDesc: "报告问题、请求功能和贡献代码",
@@ -2836,6 +2881,10 @@ const LANGUAGES = {
comfyuiConnection: "ComfyUI 连接",
comfyuiUrl: "ComfyUI URL",
comfyuiUrlHint: "作为ComfyUI插件运行时留空(推荐同源)。仅在不同服务器时设置。",
defaultCheckpointSettings: "默认 Checkpoint",
defaultCheckpointEnable: "加载工作流时强制应用默认 Checkpoint",
defaultCheckpointModel: "默认 Checkpoint 模型",
defaultCheckpointHint: "启用后,每次将工作流加载到 GenerateUI 时,所有 Checkpoint 加载节点的模型都会被覆盖为此值,用于避免工作流文件中保存的模型与当前环境不匹配导致生成错误或图像模糊。",
connectedCheck: "已连接 \u2713",
failedConnect: "连接失败 \u2717",
ollamaSettings: "AI助手设置(提示词标签页)",
@@ -2844,6 +2893,8 @@ const LANGUAGES = {
selectModel: "选择模型...",
noModelsFound: "未找到模型",
failedLoadModels: "获取模型列表失败",
modelNotFound: "未找到",
modelNotFoundHint: "此工作流中保存的模型在已安装的模型列表中未找到,请从列表中选择正确的模型。",
saveOllama: "保存AI助手设置",
testConnection: "测试连接",
ollamaConnected: "已连接 \u2713",
+53
View File
@@ -637,6 +637,30 @@ export async function initSettingsTab() {
<div id="wfm-settings-url-status" style="font-size:12px;margin-top:4px;"></div>
</details>
<!-- Default Checkpoint -->
<details class="wfm-settings-section">
<summary class="wfm-settings-summary">${t("defaultCheckpointSettings")}</summary>
<div class="wfm-form-group">
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;">
<input type="checkbox" id="wfm-settings-default-ckpt-enabled" ${serverSettings.default_checkpoint_enabled ? "checked" : ""}>
<span id="wfm-settings-default-ckpt-enable-label">${t("defaultCheckpointEnable")}</span>
</label>
</div>
<div class="wfm-form-group">
<label id="wfm-settings-default-ckpt-model-label">${t("defaultCheckpointModel")}</label>
<div style="display:flex;gap:8px;">
<select class="wfm-select" id="wfm-settings-default-ckpt-select" style="flex:1;">
<option value="">${t("selectModel")}</option>
</select>
<button class="wfm-btn wfm-btn-sm" id="wfm-settings-default-ckpt-refresh">${t("refresh")}</button>
</div>
<small id="wfm-settings-default-ckpt-hint" style="color:var(--wfm-text-secondary);font-size:11px;display:block;margin-top:4px;">
${t("defaultCheckpointHint")}
</small>
</div>
<button class="wfm-btn wfm-btn-primary wfm-btn-sm" id="wfm-settings-default-ckpt-save">${t("save")}</button>
</details>
<!-- AI Assistant Settings (Prompt Tab) -->
<details class="wfm-settings-section">
<summary class="wfm-settings-summary">${t("ollamaSettings")}</summary>
@@ -1210,6 +1234,35 @@ export async function initSettingsTab() {
statusEl.style.color = ok ? "var(--wfm-success)" : "var(--wfm-danger)";
});
// Default Checkpoint
const defaultCkptSelect = document.getElementById("wfm-settings-default-ckpt-select");
async function loadDefaultCkptOptions() {
if (!defaultCkptSelect) return;
try {
const list = await comfyUI.fetchCheckpoints();
const saved = serverSettings.default_checkpoint_name || "";
defaultCkptSelect.innerHTML = `<option value="">${t("selectModel")}</option>` +
(list || []).map((m) => `<option value="${m}" ${m === saved ? "selected" : ""}>${m}</option>`).join("");
} catch { /* ignore */ }
}
loadDefaultCkptOptions();
document.getElementById("wfm-settings-default-ckpt-refresh")?.addEventListener("click", loadDefaultCkptOptions);
document.getElementById("wfm-settings-default-ckpt-save")?.addEventListener("click", async () => {
const enabled = !!document.getElementById("wfm-settings-default-ckpt-enabled")?.checked;
const ckptName = defaultCkptSelect?.value || "";
try {
await saveServerSettings({ default_checkpoint_enabled: enabled, default_checkpoint_name: ckptName });
serverSettings.default_checkpoint_enabled = enabled;
serverSettings.default_checkpoint_name = ckptName;
showToast(t("aiToastSettingsSaved"), "success");
} catch (err) {
showToast(`${t("saveError")}: ${err.message}`, "error");
}
});
// Test Eagle URL (via server proxy to avoid CORS)
document.getElementById("wfm-settings-test-eagle")?.addEventListener("click", async () => {
const urlInput = document.getElementById("wfm-settings-eagle-url");
+21 -2
View File
@@ -1283,10 +1283,10 @@
<ul>
<li id="wfm-help-ai-1">4-pane layout — Translation | Chat | TOOLS | Settings — all panes are always visible simultaneously</li>
<li id="wfm-help-ai-2">Translation pane: translate text between Japanese, English, Chinese, or a custom Free language using Ollama or LM Studio; ⇄ swap button swaps both language selectors and text content; selections are saved automatically</li>
<li id="wfm-help-ai-3">Chat pane: multi-turn conversation with the LLM; Enter to send a message, Shift+Enter for a newline; Clear button resets the conversation history</li>
<li id="wfm-help-ai-3">Chat pane: multi-turn conversation with the LLM; Enter to send a message, Shift+Enter for a newline; Clear button resets the conversation history; if the model supports tool calling and asks for an image ("generate a cat picture", etc.) it will run generation on the workflow currently loaded in GenerateUI and show the result inline; the "Allow image generation" checkbox in the pane header toggles this on/off</li>
<li id="wfm-help-ai-4">TOOLS pane — VLM: drop an image (PNG/JPG/WebP) and select a task (Describe Image, Create Prompt, Create Tags), then click Run to analyze with a vision model; result shown with Copy button</li>
<li id="wfm-help-ai-5">TOOLS pane — Wildcards: select "Create wildcards" from the dropdown, enter a category name and count, click Run to generate plain-text wildcard entries one per line</li>
<li id="wfm-help-ai-6">Settings pane: choose backend (Ollama / LM Studio), set API URL, test connection, select model, configure Free language names; settings are shared with the Library panel's A tab via localStorage</li>
<li id="wfm-help-ai-6">Settings pane: choose backend (Ollama / LM Studio), set API URL, test connection, select model, configure Free language names; Chat Image Generation section lets you enable a dedicated workflow for Chat-triggered generation instead of the one currently loaded in GenerateUI; settings are shared with the Library panel's A tab via localStorage</li>
</ul>
</div>
</div>
@@ -1468,6 +1468,7 @@
<li id="wfm-help-trouble-5">LoRA Stack fails with "No such file or directory" error: The LoRA may not be recognized by comfyui-lora-manager (known issue). Try a different LoRA or check if the file appears in Lora Manager's own UI</li>
<li id="wfm-help-trouble-6">Model loading error after moving or deleting models: ComfyUI caches file paths and may still reference old locations. Perform a Hard Reset from the ComfyUI menu (Queue → Hard Reset) or restart ComfyUI to clear the cache.</li>
<li id="wfm-help-trouble-7"></li>
<li id="wfm-help-trouble-8"></li>
</ul>
</div>
</div>
@@ -2007,6 +2008,10 @@
<button id="wfm-ai-chat-send-btn" class="wfm-btn wfm-btn-primary">Send</button>
<button id="wfm-ai-chat-clear-btn" class="wfm-btn">Clear</button>
<span id="wfm-ai-chat-status" class="wfm-ai-trans-status"></span>
<label class="wfm-ai-chat-toggle-label" for="wfm-ai-chat-imggen-toggle">
<input type="checkbox" id="wfm-ai-chat-imggen-toggle" checked>
<span id="wfm-ai-chat-imggen-label-text">Allow image generation</span>
</label>
</div>
</div>
</div>
@@ -2092,6 +2097,20 @@
<input type="text" id="wfm-ai-free-dst-lang" class="wfm-input" placeholder="e.g. German">
</div>
</div>
<div class="wfm-ai-settings-section">
<div class="wfm-ai-settings-title" id="wfm-ai-settings-chatgen-title">Chat Image Generation</div>
<div class="wfm-ai-settings-row">
<label class="wfm-ai-label" style="display:flex;align-items:center;gap:6px;cursor:pointer;">
<input type="checkbox" id="wfm-ai-chatgen-dedicated-checkbox">
<span id="wfm-ai-chatgen-dedicated-label">Use dedicated workflow</span>
</label>
</div>
<div class="wfm-ai-settings-row" id="wfm-ai-chatgen-dedicated-row" style="display:none;">
<select id="wfm-ai-chatgen-dedicated-select" class="wfm-select">
<option value="">-- select workflow --</option>
</select>
</div>
</div>
<div class="wfm-ai-settings-section">
<button id="wfm-ai-settings-save-btn" class="wfm-btn wfm-btn-primary">Save</button>
</div>