koishi-plugin-aka-ai-generator 0.2.2 → 0.2.4
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.d.ts +0 -2
- package/lib/index.js +30 -20
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -577,10 +577,8 @@ var Config = import_koishi.Schema.intersect([
|
|
|
577
577
|
import_koishi.Schema.const("yunwu").description("云雾 Gemini 服务"),
|
|
578
578
|
import_koishi.Schema.const("gptgod").description("GPTGod 服务")
|
|
579
579
|
]).description("可选:覆盖供应商"),
|
|
580
|
-
modelId: import_koishi.Schema.string().required().description("触发该后缀时使用的模型 ID")
|
|
581
|
-
|
|
582
|
-
description: import_koishi.Schema.string().description("该后缀的说明,方便记忆")
|
|
583
|
-
})).role("table").default([]).description("根据 -后缀切换模型/供应商与附加 prompt"),
|
|
580
|
+
modelId: import_koishi.Schema.string().required().description("触发该后缀时使用的模型 ID")
|
|
581
|
+
})).role("table").default([]).description("根据 -后缀切换模型/供应商"),
|
|
584
582
|
apiTimeout: import_koishi.Schema.number().default(120).description("API请求超时时间(秒)"),
|
|
585
583
|
commandTimeout: import_koishi.Schema.number().default(180).description("命令执行总超时时间(秒)"),
|
|
586
584
|
// 默认设置
|
|
@@ -672,15 +670,23 @@ function apply(ctx, config) {
|
|
|
672
670
|
}
|
|
673
671
|
__name(buildModelMappingIndex, "buildModelMappingIndex");
|
|
674
672
|
function parseStyleCommandModifiers(argv, imgParam) {
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
if (
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
673
|
+
const session = argv.session;
|
|
674
|
+
let rawText = "";
|
|
675
|
+
if (session?.content) {
|
|
676
|
+
const elements = import_koishi.h.parse(session.content);
|
|
677
|
+
rawText = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ");
|
|
678
|
+
}
|
|
679
|
+
const argsList = rawText ? rawText.split(/\s+/).filter(Boolean) : [...argv.args || []].map((arg) => typeof arg === "string" ? arg.trim() : "").filter(Boolean);
|
|
680
|
+
if (!rawText) {
|
|
681
|
+
const restStr = typeof argv.rest === "string" ? argv.rest.trim() : "";
|
|
682
|
+
if (restStr) {
|
|
683
|
+
const restParts = restStr.split(/\s+/).filter(Boolean);
|
|
684
|
+
argsList.push(...restParts);
|
|
685
|
+
}
|
|
686
|
+
if (imgParam && typeof imgParam === "string" && !imgParam.startsWith("http") && !imgParam.startsWith("data:")) {
|
|
687
|
+
const imgParts = imgParam.split(/\s+/).filter(Boolean);
|
|
688
|
+
argsList.push(...imgParts);
|
|
689
|
+
}
|
|
684
690
|
}
|
|
685
691
|
if (!argsList.length) return {};
|
|
686
692
|
const modifiers = { customAdditions: [] };
|
|
@@ -702,8 +708,15 @@ function apply(ctx, config) {
|
|
|
702
708
|
if (lower === "-add") {
|
|
703
709
|
index++;
|
|
704
710
|
const additionTokens = [];
|
|
705
|
-
while (index < argsList.length
|
|
706
|
-
|
|
711
|
+
while (index < argsList.length) {
|
|
712
|
+
const nextToken = argsList[index];
|
|
713
|
+
if (nextToken.startsWith("-")) {
|
|
714
|
+
const key = normalizeSuffix(nextToken);
|
|
715
|
+
if (key && modelMappingIndex.has(key)) break;
|
|
716
|
+
if (nextToken.toLowerCase().startsWith("-prompt:")) break;
|
|
717
|
+
if (nextToken.toLowerCase() === "-add") break;
|
|
718
|
+
}
|
|
719
|
+
additionTokens.push(nextToken);
|
|
707
720
|
index++;
|
|
708
721
|
}
|
|
709
722
|
if (additionTokens.length) {
|
|
@@ -1129,16 +1142,13 @@ ${infoParts.join("\n")}`;
|
|
|
1129
1142
|
}
|
|
1130
1143
|
const modifiers = parseStyleCommandModifiers(argv, img);
|
|
1131
1144
|
const promptSegments = [style.prompt];
|
|
1132
|
-
if (modifiers.modelMapping?.promptSuffix) {
|
|
1133
|
-
promptSegments.push(modifiers.modelMapping.promptSuffix);
|
|
1134
|
-
}
|
|
1135
1145
|
if (modifiers.customAdditions?.length) {
|
|
1136
1146
|
promptSegments.push(...modifiers.customAdditions);
|
|
1137
1147
|
}
|
|
1138
1148
|
if (modifiers.customPromptSuffix) {
|
|
1139
1149
|
promptSegments.push(modifiers.customPromptSuffix);
|
|
1140
1150
|
}
|
|
1141
|
-
const mergedPrompt = promptSegments.filter(Boolean).join("
|
|
1151
|
+
const mergedPrompt = promptSegments.filter(Boolean).join(" - ");
|
|
1142
1152
|
const requestContext = {
|
|
1143
1153
|
numImages: options?.num
|
|
1144
1154
|
};
|
|
@@ -1154,7 +1164,7 @@ ${infoParts.join("\n")}`;
|
|
|
1154
1164
|
}
|
|
1155
1165
|
if (modifiers.modelMapping?.modelId) {
|
|
1156
1166
|
displayInfo.modelId = modifiers.modelMapping.modelId;
|
|
1157
|
-
displayInfo.modelDescription = modifiers.modelMapping.
|
|
1167
|
+
displayInfo.modelDescription = modifiers.modelMapping.suffix || modifiers.modelMapping.modelId;
|
|
1158
1168
|
}
|
|
1159
1169
|
return processImageWithTimeout(session, img, mergedPrompt, style.commandName, requestContext, displayInfo);
|
|
1160
1170
|
});
|