langchain-xberg 1.1.0
“LangChain document loader for Xberg — extract 88+ file formats into Documents with async, batching, chunking, and rich metadata”
Legacy LangChain package pathimports Path from pathlib
SHA-25655cd9f37aabc1facdd2f49cae5872322617e9e16c193d6bcbc6ac20e86f28e35
MaleculeH₂(FPo₂)
Evidence
1"""Xberg document loader for LangChain."""
2
3from __future__ import annotations
4
5import asyncio
6from concurrent.futures import ThreadPoolExecutor
7from pathlib import Path
8from typing import TYPE_CHECKING, Any
9
10from langchain_core.document_loaders import BaseLoader
11from langchain_core.documents import Document
12from xberg import ExtractInput, XbergError, extract, extract_batch
13
14if TYPE_CHECKING:
15 from collections.abc import AsyncIterator, Callable, Coroutine, Iterator
16
17 from xberg import ExtractedDocument, ExtractionConfig, ExtractionResult
18
19# Metadata fields (from xberg.Metadata) that carry JSON-friendly scalar/list values.
20# Complex nested fields (pages, format, image_preproces …
62:29… rgLoader(file_path=["a.pdf", "b.docx", "c.txt"])
63 >>> docs = loader.load()
64
65 Load from bytes:
66 >>> loader = XbergLoader(data=raw_bytes, mime_type="application/pdf")
67 >>> docs = loader.load()
68
69 Load a directory:
70 >>> loader = XbergLoader(file_path="./docs/", glo …
⋯5 lines
157 if isinstance(config, dict):
158 return config.get(name)
159 return getattr(config, name, None)
160
161 @property
162 def _per_page(self) -> bool:
163 """Whether per-page splitting is enabled in the con …
183:29… lf._glob or "**/*"
184 yield from sorted(p for p in file_path.glob(pattern) if p.is_file())
185 else:
186 yield file_path
187
188 def _is_batch(self) -> bool:
189 """Whether …
392:24… _running_loop()
393 except RuntimeError:
394 return asyncio.run(factory())
395
396 with ThreadPoolExecutor(max_workers=1) as pool:
397 return pool.submit(lambda: asyncio.run(factory())).result()
398
399 def lazy_load(self) -> Iterator[Document]:
400 """Load documents lazily, yiel …
No evidence locations were recorded for this file. Raw result