add: 添加切换模型命令
This commit is contained in:
@@ -12,26 +12,6 @@ from maubot_llmplus.platforms import Platform
|
|||||||
from maubot_llmplus.plugin import AbsExtraConfigPlugin
|
from maubot_llmplus.plugin import AbsExtraConfigPlugin
|
||||||
from maubot_llmplus.thrid_platform import OpenAi, Anthropic
|
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")
|
|
||||||
helper.copy("name")
|
|
||||||
helper.copy("reply_in_thread")
|
|
||||||
helper.copy("enable_multi_user")
|
|
||||||
helper.copy("system_prompt")
|
|
||||||
helper.copy("platforms")
|
|
||||||
helper.copy("additional_prompt")
|
|
||||||
|
|
||||||
super._cur_model = helper.base['platforms'][helper.base['use_platform']]['model']
|
|
||||||
|
|
||||||
|
|
||||||
class AiBotPlugin(AbsExtraConfigPlugin):
|
class AiBotPlugin(AbsExtraConfigPlugin):
|
||||||
|
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ from typing import Optional, List, Generator
|
|||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from maubot import Plugin
|
from maubot import Plugin
|
||||||
from mautrix.types import MessageEvent, EncryptedEvent
|
from mautrix.types import MessageEvent, EncryptedEvent
|
||||||
from mautrix.util.config import BaseProxyConfig
|
|
||||||
|
|
||||||
from maubot_llmplus.plugin import AbsExtraConfigPlugin
|
from maubot_llmplus.plugin import AbsExtraConfigPlugin, Config
|
||||||
|
|
||||||
"""
|
"""
|
||||||
AI响应对象
|
AI响应对象
|
||||||
@@ -36,7 +35,7 @@ class Platform:
|
|||||||
system_prompt: str
|
system_prompt: str
|
||||||
max_context_messages: int
|
max_context_messages: int
|
||||||
|
|
||||||
def __init__(self, config: BaseProxyConfig, http: ClientSession) -> None:
|
def __init__(self, config: Config, http: ClientSession) -> None:
|
||||||
self.http = http
|
self.http = http
|
||||||
self.config = config['platforms'][self.get_type()]
|
self.config = config['platforms'][self.get_type()]
|
||||||
self.url = self.config['url']
|
self.url = self.config['url']
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from maubot import Plugin
|
from maubot import Plugin
|
||||||
|
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
||||||
|
|
||||||
|
|
||||||
class AbsExtraConfigPlugin(Plugin):
|
class AbsExtraConfigPlugin(Plugin):
|
||||||
@@ -10,8 +11,28 @@ class AbsExtraConfigPlugin(Plugin):
|
|||||||
self.default_username = await self.client.get_displayname(self.client.mxid)
|
self.default_username = await self.client.get_displayname(self.client.mxid)
|
||||||
self.user_id = self.client.parse_user_id(self.client.mxid)[0]
|
self.user_id = self.client.parse_user_id(self.client.mxid)[0]
|
||||||
|
|
||||||
|
|
||||||
def get_bot_name(self) -> str:
|
def get_bot_name(self) -> str:
|
||||||
return self.config['name'] or \
|
return self.config['name'] or \
|
||||||
self.default_username or \
|
self.default_username or \
|
||||||
self.user_id
|
self.user_id
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
配置文件加载
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class Config(BaseProxyConfig):
|
||||||
|
_cur_model: str
|
||||||
|
|
||||||
|
def do_update(self, helper: ConfigUpdateHelper) -> None:
|
||||||
|
helper.copy("allowed_users")
|
||||||
|
helper.copy("use_platform")
|
||||||
|
helper.copy("name")
|
||||||
|
helper.copy("reply_in_thread")
|
||||||
|
helper.copy("enable_multi_user")
|
||||||
|
helper.copy("system_prompt")
|
||||||
|
helper.copy("platforms")
|
||||||
|
helper.copy("additional_prompt")
|
||||||
|
|
||||||
|
self._cur_model = helper.base['platforms'][helper.base['use_platform']]['model']
|
||||||
|
|||||||
Reference in New Issue
Block a user