compass.web.file_loader.COMPASSWebFileLoader#
- class COMPASSWebFileLoader(**kwargs)[source]#
Bases:
AsyncWebFileLoaderThe configured web file loader, recording each download
Every fetch, and each HTTP response behind it, is recorded in the event log through ELM’s loader hooks. With the Docling backend, so are the loaders it falls back on (a browser render for HTML, and ELM for sources Docling could not parse), so a document recovered by a fallback is not left looking like a failed download.
- Parameters:
header_template (
dict, optional) – Optional GET header template. If not specified, usesDEFAULT_HEADERS. By default,None.verify_ssl (
bool, optional) – Option to use aiohttp’s default SSL check. IfFalse, SSL certificate validation is skipped. By default,True.aget_kwargs (
dict, optional) – Other kwargs to pass toaiohttp.ClientSession.get(). By default,None.pw_launch_kwargs (
dict, optional) – Keyword-value argument pairs to pass toasync_playwright.chromium.launch()(only used when reading HTML). By default,None.pdf_read_kwargs (
dict, optional) – Keyword-value argument pairs to pass to the pdf_read_coroutine. By default,None.html_read_kwargs (
dict, optional) – Keyword-value argument pairs to pass to the html_read_coroutine. By default,None.pdf_read_coroutine (
callable(), optional) – PDF file read coroutine. Must by an async function. Should accept PDF bytes as the first argument and kwargs as the rest. Must return aelm.web.document.PDFDocument. IfNone, a default function that runs in the main thread is used. By default,None.html_read_coroutine (
callable(), optional) – HTML file read coroutine. Must by an async function. Should accept HTML text as the first argument and kwargs as the rest. Must return aelm.web.document.HTMLDocument. IfNone, a default function that runs in the main thread is used. By default,None.pdf_ocr_read_coroutine (
callable(), optional) – PDF OCR file read coroutine. Must by an async function. Should accept PDF bytes as the first argument and kwargs as the rest. Must return aelm.web.document.PDFDocument. IfNone, PDF OCR parsing is not attempted, and any scanned PDF URL’s will return a blank document. By default,None.file_cache_coroutine (
callable(), optional) – File caching coroutine. Can be used to cache files downloaded by this class. Must accept anDocumentinstance as the first argument and the file content to be written as the second argument. If this method is not provided, no document caching is performed. By default,None.browser_semaphore (
asyncio.Semaphore, optional) – Semaphore instance that can be used to limit the number of playwright browsers open concurrently. IfNone, no limits are applied. By default,None.use_scrapling_stealth (
bool, defaultFalse) – Option to use scrapling stealth scripts instead of playwright-stealth. By default,False.num_pw_html_retries (
int, default3) – Number of attempts to load HTML content. This is useful because the playwright parameters are stochastic, and sometimes a combination of them can fail to load HTML. The default value is likely a good balance between processing attempts and retrieval success. Note that the minimum number of attempts will always be 2, even if the user provides a value smaller than this. By default,3.keep_raw_html (
bool, defaultFalse) – Option to store the HTML each HTML document was read from under the"raw_html"key of itsattrs. SeeAsyncHTMLLoaderfor details. By default,False.on_response_hook (
callable(), optional) – Coroutine function called with every HTTP response received while fetching content. SeeAsyncFetchWithRetryfor details. By default,None.on_error_hook (
callable(), optional) – Coroutine function called when content could not be fetched because no response was received. SeeAsyncFetchWithRetryfor details. By default,None.on_fetch_hook (
callable(), optional) – Coroutine function called after every fetch with what the source produced. SeeBaseAsyncFileLoaderfor details. By default,None.
Methods
fetch(source)Fetch a document for the given source.
fetch_all(*sources)Fetch documents for all requested sources.