Skip to content

feat: 让 /ds 在群内共享上下文 - #48

Closed
riesaexe wants to merge 1 commit into
MooncellWiki:mainfrom
riesaexe:feat/group-deepseek-context
Closed

feat: 让 /ds 在群内共享上下文#48
riesaexe wants to merge 1 commit into
MooncellWiki:mainfrom
riesaexe:feat/group-deepseek-context

Conversation

@riesaexe

Copy link
Copy Markdown

改动动机

目前每次使用 /ds 提问都会新建一个会话,导致新的提问无法引用群内之前的讨论内容。

主要改动

  • 用本地插件 src/plugins/deepseek 替换 nonebot-plugin-deepseek 外部依赖。
  • 同一群聊内的所有成员共用同一个 DeepSeek 会话上下文。
  • 不同群聊、私聊之间的上下文完全隔离。
  • 当历史消息数超过 DEEPSEEK__MAX_HISTORY(默认 20 条)时,自动保留最近的消息。
  • 新增 /ds reset / /deepseek reset 用于手动重置当前会话。
  • 在消息中附带提问者昵称/ID,方便 AI 识别是谁在提问。

配置项

DEEPSEEK__API_KEY=sk-xxx
DEEPSEEK__BASE_URL=https://api.deepseek.com
DEEPSEEK__MODEL=deepseek-chat
DEEPSEEK__MAX_HISTORY=20
DEEPSEEK__TIMEOUT=600

测试

  • ruff check src/plugins/deepseek 通过。
  • pyright src/plugins/deepseek 通过。
  • 本地模拟群聊验证:同群用户共享上下文、跨群隔离、超出消息数截断、/ds reset 可清空会话。

注意

此改动会移除原 nonebot-plugin-deepseek 提供的余额查询、TTS、Markdown 转图片等子命令。如果项目仍需要这些功能,可以在后续迭代中补齐。

- Replace nonebot-plugin-deepseek with local src/plugins/deepseek plugin
- Share conversation history within the same group across all users
- Isolate contexts between different groups/private chats
- Trim history to DEEPSEEK__MAX_HISTORY (default 20) messages
- Add /ds reset to clear current session
@riesaexe riesaexe closed this Jun 29, 2026
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.

1 participant