refactor: 将 MarkdownSplitter 移入 splitters 包,ingest.py 保留兼容 import
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""分块器注册表 — 按文件后缀名路由到对应 Splitter."""
|
||||
|
||||
SUPPORTED_SUFFIXES: dict[str, str] = {
|
||||
".md": "markdown",
|
||||
".txt": "text",
|
||||
".html": "html",
|
||||
".pdf": "pdf",
|
||||
}
|
||||
|
||||
_registry: dict[str, type] = {}
|
||||
|
||||
|
||||
def register_splitter(name: str, splitter_cls: type) -> None:
|
||||
"""注册一个分块器."""
|
||||
_registry[name] = splitter_cls
|
||||
|
||||
|
||||
def get_splitter(name: str):
|
||||
"""获取已注册的分块器类."""
|
||||
if name not in _registry:
|
||||
raise ValueError(f"未注册的分块器: {name}")
|
||||
return _registry[name]
|
||||
Reference in New Issue
Block a user