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.
@@ -43,7 +43,17 @@ const loadSkillsFromPath = (skillsDir) => {
43
43
  return skills;
44
44
  };
45
45
  // 获取技能列表的简介和名称
46
- const loadSkills = () => {
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
- // console.log(`加载技能: ${uniqueSkills.length}个`);
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 };
@@ -1,7 +1,7 @@
1
1
  var title = "IA聊天插件";
2
2
  var desc = "一个基于AI的聊天插件,支持多种AI模型和丰富的功能配置,适用于各种聊天场景。";
3
3
  var name = "alemonjs-aichat";
4
- var version = "v1.0.29";
4
+ var version = "v1.0.31-beta";
5
5
  var by = "AlemonJS";
6
6
  var list = [
7
7
  {
@@ -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: imgs,
47
+ image_url: uploadedImgUrls,
42
48
  instruction: content,
43
49
  });
44
50
  if (res && typeof res === "object" && res.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs-aichat",
3
- "version": "1.0.30",
3
+ "version": "1.0.31-beta.0",
4
4
  "description": "alemonjs-aichat",
5
5
  "author": "suancaixianyu",
6
6
  "license": "MIT",
@@ -52,4 +52,4 @@
52
52
  "sharp": "^0.34.5",
53
53
  "zod": "^4.3.6"
54
54
  }
55
- }
55
+ }