From 09d38e4abfa5695d47055aae71b7b76c13ac4e37 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Tue, 29 Aug 2023 17:50:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E4=BA=8E=E5=AE=89=E5=85=A8=E6=80=A7?= =?UTF-8?q?=E8=80=83=E8=99=91=EF=BC=8C=E9=BB=98=E8=AE=A4=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 3 +++ crazy_functions/vt_fns/vt_modify_config.py | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 88446f6f..0983d22c 100644 --- a/config.py +++ b/config.py @@ -172,6 +172,9 @@ GROBID_URLS = [ ] +# 是否允许通过自然语言描述修改本页的配置,该功能具有一定的危险性,默认关闭 +ALLOW_RESET_CONFIG = False + """ 在线大模型配置关联关系示意图 diff --git a/crazy_functions/vt_fns/vt_modify_config.py b/crazy_functions/vt_fns/vt_modify_config.py index cda74026..1f84ae6e 100644 --- a/crazy_functions/vt_fns/vt_modify_config.py +++ b/crazy_functions/vt_fns/vt_modify_config.py @@ -1,17 +1,24 @@ from pydantic import BaseModel, Field from typing import List -from toolbox import update_ui_lastest_msg +from toolbox import update_ui_lastest_msg, get_conf from request_llm.bridge_all import predict_no_ui_long_connection from crazy_functions.json_fns.pydantic_io import GptJsonIO import copy, json, pickle, os, sys def modify_configuration_hot(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_intention): - import config + ALLOW_RESET_CONFIG, = get_conf('ALLOW_RESET_CONFIG') + if not ALLOW_RESET_CONFIG: + yield from update_ui_lastest_msg( + lastmsg=f"当前配置不允许被修改!如需激活本功能,请在config.py中设置ALLOW_RESET_CONFIG=True后重启软件。", + chatbot=chatbot, history=history, delay=2 + ) + return # ⭐ ⭐ ⭐ 读取可配置项目条目 - from enum import Enum names = {} + from enum import Enum + import config for k, v in config.__dict__.items(): if k.startswith('__'): continue names.update({k:k}) @@ -59,6 +66,14 @@ def modify_configuration_hot(txt, llm_kwargs, plugin_kwargs, chatbot, history, s ) def modify_configuration_reboot(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_intention): + ALLOW_RESET_CONFIG, = get_conf('ALLOW_RESET_CONFIG') + if not ALLOW_RESET_CONFIG: + yield from update_ui_lastest_msg( + lastmsg=f"当前配置不允许被修改!如需激活本功能,请在config.py中设置ALLOW_RESET_CONFIG=True后重启软件。", + chatbot=chatbot, history=history, delay=2 + ) + return + yield from modify_configuration_hot(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_intention) yield from update_ui_lastest_msg( lastmsg=f"正在执行任务: {txt}\n\n配置修改完成,五秒后即将重启!若出现报错请无视即可。", chatbot=chatbot, history=history, delay=5