haive.core.engine.document.factory¶
Auto Loader Factory for Document Engine.
This module provides a comprehensive factory interface that can analyze any path or URL and automatically select the appropriate document source and loader.
Classes¶
Factory for automatically creating document loaders. |
Functions¶
|
Analyze a source path and return detailed information. |
|
Convenience function to create a document loader. |
Module Contents¶
- class haive.core.engine.document.factory.AutoLoaderFactory(credential_manager=None)¶
Factory for automatically creating document loaders.
Initialize the factory.
- Parameters:
credential_manager (haive.core.engine.document.loaders.sources.implementation.CredentialManager | None) – Optional credential manager for authenticated sources
- analyze_path(path)¶
Analyze a path to understand its properties.
- Parameters:
path (str)
- Return type:
haive.core.engine.document.path_analysis.PathAnalysisResult | None
- create_loader(path, strategy=None, options=None, preferences=None)¶
Create the appropriate document loader for any path or URL.
This factory function analyzes the given path to determine its nature (file, URL, database URI, etc.) and returns the appropriate loader instance.
- Parameters:
- Returns:
DocumentLoader instance appropriate for the given path
- Return type:
langchain_core.document_loaders.base.BaseLoader | None
Examples
>>> factory = AutoLoaderFactory() >>> >>> # Load a PDF file with OCR >>> loader = factory.create_loader("path/to/document.pdf", strategy="pdf_pymupdf") >>> >>> # Load a webpage with JavaScript support >>> loader = factory.create_loader("https://example.com", strategy="playwright") >>> >>> # Auto-select best loader for any source >>> loader = factory.create_loader("path/to/document.docx")
- get_supported_sources()¶
Get list of supported source types.
- haive.core.engine.document.factory.analyze_source(path)¶
Analyze a source path and return detailed information.
- haive.core.engine.document.factory.create_document_loader(path, strategy=None, credential_manager=None, options=None, preferences=None)¶
Convenience function to create a document loader.
- Parameters:
path (str) – File path, URL, or URI to load
strategy (str | None) – Optional specific strategy to use
credential_manager (haive.core.engine.document.loaders.sources.implementation.CredentialManager | None) – Optional credential manager
options (dict[str, Any] | None) – Optional loader-specific options
preferences (dict[str, Any] | None) – Optional preferences for loader selection
- Returns:
DocumentLoader instance or None if creation failed
- Return type:
langchain_core.document_loaders.base.BaseLoader | None