File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 16
16
ENHANCER_REGISTRY : dict [str , type [InformationEnhancer ]] = {}
17
17
18
18
19
- def register_enhancer (modalities : list [str ]) -> Callable [[type [InformationEnhancer ]], type [InformationEnhancer ]]:
19
+ def register_enhancer (modalities : list [ChunkType ]) -> Callable [[type [InformationEnhancer ]], type [InformationEnhancer ]]:
20
20
"""
21
21
信息增强器注册装饰器
22
22
@@ -38,17 +38,17 @@ def decorator(cls: type[InformationEnhancer]) -> type[InformationEnhancer]:
38
38
39
39
# 注册到全局注册表
40
40
for modality in modalities :
41
- modality = modality .lower () # 统一转换为小写
41
+ modality = modality .value . lower () # 统一转换为小写
42
42
if modality in ENHANCER_REGISTRY :
43
- logger .warning (f"覆盖已存在的信息增强器: { modality } -> { cls .__name__ } " )
43
+ logger .error (f"覆盖已存在的信息增强器: { modality } -> { cls .__name__ } " )
44
+ raise ValueError (f"尝试覆盖已存在的信息增强器: { modality } -> { cls .__name__ } " )
44
45
ENHANCER_REGISTRY [modality ] = cls
45
46
logger .info (f"注册信息增强器: { modality } -> { cls .__name__ } " )
46
47
47
48
return cls
48
49
49
50
return decorator
50
51
51
-
52
52
def get_enhancer (modality : ChunkType ) -> InformationEnhancer | None :
53
53
"""
54
54
根据模态类型获取合适的信息增强器实例
You can’t perform that action at this time.
0 commit comments