alemonjs-aichat 1.0.30 → 1.0.31-beta.0
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/api/loadSkill.js +13 -3
- package/lib/data/help.json.js +1 -1
- package/lib/response/tools/res.js +7 -1
- package/package.json +2 -2
package/lib/api/loadSkill.js
CHANGED
|
@@ -43,7 +43,17 @@ const loadSkillsFromPath = (skillsDir) => {
|
|
|
43
43
|
return skills;
|
|
44
44
|
};
|
|
45
45
|
// 获取技能列表的简介和名称
|
|
46
|
-
|
|
46
|
+
// 技能列表缓存
|
|
47
|
+
let skillsCache = null;
|
|
48
|
+
// 可选: 手动清理缓存
|
|
49
|
+
const clearSkillsCache = () => {
|
|
50
|
+
skillsCache = null;
|
|
51
|
+
};
|
|
52
|
+
const loadSkills = (forceReload = false) => {
|
|
53
|
+
// 命中缓存时直接返回,避免重复读取目录
|
|
54
|
+
if (!forceReload && skillsCache) {
|
|
55
|
+
return skillsCache;
|
|
56
|
+
}
|
|
47
57
|
const skillsDir = path.join(currentDir, "../../skills");
|
|
48
58
|
const skills = loadSkillsFromPath(skillsDir);
|
|
49
59
|
const externalSkills = loadExternalSkills();
|
|
@@ -51,7 +61,7 @@ const loadSkills = () => {
|
|
|
51
61
|
// 根据name和description去重
|
|
52
62
|
const uniqueSkills = allSkills.filter((skill, index, self) => index ===
|
|
53
63
|
self.findIndex((s) => s.name === skill.name && s.description === skill.description));
|
|
54
|
-
|
|
64
|
+
skillsCache = uniqueSkills;
|
|
55
65
|
return uniqueSkills;
|
|
56
66
|
};
|
|
57
67
|
// 获取某个技能的详情, 通过技能名称匹配对应文件夹下的所有md文件,将内容一并返回
|
|
@@ -118,4 +128,4 @@ const loadExternalSkills = () => {
|
|
|
118
128
|
return skills;
|
|
119
129
|
};
|
|
120
130
|
|
|
121
|
-
export { loadExternalSkills, loadSkillDetail, loadSkills, loadSkillsFromPath };
|
|
131
|
+
export { clearSkillsCache, loadExternalSkills, loadSkillDetail, loadSkills, loadSkillsFromPath };
|
package/lib/data/help.json.js
CHANGED
|
@@ -36,9 +36,15 @@ var res = onResponse(selects, async (e) => {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
console.log("imgs", imgs);
|
|
39
|
+
// 将图片上传到R2,避免图片被风控或者过期无法访问
|
|
40
|
+
const uploadedImgUrls = [];
|
|
41
|
+
for (const imgUrl of imgs) {
|
|
42
|
+
const uploadedUrl = await uploadImageToR2(imgUrl);
|
|
43
|
+
uploadedImgUrls.push(uploadedUrl);
|
|
44
|
+
}
|
|
39
45
|
message.send(format(Text("开始修图喵~")));
|
|
40
46
|
const res = await availableTools.Photoshop({
|
|
41
|
-
image_url:
|
|
47
|
+
image_url: uploadedImgUrls,
|
|
42
48
|
instruction: content,
|
|
43
49
|
});
|
|
44
50
|
if (res && typeof res === "object" && res.length > 0) {
|
package/package.json
CHANGED