Skip to content

Conversation

@Futureppo
Copy link
Contributor

@Futureppo Futureppo commented Oct 2, 2025

fixes #XYZ


Motivation / 动机

  • 为插件市场的搜索增加拼音与首字母搜索功能。

Modifications / 改动点

  • 修改文件
    • dashboard/src/views/ExtensionPage.vue:
      • 引入 pinyin-pro
      • 新增工具函数:normalizeStrtoPinyinTexttoInitials
      • 新增 marketCustomFilter,对名称/简称/描述/作者进行拼音与首字母匹配
      • 在市场表格 v-data-table 绑定 :custom-filter="marketCustomFilter"
    • dashboard/package.json:
      • 依赖新增 "pinyin-pro": "^3.26.0"
  • 实现结果:市场搜索框支持中文直搜、全拼、首字母等。

Verification Steps / 验证步骤

  1. 进入前端目录 dashboard 执行:
    • npm i
    • npm run dev
  2. 打开面板进入 插件市场 页面。
  3. 在搜索框验证以下案例:
    • 名称匹配:输入“zhineng”或“zn”应能匹配包含“智能”的项
    • 首字母匹配:输入“fs”应能匹配“飞书”
  4. 验证原有中文/英文关键词搜索仍然有效。

Screenshots or Test Results / 运行截图或测试结果

image

Compatibility & Breaking Changes / 兼容性与破坏性变更

  • 仅前端改动;引入新前端依赖,对后端和数据无影响;无需迁移。
  • 这不是一个破坏性变更。/ This is NOT a breaking change.

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Sourcery 总结

在插件市场中启用拼音和首字母搜索,并引入一个新的机器人命令来激活所有功能工具。

新功能:

  • 在插件市场搜索中支持汉字、全拼和首字母匹配
  • 添加 "on_all" 机器人命令以启用所有可用的功能工具

改进:

  • 添加 pinyin-pro 作为前端依赖
Original summary in English

Summary by Sourcery

Enable pinyin and initials search in the plugin marketplace and introduce a new bot command to activate all function tools.

New Features:

  • Support Chinese character, full pinyin, and initials matching in the plugin marketplace search
  • Add "on_all" bot command to enable all available function tools

Enhancements:

  • Add pinyin-pro as a frontend dependency

@auto-assign auto-assign bot requested review from Soulter and advent259141 October 2, 2025 12:36
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `packages/astrbot/main.py:96-101` </location>
<code_context>
         """停用所有函数工具"""
         await self.tool_c.tool_all_off(event)

+    @tool.command("on_all")
+    async def tool_all_on(self, event: AstrMessageEvent):
+        """启用所有函数工具"""
+        tm = self.context.get_llm_tool_manager()
+        for tool in tm.func_list:
+            self.context.activate_llm_tool(tool.name)
+        event.set_result(MessageEventResult().message("启用所有工具成功。"))
+
     @filter.command_group("plugin")
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Handle activation errors for individual tools.

Currently, activation errors for individual tools are not handled, which may mislead users if some tools fail to activate. Please add error handling and reporting for each tool activation.

```suggestion
    async def tool_all_on(self, event: AstrMessageEvent):
        """启用所有函数工具"""
        tm = self.context.get_llm_tool_manager()
        failed_tools = []
        for tool in tm.func_list:
            try:
                self.context.activate_llm_tool(tool.name)
            except Exception as e:
                failed_tools.append(tool.name)
        if not failed_tools:
            msg = "启用所有工具成功。"
        else:
            msg = f"部分工具启用失败:{', '.join(failed_tools)}。其他工具已成功启用。"
        event.set_result(MessageEventResult().message(msg))
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +96 to +101
async def tool_all_on(self, event: AstrMessageEvent):
"""启用所有函数工具"""
tm = self.context.get_llm_tool_manager()
for tool in tm.func_list:
self.context.activate_llm_tool(tool.name)
event.set_result(MessageEventResult().message("启用所有工具成功。"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Handle activation errors for individual tools.

Currently, activation errors for individual tools are not handled, which may mislead users if some tools fail to activate. Please add error handling and reporting for each tool activation.

Suggested change
async def tool_all_on(self, event: AstrMessageEvent):
"""启用所有函数工具"""
tm = self.context.get_llm_tool_manager()
for tool in tm.func_list:
self.context.activate_llm_tool(tool.name)
event.set_result(MessageEventResult().message("启用所有工具成功。"))
async def tool_all_on(self, event: AstrMessageEvent):
"""启用所有函数工具"""
tm = self.context.get_llm_tool_manager()
failed_tools = []
for tool in tm.func_list:
try:
self.context.activate_llm_tool(tool.name)
except Exception as e:
failed_tools.append(tool.name)
if not failed_tools:
msg = "启用所有工具成功。"
else:
msg = f"部分工具启用失败:{', '.join(failed_tools)}。其他工具已成功启用。"
event.set_result(MessageEventResult().message(msg))

@Futureppo Futureppo closed this by deleting the head repository Oct 2, 2025
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