feat:支持高级配置

This commit is contained in:
SengokuCola
2026-05-03 20:28:30 +08:00
parent db46551b51
commit 041ff63fba
5 changed files with 42 additions and 2 deletions

View File

@@ -179,6 +179,8 @@ class ModelConfig(ConfigBase):
class ConfigManager:
"""总配置管理类"""
VLM_NOT_CONFIGURED_WARNING: str = "未配置视觉识图模型部分图片理解可能受限请在webui或model_config中配置"
def __init__(self):
self.bot_config_path: Path = BOT_CONFIG_PATH
self.model_config_path: Path = MODEL_CONFIG_PATH
@@ -205,8 +207,15 @@ class ConfigManager:
)
if global_updated or model_updated:
sys.exit(0) # 配置已自动升级,退出一次让用户确认新配置后再启动
self._warn_if_vlm_not_configured(self.model_config)
logger.info(t("config.loaded"))
@classmethod
def _warn_if_vlm_not_configured(cls, model_config: ModelConfig) -> None:
if any(model_name.strip() for model_name in model_config.model_task_config.vlm.model_list):
return
logger.warning(cls.VLM_NOT_CONFIGURED_WARNING)
def load_global_config(self) -> Config:
config, updated = load_config_from_file(Config, self.bot_config_path, CONFIG_VERSION)
if updated:

View File

@@ -101,6 +101,7 @@ class PersonalityConfig(ConfigBase):
"带点翻译腔,但不要太长",
],
json_schema_extra={
"advanced": True,
"x-widget": "custom",
"x-icon": "list",
},
@@ -112,6 +113,7 @@ class PersonalityConfig(ConfigBase):
ge=0,
le=1,
json_schema_extra={
"advanced": True,
"x-widget": "slider",
"x-icon": "percent",
"step": 0.1,
@@ -876,6 +878,7 @@ class EmojiConfig(ConfigBase):
content_filtration: bool = Field(
default=False,
json_schema_extra={
"advanced": True,
"x-widget": "switch",
"x-icon": "filter",
},
@@ -885,6 +888,7 @@ class EmojiConfig(ConfigBase):
filtration_prompt: str = Field(
default="符合公序良俗",
json_schema_extra={
"advanced": True,
"x-widget": "input",
"x-icon": "shield",
},