koishi-plugin-aka-ai-generator 0.2.17 → 0.2.18

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.
Files changed (2) hide show
  1. package/lib/index.js +5 -60
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -852,35 +852,6 @@ function apply(ctx, config) {
852
852
  return value?.replace(/^\-+/, "").trim().toLowerCase();
853
853
  }
854
854
  __name(normalizeSuffix, "normalizeSuffix");
855
- function parseNumImagesFromPrompt(prompt) {
856
- if (!prompt || typeof prompt !== "string") {
857
- return { numImages: void 0, cleanedPrompt: prompt };
858
- }
859
- const patterns = [
860
- /生成\s*([1-4])\s*张(?:图片)?/i,
861
- /([1-4])\s*张(?:图片)?/,
862
- /生成\s*([1-4])\s*个(?:图片)?/i,
863
- /([1-4])\s*个(?:图片)?/,
864
- /num[:\s]*([1-4])/i,
865
- /数量[:\s]*([1-4])/i
866
- ];
867
- let numImages = void 0;
868
- let cleanedPrompt = prompt;
869
- for (const pattern of patterns) {
870
- const match = prompt.match(pattern);
871
- if (match) {
872
- const num = parseInt(match[1], 10);
873
- if (num >= 1 && num <= 4) {
874
- numImages = num;
875
- cleanedPrompt = prompt.replace(pattern, "").trim();
876
- cleanedPrompt = cleanedPrompt.replace(/\s+/g, " ").replace(/[,,]\s*$/, "").trim();
877
- break;
878
- }
879
- }
880
- }
881
- return { numImages, cleanedPrompt };
882
- }
883
- __name(parseNumImagesFromPrompt, "parseNumImagesFromPrompt");
884
855
  function buildModelMappingIndex(mappings) {
885
856
  const map = /* @__PURE__ */ new Map();
886
857
  if (!Array.isArray(mappings)) return map;
@@ -1453,26 +1424,14 @@ ${infoParts.join("\n")}`;
1453
1424
  userPromptParts.push(modifiers.customPromptSuffix);
1454
1425
  }
1455
1426
  const userPromptText = userPromptParts.join(" - ");
1456
- let promptNumImages = void 0;
1457
- let cleanedUserPrompt = userPromptText;
1458
- if (userPromptText) {
1459
- const parsed = parseNumImagesFromPrompt(userPromptText);
1460
- if (parsed.numImages) {
1461
- promptNumImages = parsed.numImages;
1462
- cleanedUserPrompt = parsed.cleanedPrompt;
1463
- if (config.logLevel === "debug") {
1464
- logger.debug("从 prompt 中解析到生成数量", { numImages: promptNumImages, cleanedPrompt: cleanedUserPrompt });
1465
- }
1466
- }
1467
- }
1468
- const numImages = options?.num || promptNumImages || config.defaultNumImages;
1427
+ const numImages = options?.num || config.defaultNumImages;
1469
1428
  const limitCheck = await checkDailyLimit(session.userId, numImages);
1470
1429
  if (!limitCheck.allowed) {
1471
1430
  return limitCheck.message;
1472
1431
  }
1473
1432
  const promptSegments = [style.prompt];
1474
- if (cleanedUserPrompt) {
1475
- promptSegments.push(cleanedUserPrompt);
1433
+ if (userPromptText) {
1434
+ promptSegments.push(userPromptText);
1476
1435
  }
1477
1436
  const mergedPrompt = promptSegments.filter(Boolean).join(" - ");
1478
1437
  const requestContext = {
@@ -1555,15 +1514,8 @@ ${infoParts.join("\n")}`;
1555
1514
  if (!prompt) {
1556
1515
  return "未检测到prompt描述,请重新发送";
1557
1516
  }
1558
- const { numImages: promptNumImages, cleanedPrompt } = parseNumImagesFromPrompt(prompt);
1559
- if (promptNumImages) {
1560
- prompt = cleanedPrompt;
1561
- if (config.logLevel === "debug") {
1562
- logger.debug("从 prompt 中解析到生成数量", { numImages: promptNumImages, cleanedPrompt });
1563
- }
1564
- }
1565
1517
  const imageUrl = collectedImages[0];
1566
- const imageCount = options?.num || promptNumImages || config.defaultNumImages;
1518
+ const imageCount = options?.num || config.defaultNumImages;
1567
1519
  if (imageCount < 1 || imageCount > 4) {
1568
1520
  return "生成数量必须在 1-4 之间";
1569
1521
  }
@@ -1661,14 +1613,7 @@ Prompt: ${prompt}`);
1661
1613
  if (!prompt) {
1662
1614
  return "未检测到prompt描述,请重新发送";
1663
1615
  }
1664
- const { numImages: promptNumImages, cleanedPrompt } = parseNumImagesFromPrompt(prompt);
1665
- if (promptNumImages) {
1666
- prompt = cleanedPrompt;
1667
- if (config.logLevel === "debug") {
1668
- logger.debug("从 prompt 中解析到生成数量", { numImages: promptNumImages, cleanedPrompt });
1669
- }
1670
- }
1671
- const imageCount = options?.num || promptNumImages || config.defaultNumImages;
1616
+ const imageCount = options?.num || config.defaultNumImages;
1672
1617
  if (imageCount < 1 || imageCount > 4) {
1673
1618
  return "生成数量必须在 1-4 之间";
1674
1619
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-aka-ai-generator",
3
3
  "description": "自用AI生成插件(GPTGod & Yunwu)",
4
- "version": "0.2.17",
4
+ "version": "0.2.18",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [