feat:优化对多模态/非多模态replyer的配置
This commit is contained in:
@@ -54,7 +54,7 @@ CONFIG_DIR: Path = PROJECT_ROOT / "config"
|
||||
BOT_CONFIG_PATH: Path = (CONFIG_DIR / "bot_config.toml").resolve().absolute()
|
||||
MODEL_CONFIG_PATH: Path = (CONFIG_DIR / "model_config.toml").resolve().absolute()
|
||||
MMC_VERSION: str = "1.0.0"
|
||||
CONFIG_VERSION: str = "8.5.5"
|
||||
CONFIG_VERSION: str = "8.6.0"
|
||||
MODEL_CONFIG_VERSION: str = "1.14.0"
|
||||
|
||||
logger = get_logger("config")
|
||||
|
||||
@@ -253,6 +253,8 @@ def _migrate_target_item_list(parent: dict[str, Any], key: str) -> bool:
|
||||
raw = _as_list(parent.get(key))
|
||||
if raw is None:
|
||||
return False
|
||||
if not raw:
|
||||
return False
|
||||
if raw and all(isinstance(i, dict) for i in raw):
|
||||
return False
|
||||
targets: list[dict[str, str]] = []
|
||||
@@ -285,18 +287,18 @@ def _migrate_extra_prompt_list(exp: dict[str, Any], key: str) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def _parse_multimodal_replyer(v: Any) -> Optional[bool]:
|
||||
def _parse_replyer_mode(v: Any) -> Optional[str]:
|
||||
"""兼容旧 replyer_generator_type 到布尔开关的迁移。"""
|
||||
if isinstance(v, bool):
|
||||
return v
|
||||
return "multimodal" if v else "text"
|
||||
if not isinstance(v, str):
|
||||
return None
|
||||
|
||||
normalized_value = v.strip().lower()
|
||||
if normalized_value == "multimodal":
|
||||
return True
|
||||
if normalized_value in {"text", "multimodal", "auto"}:
|
||||
return normalized_value
|
||||
if normalized_value == "legacy":
|
||||
return False
|
||||
return "text"
|
||||
return None
|
||||
|
||||
|
||||
@@ -403,14 +405,23 @@ def try_migrate_legacy_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
|
||||
migrated_any = True
|
||||
reasons.append("chat.multimodal_planner_moved_to_visual.multimodal_planner")
|
||||
|
||||
if visual is not None and "multimodal_replyer" in visual:
|
||||
replyer_mode = _parse_replyer_mode(visual.get("multimodal_replyer"))
|
||||
if "replyer_mode" not in visual and replyer_mode is not None:
|
||||
visual["replyer_mode"] = replyer_mode
|
||||
if "replyer_mode" in visual:
|
||||
visual.pop("multimodal_replyer", None)
|
||||
migrated_any = True
|
||||
reasons.append("visual.multimodal_replyer_moved_to_visual.replyer_mode")
|
||||
|
||||
if visual is not None and "replyer_generator_type" in chat:
|
||||
multimodal_replyer = _parse_multimodal_replyer(chat["replyer_generator_type"])
|
||||
if "multimodal_replyer" not in visual and multimodal_replyer is not None:
|
||||
visual["multimodal_replyer"] = multimodal_replyer
|
||||
if "multimodal_replyer" in visual:
|
||||
replyer_mode = _parse_replyer_mode(chat["replyer_generator_type"])
|
||||
if "replyer_mode" not in visual and replyer_mode is not None:
|
||||
visual["replyer_mode"] = replyer_mode
|
||||
if "replyer_mode" in visual:
|
||||
chat.pop("replyer_generator_type", None)
|
||||
migrated_any = True
|
||||
reasons.append("chat.replyer_generator_type_moved_to_visual.multimodal_replyer")
|
||||
reasons.append("chat.replyer_generator_type_moved_to_visual.replyer_mode")
|
||||
|
||||
maisaka = _as_dict(data.get("maisaka"))
|
||||
mem = _as_dict(data.get("memory"))
|
||||
|
||||
@@ -152,16 +152,16 @@ class VisualConfig(ConfigBase):
|
||||
"x-icon": "image",
|
||||
},
|
||||
)
|
||||
"""是否直接输入图片"""
|
||||
"""是否启用多模态planner"""
|
||||
|
||||
multimodal_replyer: bool = Field(
|
||||
default=False,
|
||||
replyer_mode: Literal["text", "multimodal", "auto"] = Field(
|
||||
default="auto",
|
||||
json_schema_extra={
|
||||
"x-widget": "switch",
|
||||
"x-widget": "select",
|
||||
"x-icon": "git-branch",
|
||||
},
|
||||
)
|
||||
"""是否启用 Maisaka 多模态 replyer 生成器"""
|
||||
"""回复器模式,auto根据模型信息自动选择,text为纯文本模式,multimodal为多模态模式"""
|
||||
|
||||
visual_style: str = Field(
|
||||
default="请用中文描述这张图片的内容。如果有文字,请把文字描述概括出来,请留意其主题,直观感受,输出为一段平文本,最多30字,请注意不要分点,就输出一段文本",
|
||||
|
||||
Reference in New Issue
Block a user