koishi-plugin-aka-ai-generator 0.3.3 → 0.3.6
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/lib/index.js +38 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1249,12 +1249,22 @@ function apply(ctx, config) {
|
|
|
1249
1249
|
return { images: [], text: imgParam.trim() };
|
|
1250
1250
|
}
|
|
1251
1251
|
await session.send("请输入画面描述");
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1252
|
+
while (true) {
|
|
1253
|
+
const msg = await session.prompt(3e4);
|
|
1254
|
+
if (!msg) return { error: "等待超时" };
|
|
1255
|
+
const elements = import_koishi.h.parse(msg);
|
|
1256
|
+
const images = import_koishi.h.select(elements, "img");
|
|
1257
|
+
if (images.length > 0) {
|
|
1258
|
+
await session.send("检测到图片,请发送文字描述");
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
|
|
1262
|
+
if (!text) {
|
|
1263
|
+
await session.send("未检测到描述,请重新发送");
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
return { images: [], text };
|
|
1267
|
+
}
|
|
1258
1268
|
}
|
|
1259
1269
|
if (imgParam) {
|
|
1260
1270
|
if (typeof imgParam === "object" && imgParam.attrs?.src) {
|
|
@@ -1365,6 +1375,28 @@ function apply(ctx, config) {
|
|
|
1365
1375
|
if (extraText) {
|
|
1366
1376
|
finalPrompt += " " + extraText;
|
|
1367
1377
|
}
|
|
1378
|
+
finalPrompt = finalPrompt.trim();
|
|
1379
|
+
if (!finalPrompt) {
|
|
1380
|
+
await session.send("请发送画面描述");
|
|
1381
|
+
while (true) {
|
|
1382
|
+
const promptMsg = await session.prompt(3e4);
|
|
1383
|
+
if (!promptMsg) {
|
|
1384
|
+
return "未检测到描述,请重新发送";
|
|
1385
|
+
}
|
|
1386
|
+
const elements = import_koishi.h.parse(promptMsg);
|
|
1387
|
+
const images = import_koishi.h.select(elements, "img");
|
|
1388
|
+
if (images.length > 0) {
|
|
1389
|
+
await session.send("检测到图片,请发送文字描述");
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1392
|
+
const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
|
|
1393
|
+
if (text) {
|
|
1394
|
+
finalPrompt = text;
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
await session.send("未检测到有效文字描述,请重新发送");
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1368
1400
|
const providerType = requestContext?.provider || config.provider;
|
|
1369
1401
|
const providerModelId = requestContext?.modelId || (providerType === "yunwu" ? config.yunwuModelId : config.gptgodModelId);
|
|
1370
1402
|
logger.info("开始图像处理", {
|