Skip to content

feat(chat): 添加 chat compact 指令#1210

Merged
This-is-XiaoDeng merged 2 commits into
mainfrom
feat/chat-compact
Jun 16, 2026
Merged

feat(chat): 添加 chat compact 指令#1210
This-is-XiaoDeng merged 2 commits into
mainfrom
feat/chat-compact

Conversation

@This-is-XiaoDeng

Copy link
Copy Markdown
Member

改动内容

新增 chat compact 指令

注册 chat compact [会话ID] 子命令,用于压缩会话的消息队列。

功能说明:

  • 仅限 superuser 使用
  • 可选传入目标会话 ID,不传则使用当前会话
  • 如果目标会话有缓存消息,先触发即时记忆(instant memory)生成
  • 然后重置该会话的消息队列(清除 LLM 对话历史 + 数据库缓存)
  • 重置后自动注入已有的即时记忆,保留上下文连续性

典型使用场景:

  • 群聊上下文过长,需要清理但不想丢失记忆
  • 手动触发记忆压缩

修改的文件

  • src/plugins/nonebot_plugin_chat/matcher/chat.py — 添加 handle_compact 方法和 match case
  • src/lang/zh_hans/chat.yaml — 添加 compact 相关本地化字符串和帮助条目
  • src/lang/zh_tw/chat.yaml — 同上
  • src/lang/en_us/chat.yaml — 同上
  • src/plugins/nonebot_plugin_chat/help.yaml — 更新 usage 数量

- 注册 chat compact 子命令,仅限 superuser 使用
- 可选传入会话 ID,不传则使用当前会话
- 生成即时记忆后重置消息队列,保留记忆上下文
- 在 zh_hans/zh_tw/en_us 本地化文件中添加相关提示文本
- 在 help.yaml 中添加帮助信息
@This-is-XiaoDeng This-is-XiaoDeng requested a review from xxtg666 June 16, 2026 08:01
@github-actions github-actions Bot requested a review from montmorill June 16, 2026 08:01
@codacy-production

codacy-production Bot commented Jun 16, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@This-is-XiaoDeng This-is-XiaoDeng merged commit 5d8e763 into main Jun 16, 2026
3 checks passed
@This-is-XiaoDeng This-is-XiaoDeng deleted the feat/chat-compact branch June 16, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants