fix:修复错误的配置文件以及迁移回退
This commit is contained in:
@@ -206,40 +206,6 @@ def _migrate_target_item_list(parent: dict[str, Any], key: str) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _parse_planner_mode(value: Any) -> Optional[str]:
|
|
||||||
"""
|
|
||||||
兼容旧 planner 配置到当前 visual.planner_mode。
|
|
||||||
"""
|
|
||||||
if isinstance(value, bool):
|
|
||||||
return "multimodal" if value else "text"
|
|
||||||
|
|
||||||
if not isinstance(value, str):
|
|
||||||
return None
|
|
||||||
|
|
||||||
normalized_value = value.strip().lower()
|
|
||||||
if normalized_value in {"text", "multimodal", "auto"}:
|
|
||||||
return normalized_value
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_replyer_mode(value: Any) -> Optional[str]:
|
|
||||||
"""
|
|
||||||
兼容旧 replyer 配置到当前 visual.replyer_mode。
|
|
||||||
"""
|
|
||||||
if isinstance(value, bool):
|
|
||||||
return "multimodal" if value else "text"
|
|
||||||
|
|
||||||
if not isinstance(value, str):
|
|
||||||
return None
|
|
||||||
|
|
||||||
normalized_value = value.strip().lower()
|
|
||||||
if normalized_value in {"text", "multimodal", "auto"}:
|
|
||||||
return normalized_value
|
|
||||||
if normalized_value == "legacy":
|
|
||||||
return "text"
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def migrate_legacy_bind_env_to_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
|
def migrate_legacy_bind_env_to_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
|
||||||
"""将旧版 `.env` 中的绑定地址迁移到主配置结构。"""
|
"""将旧版 `.env` 中的绑定地址迁移到主配置结构。"""
|
||||||
|
|
||||||
@@ -314,13 +280,9 @@ def try_migrate_legacy_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
|
|||||||
migrated_any = True
|
migrated_any = True
|
||||||
reasons.append("expression.manual_reflect_operator_id_empty")
|
reasons.append("expression.manual_reflect_operator_id_empty")
|
||||||
|
|
||||||
chat = _as_dict(data.get("chat"))
|
|
||||||
personality = _as_dict(data.get("personality"))
|
personality = _as_dict(data.get("personality"))
|
||||||
visual = _as_dict(data.get("visual"))
|
visual = _as_dict(data.get("visual"))
|
||||||
if visual is None and (
|
if visual is None and personality is not None and "visual_style" in personality:
|
||||||
(personality is not None and "visual_style" in personality)
|
|
||||||
or (chat is not None and ("multimodal_planner" in chat or "replyer_generator_type" in chat))
|
|
||||||
):
|
|
||||||
visual = {}
|
visual = {}
|
||||||
data["visual"] = visual
|
data["visual"] = visual
|
||||||
|
|
||||||
@@ -331,42 +293,6 @@ def try_migrate_legacy_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
|
|||||||
migrated_any = True
|
migrated_any = True
|
||||||
reasons.append("personality.visual_style_moved_to_visual.visual_style")
|
reasons.append("personality.visual_style_moved_to_visual.visual_style")
|
||||||
|
|
||||||
if visual is not None and "multimodal_planner" in visual:
|
|
||||||
planner_mode = _parse_planner_mode(visual.get("multimodal_planner"))
|
|
||||||
if "planner_mode" not in visual and planner_mode is not None:
|
|
||||||
visual["planner_mode"] = planner_mode
|
|
||||||
if "planner_mode" in visual:
|
|
||||||
visual.pop("multimodal_planner", None)
|
|
||||||
migrated_any = True
|
|
||||||
reasons.append("visual.multimodal_planner_moved_to_visual.planner_mode")
|
|
||||||
|
|
||||||
if visual is not None and chat is not None and "multimodal_planner" in chat:
|
|
||||||
planner_mode = _parse_planner_mode(chat.get("multimodal_planner"))
|
|
||||||
if "planner_mode" not in visual and planner_mode is not None:
|
|
||||||
visual["planner_mode"] = planner_mode
|
|
||||||
if "planner_mode" in visual:
|
|
||||||
chat.pop("multimodal_planner", None)
|
|
||||||
migrated_any = True
|
|
||||||
reasons.append("chat.multimodal_planner_moved_to_visual.planner_mode")
|
|
||||||
|
|
||||||
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 chat is not None and "replyer_generator_type" in chat:
|
|
||||||
replyer_mode = _parse_replyer_mode(chat.get("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.replyer_mode")
|
|
||||||
|
|
||||||
memory = _as_dict(data.get("memory"))
|
memory = _as_dict(data.get("memory"))
|
||||||
if memory is not None and _migrate_target_item_list(memory, "global_memory_blacklist"):
|
if memory is not None and _migrate_target_item_list(memory, "global_memory_blacklist"):
|
||||||
migrated_any = True
|
migrated_any = True
|
||||||
|
|||||||
@@ -149,10 +149,10 @@ class VisualConfig(ConfigBase):
|
|||||||
default="auto",
|
default="auto",
|
||||||
json_schema_extra={
|
json_schema_extra={
|
||||||
"x-widget": "select",
|
"x-widget": "select",
|
||||||
"x-icon": "image",
|
"x-icon": "git-branch",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
"""Planner 视觉模式:text 仅文本,multimodal 强制多模态,auto 按模型能力自动选择"""
|
"""规划器模式,auto根据模型信息自动选择,text为纯文本模式,multimodal为多模态模式"""
|
||||||
|
|
||||||
replyer_mode: Literal["text", "multimodal", "auto"] = Field(
|
replyer_mode: Literal["text", "multimodal", "auto"] = Field(
|
||||||
default="auto",
|
default="auto",
|
||||||
@@ -161,7 +161,7 @@ class VisualConfig(ConfigBase):
|
|||||||
"x-icon": "git-branch",
|
"x-icon": "git-branch",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
"""Replyer 视觉模式:text 仅文本,multimodal 强制多模态,auto 按模型能力自动选择"""
|
"""回复器模式,auto根据模型信息自动选择,text为纯文本模式,multimodal为多模态模式"""
|
||||||
|
|
||||||
visual_style: str = Field(
|
visual_style: str = Field(
|
||||||
default="请用中文描述这张图片的内容。如果有文字,请把文字描述概括出来,请留意其主题,直观感受,输出为一段平文本,最多30字,请注意不要分点,就输出一段文本",
|
default="请用中文描述这张图片的内容。如果有文字,请把文字描述概括出来,请留意其主题,直观感受,输出为一段平文本,最多30字,请注意不要分点,就输出一段文本",
|
||||||
@@ -239,17 +239,12 @@ class ChatConfig(ConfigBase):
|
|||||||
)
|
)
|
||||||
"""Planner 连续被新消息打断的最大次数,0 表示不启用打断"""
|
"""Planner 连续被新消息打断的最大次数,0 表示不启用打断"""
|
||||||
|
|
||||||
plan_reply_log_max_per_chat: int = Field(
|
|
||||||
default=1024,
|
|
||||||
json_schema_extra={
|
|
||||||
"x-widget": "input",
|
|
||||||
"x-icon": "file-text",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
"""每个聊天流最大保存的Plan/Reply日志数量,超过此数量时会自动删除最老的日志"""
|
|
||||||
|
|
||||||
group_chat_prompt: str = Field(
|
group_chat_prompt: str = Field(
|
||||||
default="你需要控制自己发言的频率,如果是一对一聊天,可以以较均匀的频率发言;如果用户较多,不要每句都回复,控制回复频率,不要回复的太频繁!控制回复的频率,不要每个人的消息都回复。",
|
default="""
|
||||||
|
你正在qq群里聊天,下面是群里正在聊的内容,其中包含聊天记录和聊天中的图片。
|
||||||
|
回复尽量简短一些。最好一次对一个话题进行回复,免得啰嗦或者回复内容太乱。请注意把握聊天内容。
|
||||||
|
不要回复的太频繁!控制回复的频率,不要每个人的消息都回复,只回复你感兴趣的或者主动提及你的。
|
||||||
|
""",
|
||||||
json_schema_extra={
|
json_schema_extra={
|
||||||
"x-widget": "textarea",
|
"x-widget": "textarea",
|
||||||
"x-icon": "users",
|
"x-icon": "users",
|
||||||
@@ -258,7 +253,11 @@ class ChatConfig(ConfigBase):
|
|||||||
"""_wrap_群聊通用注意事项"""
|
"""_wrap_群聊通用注意事项"""
|
||||||
|
|
||||||
private_chat_prompts: str = Field(
|
private_chat_prompts: str = Field(
|
||||||
default="你需要控制自己发言的频率,可以以较均匀的频率发言。",
|
default="""
|
||||||
|
你正在聊天,下面是正在聊的内容,其中包含聊天记录和聊天中的图片。
|
||||||
|
回复尽量简短一些。请注意把握聊天内容。
|
||||||
|
请考虑对方的发言频率,想法,思考自己何时回复以及回复内容。
|
||||||
|
""",
|
||||||
json_schema_extra={
|
json_schema_extra={
|
||||||
"x-widget": "textarea",
|
"x-widget": "textarea",
|
||||||
"x-icon": "user",
|
"x-icon": "user",
|
||||||
@@ -694,6 +693,15 @@ class LearningItem(ConfigBase):
|
|||||||
)
|
)
|
||||||
"""是否启用jargon学习"""
|
"""是否启用jargon学习"""
|
||||||
|
|
||||||
|
advanced_chosen: bool = Field(
|
||||||
|
default=False,
|
||||||
|
json_schema_extra={
|
||||||
|
"x-widget": "switch",
|
||||||
|
"x-icon": "sparkles",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
"""是否启用基于子代理的二次表达方式选择"""
|
||||||
|
|
||||||
|
|
||||||
class ExpressionGroup(ConfigBase):
|
class ExpressionGroup(ConfigBase):
|
||||||
"""表达互通组配置类,若列表为空代表全局共享"""
|
"""表达互通组配置类,若列表为空代表全局共享"""
|
||||||
@@ -723,6 +731,7 @@ class ExpressionConfig(ConfigBase):
|
|||||||
use_expression=True,
|
use_expression=True,
|
||||||
enable_learning=True,
|
enable_learning=True,
|
||||||
enable_jargon_learning=True,
|
enable_jargon_learning=True,
|
||||||
|
advanced_chosen=False,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
json_schema_extra={
|
json_schema_extra={
|
||||||
@@ -1594,35 +1603,6 @@ class MaiSakaConfig(ConfigBase):
|
|||||||
)
|
)
|
||||||
"""MaiSaka 使用的用户名称"""
|
"""MaiSaka 使用的用户名称"""
|
||||||
|
|
||||||
tool_filter_task_name: str = Field(
|
|
||||||
default="utils",
|
|
||||||
json_schema_extra={
|
|
||||||
"x-widget": "input",
|
|
||||||
"x-icon": "sparkles",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
"""工具筛选预判使用的模型任务名"""
|
|
||||||
|
|
||||||
tool_filter_threshold: int = Field(
|
|
||||||
default=20,
|
|
||||||
ge=1,
|
|
||||||
json_schema_extra={
|
|
||||||
"x-widget": "input",
|
|
||||||
"x-icon": "filter",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
"""当可用工具总数超过该阈值时,先进行一轮工具筛选"""
|
|
||||||
|
|
||||||
tool_filter_max_keep: int = Field(
|
|
||||||
default=5,
|
|
||||||
ge=1,
|
|
||||||
json_schema_extra={
|
|
||||||
"x-widget": "input",
|
|
||||||
"x-icon": "list-filter",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
"""工具筛选阶段最多保留的非内置工具数量"""
|
|
||||||
|
|
||||||
show_image_path: bool = Field(
|
show_image_path: bool = Field(
|
||||||
default=True,
|
default=True,
|
||||||
json_schema_extra={
|
json_schema_extra={
|
||||||
|
|||||||
Reference in New Issue
Block a user