优化代码格式和异常处理

- 修复异常处理链,使用from语法保留原始异常
- 格式化代码以符合项目规范
- 优化导入模块的顺序

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
春河晴
2025-03-19 20:27:34 +09:00
parent a829dfdb77
commit fdc098d0db
52 changed files with 3156 additions and 2778 deletions

View File

@@ -16,22 +16,23 @@ willing_config = LogConfig(
),
)
logger = get_module_logger("willing",config=willing_config)
logger = get_module_logger("willing", config=willing_config)
def init_willing_manager() -> Optional[object]:
"""
根据配置初始化并返回对应的WillingManager实例
Returns:
对应mode的WillingManager实例
"""
mode = global_config.willing_mode.lower()
if mode == "classical":
logger.info("使用经典回复意愿管理器")
return ClassicalWillingManager()
elif mode == "dynamic":
logger.info("使用动态回复意愿管理器")
logger.info("使用动态回复意愿管理器")
return DynamicWillingManager()
elif mode == "custom":
logger.warning(f"自定义的回复意愿管理器模式: {mode}")
@@ -40,5 +41,6 @@ def init_willing_manager() -> Optional[object]:
logger.warning(f"未知的回复意愿管理器模式: {mode}, 将使用经典模式")
return ClassicalWillingManager()
# 全局willing_manager对象
willing_manager = init_willing_manager()