mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-10-08 03:10:24 +00:00
22 lines
726 B
Python
22 lines
726 B
Python
"""Abstract base for file chunkers."""
|
|
|
|
from abc import abstractmethod
|
|
from pathlib import Path
|
|
|
|
from ..base_component import BaseComponent
|
|
from ...enumeration import ComponentEnum
|
|
from ...schema import FileChunk, FileNode
|
|
|
|
|
|
class BaseFileChunker(BaseComponent):
|
|
"""Abstract base for file chunkers. Subclasses implement `chunk`."""
|
|
|
|
component_type = ComponentEnum.FILE_CHUNKER
|
|
|
|
def __init__(self, supported_extensions: list[str] | None = None, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self.supported_extensions: list[str] = supported_extensions or []
|
|
|
|
@abstractmethod
|
|
async def chunk(self, path: str | Path) -> tuple[FileNode, list[FileChunk]]:
|
|
"""Chunk a file into (node, chunks)."""
|