koishi-plugin-p-draw 1.5.6 → 1.5.7
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/index.js +26 -16
- package/package.json +1 -1
- package/readme.md +1 -0
package/index.js
CHANGED
|
@@ -478,11 +478,15 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
478
478
|
return `已扣除 ${totalPrice} P 点,${modelSeed}`
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
function buildGenerationReply(session, { successCount, count, failures, notes = [] }) {
|
|
481
|
+
function buildGenerationReply(session, { successCount, count, failures, notes = [] }) {
|
|
482
482
|
const reply = []
|
|
483
483
|
if (notes.length) reply.push(notes.join('\n'))
|
|
484
484
|
if (failures.length) reply.push(session.text('.batch-partial', [successCount, count, failures.length, failures.join(';')]))
|
|
485
|
-
return reply.filter(Boolean).join('\n')
|
|
485
|
+
return reply.filter(Boolean).join('\n')
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function shouldOptimizePerImage({ count, enabled, admin }) {
|
|
489
|
+
return count > 1 && (enabled || admin)
|
|
486
490
|
}
|
|
487
491
|
|
|
488
492
|
async function sendNotices(session, notices, opts = {}) {
|
|
@@ -1866,19 +1870,25 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
1866
1870
|
if (!raw) {
|
|
1867
1871
|
const globalOpt = cfg.promptOptimizeEnabled
|
|
1868
1872
|
const adminOpt = !globalOpt && isAdmin && cfg.llmModel && cfg.llmBaseUrl
|
|
1869
|
-
const tokenOpt = !globalOpt && !isAdmin && cfg.llmModel && cfg.llmBaseUrl
|
|
1870
|
-
if (globalOpt) {
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1873
|
+
const tokenOpt = !globalOpt && !isAdmin && cfg.llmModel && cfg.llmBaseUrl
|
|
1874
|
+
if (globalOpt) {
|
|
1875
|
+
if (shouldOptimizePerImage({ count, enabled: true, admin: false })) {
|
|
1876
|
+
perImageOptimize = true
|
|
1877
|
+
} else {
|
|
1878
|
+
const optimized = await optimizePrompt(session, userPrompt, false)
|
|
1879
|
+
finalPrompt = optimized.prompt
|
|
1880
|
+
degraded = !optimized.ok
|
|
1881
|
+
optimizedReason = optimized.reason || ''
|
|
1882
|
+
}
|
|
1883
|
+
} else if (adminOpt) {
|
|
1884
|
+
if (shouldOptimizePerImage({ count, enabled: false, admin: true })) {
|
|
1885
|
+
perImageOptimize = true
|
|
1886
|
+
} else {
|
|
1887
|
+
const optimized = await optimizePrompt(session, userPrompt, true)
|
|
1888
|
+
finalPrompt = optimized.prompt
|
|
1889
|
+
degraded = !optimized.ok
|
|
1890
|
+
optimizedReason = optimized.reason || ''
|
|
1891
|
+
}
|
|
1882
1892
|
} else if (tokenOpt) {
|
|
1883
1893
|
// 全局优化关闭:使用 p-shop 的「提示词优化券」(p_system.llmToken)。
|
|
1884
1894
|
// 券一次性,按张数扣:x3 扣 3 张,每张图独立做一次 LLM 优化。
|
|
@@ -2169,5 +2179,5 @@ exports.apply = async function apply(ctx, cfg) {
|
|
|
2169
2179
|
})
|
|
2170
2180
|
|
|
2171
2181
|
// 暴露内部接口供自动化测试调用(Koishi 忽略 apply 返回值,不影响生产行为)
|
|
2172
|
-
return { couponConfirmFlow, buyCouponsAndConsume, normalizeConfirm, resolveCouponPrice, buildChargeNotice, buildGenerationReply, sendNotices, sendImagesAsForward, executeBatch }
|
|
2182
|
+
return { couponConfirmFlow, buyCouponsAndConsume, normalizeConfirm, resolveCouponPrice, buildChargeNotice, buildGenerationReply, shouldOptimizePerImage, sendNotices, sendImagesAsForward, executeBatch }
|
|
2173
2183
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -21,6 +21,7 @@ p点-绘图插件,连接本地 ComfyUI 生图,参考 AstrBot 的 [anima 绘
|
|
|
21
21
|
- `p-draw 状态` 查看 ComfyUI 连接状态与模型可用性。
|
|
22
22
|
- `p-draw help`(或 `帮助`)查看全部指令帮助,包含生成 / 多人 / 批量张数 / 尺寸 / 画师组 / 状态等。
|
|
23
23
|
- 发图时会以合并转发发送,每张图片后附对应的 Positive / Negative 提示词;生成完成消息会显示实际模型和 seed(如 `已扣除 750 P 点,当前模型:animagine-xl-3.1.safetensors,--seed=123456`)。管理员/免扣费用户不显示扣费金额,但仍显示模型和 seed。
|
|
24
|
+
- 批量生成(如 `x5` / `x10`)开启 LLM 优化时,每张图会在生成前单独重新优化一次提示词;因此 `random color hair`、`random color eyes` 等动态要求可以在不同图片中产生不同结果。
|
|
24
25
|
|
|
25
26
|
## 安装
|
|
26
27
|
|