Skip to content

Commit f4eb8c1

Browse files
committed
fix: ban cover enhancer
1 parent 628edb3 commit f4eb8c1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

enhancers/enhancer_registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ENHANCER_REGISTRY: dict[str, type[InformationEnhancer]] = {}
1717

1818

19-
def register_enhancer(modalities: list[str]) -> Callable[[type[InformationEnhancer]], type[InformationEnhancer]]:
19+
def register_enhancer(modalities: list[ChunkType]) -> Callable[[type[InformationEnhancer]], type[InformationEnhancer]]:
2020
"""
2121
信息增强器注册装饰器
2222
@@ -38,17 +38,17 @@ def decorator(cls: type[InformationEnhancer]) -> type[InformationEnhancer]:
3838

3939
# 注册到全局注册表
4040
for modality in modalities:
41-
modality = modality.lower() # 统一转换为小写
41+
modality = modality.value.lower() # 统一转换为小写
4242
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__}")
4445
ENHANCER_REGISTRY[modality] = cls
4546
logger.info(f"注册信息增强器: {modality} -> {cls.__name__}")
4647

4748
return cls
4849

4950
return decorator
5051

51-
5252
def get_enhancer(modality: ChunkType) -> InformationEnhancer | None:
5353
"""
5454
根据模态类型获取合适的信息增强器实例

0 commit comments

Comments
 (0)