Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6b4e7fe
Implement persistent image cache with ImageCacheManager class
Copilot May 15, 2026
84d5e90
Fix final code quality issues in image cache persistence
Copilot May 15, 2026
8901ffd
Remove history length limit trimming in save_message
nbnbnd May 15, 2026
f3b488d
Remove parenthetical content from hint strings in _conf_schema.json
nbnbnd May 15, 2026
d60a58a
Merge pull request #1 from nbnbnd/copilot/implement-image-cache-persi…
nbnbnd May 15, 2026
3ec5ac2
Initial plan
Copilot May 18, 2026
4010a1d
feat: skip repeated failed image caption attempts
Copilot May 18, 2026
240e5f8
refactor: deduplicate failed-image skip checks
Copilot May 18, 2026
9f3e898
chore: clarify failed-image skip diagnostics
Copilot May 18, 2026
0c12bf7
Merge pull request #3 from nbnbnd/copilot/update-image-caption-logic
nbnbnd May 18, 2026
84bf0bc
Ensure image is accessible before captioning
nbnbnd May 18, 2026
28c9517
Ensure image accessible before captioning
Copilot May 18, 2026
a7e0d83
Refine image access checks
Copilot May 18, 2026
f066b72
Harden image accessibility checks
Copilot May 18, 2026
e7d0dd1
Refine URL and path checks
Copilot May 18, 2026
f3bcd35
Tighten URL and path handling
Copilot May 18, 2026
fb9a54f
Validate file netloc and base64 checks
Copilot May 18, 2026
432b969
Harden file URI validation
Copilot May 18, 2026
6a35133
Simplify URL and path checks
Copilot May 18, 2026
51b3345
Merge pull request #4 from nbnbnd/copilot/ensure-image-existence-befo…
nbnbnd May 18, 2026
378e38d
Update author and repository information in metadata
nbnbnd May 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions _conf_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"group_msg_history": {
"description": "输入给大模型的消息数量",
"type": "int",
"hint": "决定了会输入给大模型多少条q群历史消息(最多200条)",
"hint": "决定了会输入给大模型多少条q群历史消息",
"default": 20
},
"enable_all_groups": {
Expand Down Expand Up @@ -93,7 +93,7 @@
"image_count":{
"description":"直接输入给大模型的图片数量",
"type":"int",
"hint":"决定了会直接输入给大模型多少张图片,仅限支持图片输入的多模态模型可用(和下面的图像转述功能可以同时开启,最近的指定数量图片会直接输入)",
"hint":"决定了会直接输入给大模型多少张图片,仅限支持图片输入的多模态模型可用",
"default":0
},
"use_image_caption": {
Expand Down Expand Up @@ -128,4 +128,4 @@
}
}
}
}
}
20 changes: 18 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ async def help(self, event: AstrMessageEvent):
" 你也可以重置指定群聊天记录 如/sc reset 群号\n"
"使用history指令可以查看最近聊天记录 如/sc history\n"
"使用mute/闭嘴指令临时禁用自动回复 如/sc mute 5 或 /sc 闭嘴 10\n"
"使用unmute/说话指令解除禁用 如/sc unmute 或 /sc 说话"
"使用unmute/说话指令解除禁用 如/sc unmute 或 /sc 说话\n"
"使用clear_image_cache/清除图片缓存指令清除图片转述缓存 如/sc clear_image_cache"
)
platform_name = event.get_platform_name()
if platform_name in ("qq_official", "qq_official_webhook"):
Expand Down Expand Up @@ -286,4 +287,19 @@ async def callllm(self, event: AstrMessageEvent):
yield await LLMUtils.call_llm(event, self.config, self.context)
except Exception as e:
logger.error(f"调用大模型时发生错误: {e}")
yield event.plain_result(f"触发大模型回复失败喵:{str(e)}")
yield event.plain_result(f"触发大模型回复失败喵:{str(e)}")

@filter.permission_type(filter.PermissionType.ADMIN)
@spectrecore.command("clear_image_cache", alias=['清除图片缓存'])
async def clear_image_cache(self, event: AstrMessageEvent):
"""清除图片转述缓存喵"""
try:
from .utils import ImageCacheManager
success = ImageCacheManager.clear()
if success:
yield event.plain_result("已成功清除图片转述缓存喵~")
else:
yield event.plain_result("清除图片转述缓存失败喵,可能发生错误")
except Exception as e:
logger.error(f"清除图片缓存时发生错误: {e}")
yield event.plain_result(f"清除图片缓存失败喵:{str(e)}")
4 changes: 2 additions & 2 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: spectrecore # 这是你的插件的唯一识别名。
desc: 使大模型更好的主动回复群聊中的消息,带来生动和沉浸的群聊对话体验 # 插件简短描述
help: 自动检测群聊消息并让AI模型进行回复,让群聊更加生动有趣。 # 插件的帮助信息
version: v2.1.11 # 插件版本号。格式:v1.1.1 或者 v1.1
author: 23q3 # 作者
repo: https://github.com/23q3/astrbot_plugin_SpectreCore # 插件的仓库地址
author: 23q3-nbnbnd # 作者
repo: https://github.com/nbnbnd/astrbot_plugin_SpectreCore # 插件的仓库地址
display_name: 🌟 SpectreCore
2 changes: 2 additions & 0 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .history_storage import HistoryStorage
from .message_utils import MessageUtils
from .image_caption import ImageCaptionUtils
from .image_cache import ImageCacheManager
from .llm_utils import LLMUtils
from .persona_utils import PersonaUtils
from .text_filter import TextFilter
Expand All @@ -14,6 +15,7 @@
"HistoryStorage",
"MessageUtils",
"ImageCaptionUtils",
"ImageCacheManager",
"LLMUtils",
"PersonaUtils",
"TextFilter",
Expand Down
5 changes: 0 additions & 5 deletions utils/history_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ async def save_message(message: AstrBotMessage, platform_name: str, chat_id_over
sanitized_message = HistoryStorage._sanitize_message(message)
history.append(sanitized_message)

# 限制历史记录数量
if len(history) > 200:
history = history[-200:]

# 确保父目录存在
os.makedirs(os.path.dirname(file_path), exist_ok=True)

Expand Down Expand Up @@ -463,4 +459,3 @@ def _cleanup_old_images() -> None:

except Exception as e:
logger.error(f"清理图片文件时发生错误: {e}")

Loading