From 0c0841cc0380b4929902c3f339b629c869732f73 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 9 Jan 2025 16:33:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20websearch=20=E5=9C=A8=20cmd=5Fconfig=20?= =?UTF-8?q?=E4=B8=AD=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/star/star_manager.py | 2 -- packages/web_searcher/main.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index b62854c7d..45f107656 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -317,8 +317,6 @@ class PluginManager: async def turn_on_plugin(self, plugin_name: str): plugin = self.context.get_registered_star(plugin_name) - if not plugin: - raise Exception("插件已经启用,无需重新启用。") inactivated_plugins: list = sp.get("inactivated_plugins", []) inactivated_llm_tools: list = sp.get("inactivated_llm_tools", []) if plugin.module_path in inactivated_plugins: diff --git a/packages/web_searcher/main.py b/packages/web_searcher/main.py index 31a285394..468fa4337 100644 --- a/packages/web_searcher/main.py +++ b/packages/web_searcher/main.py @@ -22,6 +22,18 @@ class Main(star.Star): self.sogo_search = Sogo() self.google = Google() + self.enable_jinaai = self.context.get_config()['provider_settings']['web_search_jinaai'] + self.jinaai_api_key = self.context.get_config()['provider_settings']['web_search_jinaai_api_key'] + + async def initialize(self): + websearch = self.context.get_config()['provider_settings']['web_search'] + if websearch: + self.context.activate_llm_tool("web_search") + self.context.activate_llm_tool("fetch_url") + else: + self.context.deactivate_llm_tool("web_search") + self.context.deactivate_llm_tool("fetch_url") + async def _tidy_text(self, text: str) -> str: '''清理文本,去除空格、换行符等''' return text.strip().replace("\n", " ").replace("\r", " ").replace(" ", " ")