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.
Files changed (2) hide show
  1. package/lib/index.js +12 -4
  2. 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 nonEmptyPayload = batchPayload.filter((p) => p.text.trim() || p.images.length > 0);
1207
- if (nonEmptyPayload.length === 0) return [];
1208
- const userMessage = { role: "user", content: JSON.stringify(nonEmptyPayload) };
1209
- const analysePrompt = `你是一位内容分析专家。请使用中文,分析我以JSON格式提供的一组内容,为每一项内容总结关键词、概括内容并评分。你的回复必须且只能是一个包裹在 \`\`\`json ... \`\`\` 代码块中的有效 JSON 对象。该JSON对象应有一个 "analyses" 键,其值为一个数组。数组中的每个对象都必须包含 "id" (整数), "keywords" (字符串数组), "description" (字符串), "rating" (0-100的整数)。`;
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,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-best-cave",
3
3
  "description": "功能强大、高度可定制的回声洞。支持丰富的媒体类型、内容查重、人工审核、用户昵称、数据迁移以及本地/S3 双重文件存储后端。",
4
- "version": "2.7.16",
4
+ "version": "2.7.17",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],