Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"lodash": "4.17.21",
"marked": "^15.0.7",
"markdown-it": "^14.1.0",
"pinyin-pro": "^3.26.0",
"pinia": "2.1.6",
"remixicon": "3.5.0",
"vee-validate": "4.11.3",
Expand Down
29 changes: 28 additions & 1 deletion dashboard/src/views/ExtensionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ConsoleDisplayer from '@/components/shared/ConsoleDisplayer.vue';
import ReadmeDialog from '@/components/shared/ReadmeDialog.vue';
import ProxySelector from '@/components/shared/ProxySelector.vue';
import axios from 'axios';
import { pinyin } from 'pinyin-pro';
import { useCommonStore } from '@/stores/common';
import { useI18n, useModuleI18n } from '@/i18n/composables';

Expand Down Expand Up @@ -65,6 +66,32 @@ const marketSearch = ref("");
const filterKeys = ['name', 'desc', 'author'];
const refreshingMarket = ref(false);

// 插件市场拼音搜索
const normalizeStr = (s) => (s ?? '').toString().toLowerCase().trim();
const toPinyinText = (s) => pinyin(s ?? '', { toneType: 'none' }).toLowerCase().replace(/\s+/g, '');
const toInitials = (s) => pinyin(s ?? '', { pattern: 'first', toneType: 'none' }).toLowerCase().replace(/\s+/g, '');
const marketCustomFilter = (value, query, item) => {
const q = normalizeStr(query);
if (!q) return true;

const candidates = new Set();
if (value != null) candidates.add(String(value));
if (item?.name) candidates.add(String(item.name));
if (item?.trimmedName) candidates.add(String(item.trimmedName));
if (item?.desc) candidates.add(String(item.desc));
if (item?.author) candidates.add(String(item.author));

for (const v of candidates) {
const nv = normalizeStr(v);
if (nv.includes(q)) return true;
const pv = toPinyinText(v);
if (pv.includes(q)) return true;
const iv = toInitials(v);
if (iv.includes(q)) return true;
}
return false;
};

const plugin_handler_info_headers = computed(() => [
{ title: tm('table.headers.eventType'), key: 'event_type_h' },
{ title: tm('table.headers.description'), key: 'desc', maxWidth: '250px' },
Expand Down Expand Up @@ -772,7 +799,7 @@ onMounted(async () => {

<v-col cols="12" md="12" style="padding: 0px;">
<v-data-table :headers="pluginMarketHeaders" :items="pluginMarketData" item-key="name"
:loading="loading_" v-model:search="marketSearch" :filter-keys="filterKeys">
:loading="loading_" v-model:search="marketSearch" :filter-keys="filterKeys" :custom-filter="marketCustomFilter">
<template v-slot:item.name="{ item }">
<div class="d-flex align-center"
style="overflow-x: auto; scrollbar-width: thin; scrollbar-track-color: transparent;">
Expand Down
8 changes: 8 additions & 0 deletions packages/astrbot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ async def tool_all_off(self, event: AstrMessageEvent):
"""停用所有函数工具"""
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("启用所有工具成功。"))
Comment on lines +96 to +101
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))


@filter.command_group("plugin")
def plugin(self):
pass
Expand Down
Loading