From 25f120f18fa27a87338c306d604a1db6d5bb7697 Mon Sep 17 00:00:00 2001 From: taylor Date: Mon, 14 Oct 2024 01:00:07 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=B7=BB=E5=8A=A0=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maubot_llmplus/aibot.py | 4 +++- maubot_llmplus/platforms.py | 2 +- maubot_llmplus/plugin.py | 7 +------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/maubot_llmplus/aibot.py b/maubot_llmplus/aibot.py index e22b124..8177741 100644 --- a/maubot_llmplus/aibot.py +++ b/maubot_llmplus/aibot.py @@ -18,6 +18,7 @@ from maubot_llmplus.thrid_platform import OpenAi, Anthropic class Config(BaseProxyConfig): + def do_update(self, helper: ConfigUpdateHelper) -> None: helper.copy("allowed_users") helper.copy("use_platform") @@ -27,6 +28,7 @@ class Config(BaseProxyConfig): helper.copy("system_prompt") helper.copy("platforms") helper.copy("additional_prompt") + super._cur_model = self['platforms'][self['use_platform']]['model'] class AiBotPlugin(AbsExtraConfigPlugin): @@ -182,7 +184,7 @@ class AiBotPlugin(AbsExtraConfigPlugin): models = platform.list_models() if f"- {arg_elements[1]}" in models: self.log.debug(f"switch model: {arg_elements[1]}") - self.model = arg_elements[1] + self.config._cur_model = arg_elements[1] await event.react("✅") else: await event.reply("not found valid model") diff --git a/maubot_llmplus/platforms.py b/maubot_llmplus/platforms.py index e907a33..e444378 100644 --- a/maubot_llmplus/platforms.py +++ b/maubot_llmplus/platforms.py @@ -40,7 +40,7 @@ class Platform: self.http = http self.config = config['platforms'][self.get_type()] self.url = self.config['url'] - self.model = self.config['model'] + self.model = config._cur_model self.max_words = self.config['max_words'] self.api_key = self.config['api_key'] self.max_context_messages = self.config['max_context_messages'] diff --git a/maubot_llmplus/plugin.py b/maubot_llmplus/plugin.py index a13a762..0c1d120 100644 --- a/maubot_llmplus/plugin.py +++ b/maubot_llmplus/plugin.py @@ -5,18 +5,13 @@ class AbsExtraConfigPlugin(Plugin): default_username: str user_id: str - model: str; - async def start(self) -> None: await super().start() self.default_username = await self.client.get_displayname(self.client.mxid) self.user_id = self.client.parse_user_id(self.client.mxid)[0] - self.model = self.config['platforms'][self.config['use_platform']]['model'] + def get_bot_name(self) -> str: return self.config['name'] or \ self.default_username or \ self.user_id - - def get_use_model(self) -> str: - return self.model