feat: interface for WebLoader

This commit is contained in:
Daulet Amirkhanov 2025-10-16 11:52:16 +01:00
parent 62157a114d
commit 9395539868

View file

@ -0,0 +1,61 @@
from cognee.infrastructure.loaders import LoaderInterface
from typing import List
class WebLoader(LoaderInterface):
@property
def supported_extensions(self) -> List[str]:
"""
List of file extensions this loader supports.
Returns:
List of extensions including the dot (e.g., ['.txt', '.md'])
"""
raise NotImplementedError
@property
def supported_mime_types(self) -> List[str]:
"""
List of MIME types this loader supports.
Returns:
List of MIME type strings (e.g., ['text/plain', 'application/pdf'])
"""
raise NotImplementedError
@property
def loader_name(self) -> str:
"""
Unique name identifier for this loader.
Returns:
String identifier used for registration and configuration
"""
raise NotImplementedError
def can_handle(self, extension: str, mime_type: str) -> bool:
"""
Check if this loader can handle the given file.
Args:
extension: File extension
mime_type: MIME type of the file
Returns:
True if this loader can process the file, False otherwise
"""
raise NotImplementedError
async def load(self, file_path: str, **kwargs):
"""
Load and process the file, returning standardized result.
Args:
file_path: Path to the file to be processed
file_stream: If file stream is provided it will be used to process file instead
**kwargs: Additional loader-specific configuration
Raises:
Exception: If file cannot be processed
"""
raise NotImplementedError