refactor(config): 移除全局表达开关以支持分聊天配置

移除全局的 `enable_expression` 配置项,转而使用 `get_expression_config_for_chat` 方法在生成提示词时动态判断。

原有的全局开关不够灵活,无法满足分聊天、分群组控制表达功能的需求。此次重构通过在运行时检查每个聊天的具体配置,实现了更精细化的功能启用控制。

BREAKING CHANGE: 全局配置项 `expression.enable_expression` 已被移除。现在需要通过表达规则来为不同的聊天单独控制功能的启用状态。
This commit is contained in:
tt-P607
2025-09-26 23:11:55 +08:00
parent 568de3b473
commit 28a2a4b0c8
2 changed files with 2 additions and 2 deletions

View File

@@ -483,7 +483,8 @@ class Prompt:
async def _build_expression_habits(self) -> Dict[str, Any]:
"""构建表达习惯"""
if not global_config.expression.enable_expression:
use_expression, _, _ = global_config.expression.get_expression_config_for_chat(self.parameters.chat_id)
if not use_expression:
return {"expression_habits_block": ""}
try:

View File

@@ -308,7 +308,6 @@ class ExpressionRule(ValidatedConfigBase):
class ExpressionConfig(ValidatedConfigBase):
"""表达配置类"""
enable_expression: bool = Field(default=True, description="是否启用表达")
rules: List[ExpressionRule] = Field(default_factory=list, description="表达学习规则")
def _parse_stream_config_to_chat_id(self, stream_config_str: str) -> Optional[str]: