koishi-plugin-best-cave 2.7.16 → 2.7.17
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 +12 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1203,10 +1203,18 @@ var AIManager = class {
|
|
|
1203
1203
|
)).filter(Boolean);
|
|
1204
1204
|
return { id: cave.id, text: combinedText, images: imagesBase64 };
|
|
1205
1205
|
}));
|
|
1206
|
-
const
|
|
1207
|
-
if (
|
|
1208
|
-
const
|
|
1209
|
-
const
|
|
1206
|
+
const nonEmptyPayloads = batchPayload.filter((p) => p.text.trim() || p.images.length > 0);
|
|
1207
|
+
if (nonEmptyPayloads.length === 0) return [];
|
|
1208
|
+
const contentForAI = [];
|
|
1209
|
+
const textData = nonEmptyPayloads.map(({ id, text }) => ({ id, text }));
|
|
1210
|
+
contentForAI.push({ type: "text", text: JSON.stringify(textData) });
|
|
1211
|
+
nonEmptyPayloads.forEach((payload) => {
|
|
1212
|
+
payload.images.forEach((imageBase64Url) => {
|
|
1213
|
+
contentForAI.push({ type: "image_url", image_url: { url: imageBase64Url } });
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
const userMessage = { role: "user", content: contentForAI };
|
|
1217
|
+
const analysePrompt = `你是一位内容分析专家。请使用中文,分析我以JSON格式提供的一组内容(位于消息的第一个 text 部分),并结合可能附带的图片,为每一项内容总结关键词、概括内容并评分。你的回复必须且只能是一个包裹在 \`\`\`json ... \`\`\` 代码块中的有效 JSON 对象。该JSON对象应有一个 "analyses" 键,其值为一个数组。数组中的每个对象都必须包含 "id" (整数), "keywords" (字符串数组), "description" (字符串), 和 "rating" (0-100的整数)。`;
|
|
1210
1218
|
const response = await this.requestAI([userMessage], analysePrompt);
|
|
1211
1219
|
return (response.analyses || []).map((res) => ({
|
|
1212
1220
|
cave: res.id,
|