From 9395539868155cbb1402f1cd77a8f5f7c5f478cd Mon Sep 17 00:00:00 2001 From: Daulet Amirkhanov Date: Thu, 16 Oct 2025 11:52:16 +0100 Subject: [PATCH] feat: interface for WebLoader --- .../loaders/external/WebLoader.py | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 cognee/infrastructure/loaders/external/WebLoader.py diff --git a/cognee/infrastructure/loaders/external/WebLoader.py b/cognee/infrastructure/loaders/external/WebLoader.py new file mode 100644 index 000000000..609ade2e0 --- /dev/null +++ b/cognee/infrastructure/loaders/external/WebLoader.py @@ -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