refactor: 统一类型注解风格并优化代码结构
- 将裸 except 改为显式 Exception 捕获 - 用列表推导式替换冗余 for 循环 - 为类属性添加 ClassVar 注解 - 统一 Union/Optional 写法为 | - 移除未使用的导入 - 修复 SQLAlchemy 空值比较语法 - 优化字符串拼接与字典更新逻辑 - 补充缺失的 noqa 注释与异常链 BREAKING CHANGE: 所有插件基类的类级字段现要求显式 ClassVar 注解,自定义插件需同步更新
This commit is contained in:
@@ -55,12 +55,12 @@ class SituationExtractor:
|
||||
) -> list[str]:
|
||||
"""
|
||||
从聊天历史中提取情境
|
||||
|
||||
|
||||
Args:
|
||||
chat_history: 聊天历史(列表或字符串)
|
||||
target_message: 目标消息(可选)
|
||||
max_situations: 最多提取的情境数量
|
||||
|
||||
|
||||
Returns:
|
||||
情境描述列表
|
||||
"""
|
||||
@@ -115,11 +115,11 @@ class SituationExtractor:
|
||||
def _parse_situations(response: str, max_situations: int) -> list[str]:
|
||||
"""
|
||||
解析 LLM 返回的情境描述
|
||||
|
||||
|
||||
Args:
|
||||
response: LLM 响应
|
||||
max_situations: 最多返回的情境数量
|
||||
|
||||
|
||||
Returns:
|
||||
情境描述列表
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user