dsh-mo-image 0.7.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +286 -52
- package/lib/adapter-kit.js +150 -253
- package/lib/adapters/async.js +264 -277
- package/lib/adapters/cn.js +133 -81
- package/lib/adapters/openai.js +188 -157
- package/lib/adapters.js +3090 -945
- package/lib/client.js +6444 -858
- package/lib/comfy-workflow.js +96 -10
- package/lib/config-store.js +1072 -136
- package/lib/field-templates.js +385 -0
- package/lib/image-execution.js +40 -817
- package/lib/image-jobs.js +23 -12
- package/lib/image-request.js +830 -0
- package/lib/image-service.js +96 -133
- package/lib/image-worker.js +84 -71
- package/lib/index.js +833 -327
- package/lib/localized-error.js +4 -0
- package/lib/model-rules.js +1055 -0
- package/lib/net.js +60 -25
- package/lib/output-profiles.js +1225 -0
- package/lib/png-scale.js +53 -46
- package/lib/prompt-profiles.js +83 -38
- package/lib/provider-operations.js +291 -0
- package/lib/proxy-dispatcher.js +11 -5
- package/lib/proxy.js +10 -8
- package/lib/request-auth.js +86 -31
- package/lib/settings-memory.js +112 -28
- package/lib/status.js +6 -3
- package/locale/messages.csv +396 -226
- package/package.json +1 -1
- package/scripts/release.mjs +79 -64
- package/skills/mo-image-editing/SKILL.md +7 -13
- package/skills/mo-image-generation/SKILL.md +7 -6
package/lib/png-scale.js
CHANGED
|
@@ -130,7 +130,8 @@ export function decodePng(buffer) {
|
|
|
130
130
|
const width = header.width;
|
|
131
131
|
const height = header.height;
|
|
132
132
|
const colorType = header.colorType;
|
|
133
|
-
|
|
133
|
+
const pixels = pixelCount(width, height);
|
|
134
|
+
if (!pixels) return null;
|
|
134
135
|
|
|
135
136
|
let offset = 33;
|
|
136
137
|
let palette = null;
|
|
@@ -150,11 +151,11 @@ export function decodePng(buffer) {
|
|
|
150
151
|
const type = buffer.toString('ascii', offset + 4, offset + 8);
|
|
151
152
|
if (type === 'IHDR') return null;
|
|
152
153
|
if (type === 'PLTE') {
|
|
153
|
-
palette =
|
|
154
|
+
palette = buffer.subarray(start, dataEnd);
|
|
154
155
|
} else if (type === 'tRNS') {
|
|
155
|
-
transparency =
|
|
156
|
-
} else if (type === 'IDAT') {
|
|
157
|
-
idat.push(
|
|
156
|
+
transparency = buffer.subarray(start, dataEnd);
|
|
157
|
+
} else if (type === 'IDAT' && length) {
|
|
158
|
+
idat.push(buffer.subarray(start, dataEnd));
|
|
158
159
|
} else if (type === 'IEND') {
|
|
159
160
|
if (length !== 0) return null;
|
|
160
161
|
sawIend = true;
|
|
@@ -167,64 +168,70 @@ export function decodePng(buffer) {
|
|
|
167
168
|
if (colorType === 3 && !palette) return null;
|
|
168
169
|
|
|
169
170
|
const stride = width * channels;
|
|
170
|
-
const
|
|
171
|
+
const rowSize = stride + 1;
|
|
172
|
+
const expected = height * rowSize;
|
|
171
173
|
if (!Number.isSafeInteger(expected) || expected <= 0) return null;
|
|
172
174
|
let raw;
|
|
173
175
|
try {
|
|
174
176
|
// 只解到期望长度:压缩炸弹会在超出时抛错,而不是先占满内存。
|
|
175
|
-
raw = zlib.inflateSync(Buffer.concat(idat), { maxOutputLength: expected });
|
|
177
|
+
raw = zlib.inflateSync(idat.length === 1 ? idat[0] : Buffer.concat(idat), { maxOutputLength: expected });
|
|
176
178
|
} catch (_error) {
|
|
177
179
|
return null;
|
|
178
180
|
}
|
|
179
181
|
if (!raw || raw.length !== expected) return null;
|
|
180
|
-
const pixels = Buffer.alloc(height * stride);
|
|
181
182
|
|
|
182
|
-
|
|
183
|
+
// 在解压缓冲区内还原扫描线。过滤器只依赖当前行左侧和上一行,不需要第二份像素副本。
|
|
183
184
|
for (let y = 0; y < height; y++) {
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
|
|
185
|
+
const rowStart = y * rowSize + 1;
|
|
186
|
+
const filter = raw[rowStart - 1];
|
|
187
|
+
if (filter === 0) continue;
|
|
188
|
+
if (filter > 4) return null;
|
|
189
|
+
const prevStart = rowStart - rowSize;
|
|
187
190
|
for (let x = 0; x < stride; x++) {
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (filter ===
|
|
194
|
-
else if (filter ===
|
|
195
|
-
else
|
|
196
|
-
|
|
197
|
-
else if (filter === 4) out = value + paeth(a, b, c);
|
|
198
|
-
else return null;
|
|
199
|
-
pixels[rowStart + x] = out & 0xff;
|
|
191
|
+
const a = x >= channels ? raw[rowStart + x - channels] : 0;
|
|
192
|
+
const b = y > 0 ? raw[prevStart + x] : 0;
|
|
193
|
+
const c = x >= channels && y > 0 ? raw[prevStart + x - channels] : 0;
|
|
194
|
+
let prediction;
|
|
195
|
+
if (filter === 1) prediction = a;
|
|
196
|
+
else if (filter === 2) prediction = b;
|
|
197
|
+
else if (filter === 3) prediction = (a + b) >> 1;
|
|
198
|
+
else prediction = paeth(a, b, c);
|
|
199
|
+
raw[rowStart + x] = (raw[rowStart + x] + prediction) & 0xff;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const v = pixels[src];
|
|
209
|
-
rgba[dst] = v; rgba[dst + 1] = v; rgba[dst + 2] = v; rgba[dst + 3] = 255;
|
|
210
|
-
} else if (colorType === 2) {
|
|
211
|
-
rgba[dst] = pixels[src]; rgba[dst + 1] = pixels[src + 1]; rgba[dst + 2] = pixels[src + 2]; rgba[dst + 3] = 255;
|
|
212
|
-
} else if (colorType === 3) {
|
|
213
|
-
const index = pixels[src];
|
|
214
|
-
const at = index * 3;
|
|
215
|
-
rgba[dst] = palette[at] || 0;
|
|
216
|
-
rgba[dst + 1] = palette[at + 1] || 0;
|
|
217
|
-
rgba[dst + 2] = palette[at + 2] || 0;
|
|
218
|
-
rgba[dst + 3] = transparency && index < transparency.length ? transparency[index] : 255;
|
|
219
|
-
} else if (colorType === 4) {
|
|
220
|
-
const v = pixels[src];
|
|
221
|
-
rgba[dst] = v; rgba[dst + 1] = v; rgba[dst + 2] = v; rgba[dst + 3] = pixels[src + 1];
|
|
222
|
-
} else {
|
|
223
|
-
rgba[dst] = pixels[src]; rgba[dst + 1] = pixels[src + 1]; rgba[dst + 2] = pixels[src + 2]; rgba[dst + 3] = pixels[src + 3];
|
|
203
|
+
if (colorType === 6) {
|
|
204
|
+
// RGBA 只需移除每行的过滤字节,复用整个解压缓冲区。
|
|
205
|
+
for (let y = 0; y < height; y++) {
|
|
206
|
+
const rowStart = y * rowSize + 1;
|
|
207
|
+
raw.copyWithin(y * stride, rowStart, rowStart + stride);
|
|
224
208
|
}
|
|
209
|
+
return { width, height, rgba: new Uint8Array(raw.buffer, raw.byteOffset, pixels * 4) };
|
|
225
210
|
}
|
|
226
211
|
|
|
227
|
-
|
|
212
|
+
const rgba = new Uint8Array(pixels * 4);
|
|
213
|
+
let dst = 0;
|
|
214
|
+
for (let y = 0; y < height; y++) {
|
|
215
|
+
const rowStart = y * rowSize + 1;
|
|
216
|
+
for (let src = rowStart; src < rowStart + stride; src += channels, dst += 4) {
|
|
217
|
+
if (colorType === 0 || colorType === 4) {
|
|
218
|
+
const gray = raw[src];
|
|
219
|
+
rgba[dst] = gray; rgba[dst + 1] = gray; rgba[dst + 2] = gray;
|
|
220
|
+
rgba[dst + 3] = colorType === 4 ? raw[src + 1] : 255;
|
|
221
|
+
} else if (colorType === 2) {
|
|
222
|
+
rgba[dst] = raw[src]; rgba[dst + 1] = raw[src + 1]; rgba[dst + 2] = raw[src + 2]; rgba[dst + 3] = 255;
|
|
223
|
+
} else {
|
|
224
|
+
const index = raw[src];
|
|
225
|
+
const at = index * 3;
|
|
226
|
+
rgba[dst] = palette[at] || 0;
|
|
227
|
+
rgba[dst + 1] = palette[at + 1] || 0;
|
|
228
|
+
rgba[dst + 2] = palette[at + 2] || 0;
|
|
229
|
+
rgba[dst + 3] = transparency && index < transparency.length ? transparency[index] : 255;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return { width, height, rgba };
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
/** 面积平均缩放(不是最近邻,小图不会锯齿)。 */
|
package/lib/prompt-profiles.js
CHANGED
|
@@ -22,13 +22,16 @@ function languageLabel(language) {
|
|
|
22
22
|
/**
|
|
23
23
|
* 模型族 → 提示词写法。match 只看模型 ID,adapter 是模型 ID 认不出时的兜底。
|
|
24
24
|
* 顺序有意义:越具体的族越靠前。
|
|
25
|
+
*
|
|
26
|
+
* `adapter` 只收**还存在的协议 id**:gpt-image / dall-e-3 这两族原来靠 adapter 兜底,
|
|
27
|
+
* 协议合并成 openai-images 之后那个 id 已经不存在(同一条协议下两个族要的写法还相反),
|
|
28
|
+
* 兜底交给它们自己的 match;volcengine-ark 同理(seedream / doubao 的 match 已覆盖)。
|
|
25
29
|
*/
|
|
26
30
|
const PROFILES = [
|
|
27
31
|
{
|
|
28
32
|
id: 'gpt-image',
|
|
29
33
|
label: 'OpenAI GPT-Image',
|
|
30
34
|
match: /gpt-?image|chatgpt-?image/i,
|
|
31
|
-
adapter: 'gpt-image',
|
|
32
35
|
language: 'en',
|
|
33
36
|
supportsNegative: false,
|
|
34
37
|
supportsEdit: true,
|
|
@@ -44,7 +47,6 @@ const PROFILES = [
|
|
|
44
47
|
id: 'dall-e-3',
|
|
45
48
|
label: 'OpenAI DALL·E 3',
|
|
46
49
|
match: /dall-?e-?3/i,
|
|
47
|
-
adapter: 'dall-e-3',
|
|
48
50
|
language: 'en',
|
|
49
51
|
supportsNegative: false,
|
|
50
52
|
supportsEdit: false,
|
|
@@ -75,7 +77,6 @@ const PROFILES = [
|
|
|
75
77
|
id: 'seedream',
|
|
76
78
|
label: '字节 Seedream',
|
|
77
79
|
match: /seedream|doubao.*(?:image|t2i)/i,
|
|
78
|
-
adapter: 'volcengine-ark',
|
|
79
80
|
language: 'zh',
|
|
80
81
|
supportsNegative: false,
|
|
81
82
|
supportsEdit: true,
|
|
@@ -224,10 +225,32 @@ function paramType(param) {
|
|
|
224
225
|
return type;
|
|
225
226
|
}
|
|
226
227
|
|
|
227
|
-
|
|
228
|
+
function qualitySettings(state, catalog) {
|
|
229
|
+
if (!state || (!catalog && state.qualitySpec === undefined)) return {};
|
|
230
|
+
const automatic = state.defaults?.quality === 'auto';
|
|
231
|
+
if (catalog) return { qualityMode: automatic ? 'auto' : 'fixed' };
|
|
232
|
+
if (!state.qualitySpec) return { qualityMode: 'unsupported' };
|
|
233
|
+
if (!automatic) return { qualityMode: 'fixed', quality: state.quality };
|
|
234
|
+
return {
|
|
235
|
+
qualityMode: 'auto',
|
|
236
|
+
qualityOptions: state.qualitySpec.options.map((item) => item.value).filter((value) => value !== 'auto')
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function qualityRuleText(settings) {
|
|
241
|
+
if (settings.qualityMode === 'auto') {
|
|
242
|
+
return '质量为自动:可从 qualityOptions 选一个档位传 quality,不传则用上游默认。目录缺少档位时按候选查询。';
|
|
243
|
+
}
|
|
244
|
+
if (settings.qualityMode === 'fixed') return '质量由选择器固定,不要传 quality。';
|
|
245
|
+
if (settings.qualityMode === 'unsupported') return '当前模型没有独立质量档位,不要传 quality。';
|
|
246
|
+
return '';
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function settingsPayload(state, { includeParamDetails = false } = {}) {
|
|
228
250
|
const provider = (state && state.provider) || null;
|
|
229
251
|
const model = String((state && state.model) || '').trim();
|
|
230
252
|
const optimized = !(state && state.promptOptimization === false);
|
|
253
|
+
const catalog = model === 'auto' && !includeParamDetails;
|
|
231
254
|
const payload = {
|
|
232
255
|
provider: provider ? String(provider.id || '') : '',
|
|
233
256
|
model: model,
|
|
@@ -235,6 +258,7 @@ export function settingsPayload(state) {
|
|
|
235
258
|
canEdit: Boolean(state && state.canEdit),
|
|
236
259
|
// 自动尺寸下模型可以自己填 size;固定尺寸下选择器说了算。
|
|
237
260
|
sizeMode: state && state.sizeMode === 'fixed' ? 'fixed' : 'auto',
|
|
261
|
+
...qualitySettings(state, catalog),
|
|
238
262
|
strict: !!(state && state.strict === true),
|
|
239
263
|
hint: ''
|
|
240
264
|
};
|
|
@@ -242,10 +266,14 @@ export function settingsPayload(state) {
|
|
|
242
266
|
payload.hint = '还没有选择生图模型,请让用户先到设置里选一个';
|
|
243
267
|
return payload;
|
|
244
268
|
}
|
|
245
|
-
|
|
269
|
+
const qualityHint = qualityRuleText(payload);
|
|
270
|
+
if (catalog) {
|
|
246
271
|
payload.hint = optimized
|
|
247
|
-
? '
|
|
272
|
+
? '按所选模型的方言写'
|
|
248
273
|
: '直接用用户原话,不要扩写';
|
|
274
|
+
payload.hint += ';要确认某个候选的尺寸、编辑能力或可调参数时,传该 model 给 mo_image_settings。';
|
|
275
|
+
if (qualityHint) payload.hint += ' ' + qualityHint;
|
|
276
|
+
if (payload.sizeMode === 'fixed' && state.size) payload.size = String(state.size);
|
|
249
277
|
payload.models = (Array.isArray(state && state.models) ? state.models : []).filter(Boolean).map(String);
|
|
250
278
|
// 改图只在能图生图的模型里选;没传 model 时插件会自动取第一个。
|
|
251
279
|
payload.editModels = (Array.isArray(state && state.editModels) ? state.editModels : []).filter(Boolean).map(String);
|
|
@@ -253,39 +281,54 @@ export function settingsPayload(state) {
|
|
|
253
281
|
}
|
|
254
282
|
const profile = resolvePromptProfile(model, (state && state.adapter) || null);
|
|
255
283
|
payload.hint = optimized
|
|
256
|
-
? (PROFILE_HINTS[profile.id] || profile.label)
|
|
284
|
+
? (PROFILE_HINTS[profile.id] || profile.label)
|
|
257
285
|
: '直接用用户原话,不要扩写,不要补 negative prompt';
|
|
258
286
|
const sizeMode = payload.sizeMode;
|
|
259
287
|
if (state && state.control) payload.control = String(state.control);
|
|
260
288
|
if (sizeMode === 'fixed') {
|
|
261
|
-
|
|
262
|
-
payload.hint += '
|
|
289
|
+
if (state && state.size) payload.size = String(state.size);
|
|
290
|
+
payload.hint += ';尺寸已固定,不要填 size,用户要别的形状就让他去选择器改';
|
|
263
291
|
} else {
|
|
264
292
|
if (state && Array.isArray(state.sizeOptions) && state.sizeOptions.length) {
|
|
265
293
|
payload.sizeOptions = state.sizeOptions.map(String);
|
|
266
294
|
}
|
|
267
|
-
payload.hint += '
|
|
295
|
+
payload.hint += ';尺寸交给模型:可按构图或用户要求填 size(如 1024x1536),默认尺寸合适时留空';
|
|
268
296
|
}
|
|
297
|
+
if (qualityHint) payload.hint += ';' + qualityHint;
|
|
269
298
|
if (payload.strict) {
|
|
270
|
-
payload.hint += '
|
|
299
|
+
payload.hint += ';严格模式尝试将成品缩放到明确的像素宽高;比例或档位没有精确像素目标';
|
|
271
300
|
}
|
|
272
301
|
const workflowParams = Array.isArray(state && state.workflowParams)
|
|
273
302
|
? state.workflowParams.filter((param) => param && param.expose !== false)
|
|
274
303
|
: [];
|
|
275
304
|
if (workflowParams.length) {
|
|
276
305
|
// 参数只走结构化的 params,hint 里不再重复列一遍名字。
|
|
306
|
+
// 名字叫 workflowParams 是历史原因:清单里现在既有工作流行,也有 HTTP 参数行(A1111 / 通用路径)。
|
|
277
307
|
payload.params = workflowParams.map((param) => {
|
|
278
308
|
const out = { name: param.name, type: paramType(param) };
|
|
279
309
|
if (Array.isArray(param.options)) out.options = param.options;
|
|
310
|
+
if (includeParamDetails && param.description) out.description = param.description;
|
|
311
|
+
if (includeParamDetails && param.default !== undefined && param.default !== '') out.default = param.default;
|
|
280
312
|
return out;
|
|
281
313
|
});
|
|
282
|
-
payload.hint += ';可用 params
|
|
314
|
+
payload.hint += ';可用 params 覆盖这些参数,不传就用默认值';
|
|
283
315
|
}
|
|
284
316
|
return payload;
|
|
285
317
|
}
|
|
286
318
|
|
|
287
|
-
/**
|
|
288
|
-
|
|
319
|
+
/** The structured result retains the original shape. The model sees each ID only once. */
|
|
320
|
+
export function settingsForModel(payload) {
|
|
321
|
+
if (!Array.isArray(payload?.models) || !Array.isArray(payload?.editModels)) return payload;
|
|
322
|
+
const { editModels, models, ...settings } = payload;
|
|
323
|
+
const editable = new Set(editModels);
|
|
324
|
+
const indexes = [];
|
|
325
|
+
for (const [index, model] of models.entries()) if (editable.has(model)) indexes.push(index);
|
|
326
|
+
const editModelIndexes = indexes.length && indexes.length === models.length ? 'all' : indexes;
|
|
327
|
+
return { ...settings, models, editModelIndexes };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const OPTIMIZE_PROMPT = '- 优化粗略需求,保留主体、限制、指定语言和逐字文本;已有适用成稿或用户要求原样时直接用。';
|
|
331
|
+
const REUSE_GUIDANCE = '- 复用上下文已有写法;缺少所需指引时才加载相应 skill。';
|
|
289
332
|
|
|
290
333
|
/** 每个模型族一句最短提示:就是 mo_image_settings 里 hint 的内容,别的都不要。 */
|
|
291
334
|
const PROFILE_HINTS = {
|
|
@@ -309,8 +352,8 @@ const PROFILE_HINTS = {
|
|
|
309
352
|
const DELIVERY_RULES = [
|
|
310
353
|
'- 交付即止:最终回复只输出图片行,不评价画质、不描述画面;除非用户明确要求看图,不要读图。',
|
|
311
354
|
'- 只用选择器里的提供商和模型:不要自行切换,也不要用本地生图、建模、脚本绘图替代。',
|
|
312
|
-
'-
|
|
313
|
-
'-
|
|
355
|
+
'- 配置不匹配(未提交):refresh:true 重读,修正后只试一次。其余失败原样报错,可以问用户是否换模型。',
|
|
356
|
+
'- 收到 needsSettings:应用同一步返回的设置,只调整受影响的内容,再发起新调用。'
|
|
314
357
|
];
|
|
315
358
|
|
|
316
359
|
/**
|
|
@@ -322,13 +365,14 @@ export const CONFIG_STATE_MARKER = '{{' + CONFIG_STATE_VARIABLE + '}}';
|
|
|
322
365
|
|
|
323
366
|
const CONFIG_STATE_TEXT = {
|
|
324
367
|
unread: '本会话还没读过 —— 先调用 mo_image_settings',
|
|
325
|
-
stale: '用户刚改过 ——
|
|
326
|
-
|
|
368
|
+
stale: '用户刚改过 —— 直接调用生图/改图工具接收增量',
|
|
369
|
+
refresh: '需要重新对齐完整配置 —— 直接调用生图/改图工具接收完整配置',
|
|
370
|
+
fresh: '和上次读到的一致 —— 仍在上下文就不用再读;缺少时用 refresh:true'
|
|
327
371
|
};
|
|
328
372
|
|
|
329
373
|
/**
|
|
330
374
|
* 把配置状态翻成模型能直接照做的一句话。
|
|
331
|
-
* @param {'unread'|'stale'|'fresh'} state
|
|
375
|
+
* @param {'unread'|'stale'|'refresh'|'fresh'} state
|
|
332
376
|
*/
|
|
333
377
|
export function configStateText(state) {
|
|
334
378
|
return CONFIG_STATE_TEXT[state] || CONFIG_STATE_TEXT.unread;
|
|
@@ -336,20 +380,20 @@ export function configStateText(state) {
|
|
|
336
380
|
|
|
337
381
|
/** Auto 行:用户把选择器设为 Auto 时,模型选择权才下放给对话模型。 */
|
|
338
382
|
function autoSectionText(state, marker) {
|
|
339
|
-
const
|
|
340
|
-
const editModels = Array.isArray(state && state.editModels) ? state.editModels.filter(Boolean) : [];
|
|
383
|
+
const optimize = state?.promptOptimization !== false;
|
|
341
384
|
return [
|
|
342
385
|
'<mo-image-prompt>',
|
|
343
386
|
'仅生成/编辑图片时使用,其他任务忽略。',
|
|
344
387
|
...(marker ? ['- 配置状态:' + marker] : []),
|
|
345
|
-
'- 当前模型:Auto
|
|
346
|
-
'
|
|
347
|
-
'
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
388
|
+
'- 当前模型:Auto。用设置结果中 models 的原始 ID。',
|
|
389
|
+
'- 生图传 model;改图从 editModelIndexes 选,或省略以使用首个可改图模型。',
|
|
390
|
+
'- 需要候选细节时查询 mo_image_settings({ model })。',
|
|
391
|
+
...(optimize
|
|
392
|
+
? ['- 提示词优化:On,按所选模型的方言写。', OPTIMIZE_PROMPT]
|
|
393
|
+
: ['- 提示词优化:Off,直接用用户原话,不要扩写,不要套用公式或自动补 negative_prompt。只有用户明确要求优化时才改写。']),
|
|
394
|
+
REUSE_GUIDANCE,
|
|
352
395
|
sizeRuleText(state, { modelByPicker: false }),
|
|
396
|
+
qualityRuleText(qualitySettings(state, true)),
|
|
353
397
|
...DELIVERY_RULES,
|
|
354
398
|
'</mo-image-prompt>'
|
|
355
399
|
].join('\n');
|
|
@@ -366,18 +410,18 @@ export function sizeRuleText(state, options) {
|
|
|
366
410
|
const control = String((state && state.control) || '');
|
|
367
411
|
const modelByPicker = !(options && options.modelByPicker === false);
|
|
368
412
|
const tail = modelByPicker
|
|
369
|
-
? '
|
|
370
|
-
: '
|
|
413
|
+
? '提供商和模型同样由选择器控制。'
|
|
414
|
+
: '模型必须从当前提供商的目录里选,提供商不能换。';
|
|
371
415
|
const parts = [];
|
|
372
416
|
if (mode === 'fixed') {
|
|
373
417
|
parts.push('- 尺寸已固定为 ' + (label || '选择器里的值') + ',不要传 size;要别的尺寸让用户去选择器改。' + tail);
|
|
374
418
|
} else {
|
|
375
419
|
const sizeValues = Array.isArray(state && state.sizeOptions) ? state.sizeOptions.filter(Boolean) : [];
|
|
376
|
-
parts.push('-
|
|
420
|
+
parts.push('- 尺寸由你决定:可按构图或用户要求传 size(如 1024x1536),默认尺寸合适时省略;' + tail
|
|
377
421
|
+ (sizeValues.length ? '可选尺寸:' + sizeValues.join(' / ') : ''));
|
|
378
422
|
}
|
|
379
423
|
if (state && state.strict === true) {
|
|
380
|
-
parts.push('-
|
|
424
|
+
parts.push('- 严格模式已开。会尝试缩放到明确的像素宽高,无法安全缩放时会标注实际尺寸。比例和档位没有精确目标。');
|
|
381
425
|
}
|
|
382
426
|
if (control === 'aspect') {
|
|
383
427
|
parts.push('- 该模型只吃宽高比:size 给 3:4 这类比例即可。');
|
|
@@ -408,7 +452,9 @@ export function promptSectionText(state, marker) {
|
|
|
408
452
|
'- 只做最低限度整理:保留主体、动作、文字、语言和限制;分段可原样拼接,不加用户没说的内容。',
|
|
409
453
|
'- 不要自动补 negative_prompt:用户没说的排除项不加。',
|
|
410
454
|
sizeRuleText(state),
|
|
411
|
-
|
|
455
|
+
...(state?.qualitySpec !== undefined ? [qualityRuleText(qualitySettings(state, false))] : []),
|
|
456
|
+
'- 不要套用公式或模板。',
|
|
457
|
+
REUSE_GUIDANCE,
|
|
412
458
|
'- 只有用户明确要求“优化/改写提示词”时,才按当前模型方言改写,并说明是应要求改写。',
|
|
413
459
|
'- 编辑时 prompt 同样只写原话或最小必要修改;images 按用户指定的参考图传。',
|
|
414
460
|
...DELIVERY_RULES,
|
|
@@ -426,6 +472,7 @@ export function promptSectionText(state, marker) {
|
|
|
426
472
|
lines.push('仅生成/编辑图片时使用,其他任务忽略。');
|
|
427
473
|
if (marker) lines.push('- 配置状态:' + marker);
|
|
428
474
|
lines.push('- 当前模型:' + model + '(' + profile.label + '),按其方言写。');
|
|
475
|
+
lines.push(OPTIMIZE_PROMPT);
|
|
429
476
|
if (state && state.canEdit === false) lines.push('- 该模型不支持图生图:微调/重做先换支持编辑的模型。');
|
|
430
477
|
lines.push('- 不用传 model:用选择器里的当前模型;传了不一致的值会被拒绝。');
|
|
431
478
|
for (const rule of DELIVERY_RULES) lines.push(rule);
|
|
@@ -436,12 +483,10 @@ export function promptSectionText(state, marker) {
|
|
|
436
483
|
: '无 negative prompt:用正面描述和硬约束表达排除项。'));
|
|
437
484
|
lines.push('- 提示词语言:' + languageLabel(profile.language) + ';用户明确指定时从用户。');
|
|
438
485
|
lines.push(sizeRuleText(state));
|
|
486
|
+
if (state?.qualitySpec !== undefined) lines.push(qualityRuleText(qualitySettings(state, false)));
|
|
439
487
|
const exposedParams = Array.isArray(state && state.workflowParams) ? state.workflowParams : [];
|
|
440
488
|
if (exposedParams.length) {
|
|
441
|
-
|
|
442
|
-
lines.push('- 可调参数:' + exposedParams.map((param) => param.name).join('、')
|
|
443
|
-
+ '。按需主动调整,用法见 skill mo-image-generation「参数调优」;'
|
|
444
|
-
+ '没读过才加载,拿不准就留空。');
|
|
489
|
+
lines.push('- 按需调整设置结果里的可调参数,拿不准就留空;额外指引见「参数调优」。');
|
|
445
490
|
}
|
|
446
491
|
lines.push('编辑公式:' + EDITING_FORMULA + '。');
|
|
447
492
|
if (editProfile) {
|
|
@@ -449,7 +494,7 @@ export function promptSectionText(state, marker) {
|
|
|
449
494
|
} else {
|
|
450
495
|
lines.push('编辑:' + profile.editRule);
|
|
451
496
|
}
|
|
452
|
-
lines.push(
|
|
497
|
+
lines.push(REUSE_GUIDANCE);
|
|
453
498
|
lines.push('</mo-image-prompt>');
|
|
454
499
|
return lines.join('\n');
|
|
455
500
|
}
|