-
-
Notifications
You must be signed in to change notification settings - Fork 525
feat: 😽对reset在不同情况下的权限特殊处理, 使其兼容alter_cmd 🤠为new指令增加清理上下文选项, 默认为清理, 更符合直觉 #1362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
带有上下文清理的 new 命令的序列图sequenceDiagram
participant User
participant AstrBot
participant ConversationManager
participant LTM (Long Term Memory)
User->>AstrBot: /new [clean: bool]
AstrBot->>ConversationManager: new_conversation(message.unified_msg_origin)
ConversationManager-->>AstrBot: cid
alt clean == True
AstrBot->>ConversationManager: update_conversation(message.unified_msg_origin, cid, [])
AstrBot->>LTM: remove_session(event=message)
LTM-->>AstrBot: Ack
end
AstrBot->>User: Switch to new conversation message
alter_cmd reset scene 的序列图sequenceDiagram
participant User
participant AstrBot
participant sp (SettingsProvider)
User->>AstrBot: /alter_cmd reset scene <scene_num> <perm_type>
AstrBot->>AstrBot: Validate scene_num and perm_type
alt scene_num or perm_type invalid
AstrBot->>User: Error message
else scene_num and perm_type valid
AstrBot->>sp: get("alter_cmd", {})
sp-->>AstrBot: alter_cmd_cfg
AstrBot->>AstrBot: Update reset_cfg with new permission
AstrBot->>sp: put("alter_cmd", alter_cmd_cfg)
sp-->>AstrBot: Ack
AstrBot->>User: Confirmation message
end
文件级别更改
提示和命令与 Sourcery 交互
自定义您的体验访问您的 仪表板 以:
获取帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request introduces changes to the Sequence diagram for reset command permission checksequenceDiagram
participant User
participant AstrBot
participant Context
User->>AstrBot: /reset
AstrBot->>Context: get_config()
Context-->>AstrBot: config
AstrBot->>AstrBot: Determine scene (group_unique_on/off, private)
AstrBot->>Context: sp.get("alter_cmd", {})
Context-->>AstrBot: alter_cmd_cfg
AstrBot->>AstrBot: Get required permission from config
alt User is not admin and required permission is admin
AstrBot->>User: Error message (insufficient permissions)
else User is admin or required permission is member
AstrBot->>AstrBot: Reset LLM session
AstrBot->>User: Success message
end
Sequence diagram for new command with context cleaningsequenceDiagram
participant User
participant AstrBot
participant ConversationManager
participant LTM (Long Term Memory)
User->>AstrBot: /new [clean: bool]
AstrBot->>ConversationManager: new_conversation(message.unified_msg_origin)
ConversationManager-->>AstrBot: cid
alt clean == True
AstrBot->>ConversationManager: update_conversation(message.unified_msg_origin, cid, [])
AstrBot->>LTM: remove_session(event=message)
LTM-->>AstrBot: Ack
end
AstrBot->>User: Switch to new conversation message
Sequence diagram for alter_cmd reset scenesequenceDiagram
participant User
participant AstrBot
participant sp (SettingsProvider)
User->>AstrBot: /alter_cmd reset scene <scene_num> <perm_type>
AstrBot->>AstrBot: Validate scene_num and perm_type
alt scene_num or perm_type invalid
AstrBot->>User: Error message
else scene_num and perm_type valid
AstrBot->>sp: get("alter_cmd", {})
sp-->>AstrBot: alter_cmd_cfg
AstrBot->>AstrBot: Update reset_cfg with new permission
AstrBot->>sp: put("alter_cmd", alter_cmd_cfg)
sp-->>AstrBot: Ack
AstrBot->>User: Confirmation message
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @anka-afk - 我已经审查了你的更改 - 这里有一些反馈:
总体评论:
- 考虑在帮助文本中添加有关
reset
命令的配置选项的更详细描述。 - 用于处理
reset
命令权限的逻辑有点复杂;确保对其进行全面测试以涵盖所有场景。
以下是我在审查期间查看的内容
- 🟡 一般问题:发现 1 个问题
- 🟢 安全性:一切看起来都不错
- 🟢 测试:一切看起来都不错
- 🟡 复杂性:发现 1 个问题
- 🟢 文档:一切看起来都不错
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @anka-afk - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a more detailed description of the configuration options for the
reset
command in the help text. - The logic for handling the
reset
command's permissions is a bit complex; ensure it's thoroughly tested to cover all scenarios.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances the permission and context management for the reset and new commands. The changes include:
- Adding granular scene-based configuration for the reset command.
- Introducing an optional context cleaning parameter for the new conversation command.
- Extending the alter_cmd command to support detailed reset permissions configuration.
Comments suppressed due to low confidence (1)
packages/astrbot/main.py:1418
- The docstring for 'scene_key' mentions '场景编号,1-3', but the actual expected values are 'group_unique_on', 'group_unique_off', or 'private'. Update the docstring for clarity.
def update_reset_permission(self, scene_key: str, perm_type: str):
Co-authored-by: 渡鸦95676 <[email protected]>
Co-authored-by: Copilot <[email protected]>
packages/astrbot/main.py
Outdated
@@ -732,8 +775,13 @@ async def convs(self, message: AstrMessageEvent, page: int = 1): | |||
return | |||
|
|||
@filter.command("new") | |||
async def new_conv(self, message: AstrMessageEvent): | |||
"""创建新对话""" | |||
async def new_conv(self, message: AstrMessageEvent, clean: bool = True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我认为不需要这个参数(而且目前来说指令系统无法处理 bool 类型参数),new 指令一定会清理 “记录群员聊天” 产生的上下文,即 await self.ltm.remove_session(event=message)。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这么看的话应该不太适合在new清理长期记忆了, 现在的长期记忆没有对应每个对话一个, 原本设计来就是为了跨越多个对话的吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得如果用户希望在群聊里 new 对话,那么应该就是打算清理整个对话,重新开始了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得如果用户希望在群聊里 new 对话,那么应该就是打算清理整个对话,重新开始了
我直觉上也是这样的, 之前new之后仍然保留前面的对话的bug这么看应该是聊天增强没清除的问题
感觉没问题了 |
修复了 #1360
Motivation
Modifications
Check
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
增强 reset 和 new 命令的权限和上下文管理,以改善用户体验并提供更灵活的配置选项。
新功能:
增强功能:
Original summary in English
Summary by Sourcery
Enhance the permission and context management for reset and new commands to improve user experience and provide more flexible configuration options
New Features:
Enhancements: