txtai-xberg
Feed Xberg document extraction into txtai. XbergPipeline is a plain callable that extracts text and metadata from 107 formats — running OCR where needed — and flattens the result into documents ready for txtai.Embeddings.index. When you enable Xberg's native chunking, each chunk becomes one embedding-sized segment instead of a single blob.
Install
pip install txtai-xberg
Requires Python 3.10+. Install the txtai extra (pip install "txtai-xberg[txtai]") if txtai isn't already in your environment.
Extract
Call the pipeline with a path or a list of paths. A string returns one document; a list returns documents in input order. Batches run through Xberg's extract_batch in a single native call.
from txtai_xberg import XbergPipeline
pipeline = XbergPipeline()
doc = pipeline("report.pdf")
print(doc["content"]) # extracted markdown
print(doc["metadata"]["title"]) # source, mime_type, title, authors, languages, page_count
docs = pipeline(["report.pdf", "notes.docx"])
Index into txtai
Use to_documents to get (id, text, tags) tuples and hand them straight to Embeddings.index. Enable Xberg chunking so segments arrive sized for the model, with heading and page context in each document's tags.
from txtai import Embeddings
from txtai_xberg import XbergPipeline
from xberg import ChunkingConfig, ExtractionConfig
pipeline = XbergPipeline(
config=ExtractionConfig(chunking=ChunkingConfig(max_characters=1000, overlap=200)),
)
documents = pipeline.to_documents(["report.pdf", "notes.docx"])
embeddings = Embeddings(path="sentence-transformers/all-MiniLM-L6-v2", content=True)
embeddings.index(documents)
for result in embeddings.search("quarterly revenue", 3):
print(result["id"], result["text"])
Without a chunking config, to_documents emits one document per file. Chunk ids are "<source>#<chunk_index>".
Configure extraction
Pass any Xberg ExtractionConfig to control OCR, output format, chunking, and concurrency.
from xberg import ExtractionConfig, OcrConfig
pipeline = XbergPipeline(
config=ExtractionConfig(
output_format="markdown",
ocr=OcrConfig(language="eng"),
force_ocr=True,
max_concurrent_extractions=8,
),
)
Async
Already inside an event loop? Use the async methods — await pipeline.acall(paths) and await pipeline.ato_documents(paths). The synchronous __call__ and to_documents wrap these with asyncio.run and must not run inside a running loop.
Errors
Per-input failures in a batch surface as an ExtractionFailedError, whose errors attribute holds Xberg's ExtractionErrorItem objects (each with an index, source, code, and message).
For the full API, see the Xberg documentation.
Metadata
Release files for txtai-xberg 1.3.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| txtai_xberg-1.3.8.tar.gz | 9.8 kB | Without provenance | Details for txtai_xberg-1.3.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| txtai_xberg-1.3.8-py3-none-any.whl | Python 3 | none | any | Details for txtai_xberg-1.3.8-py3-none-any.whl |
Total release size: 16.8 kB
Release files / txtai_xberg-1.3.8.tar.gz
| Download URL | txtai_xberg-1.3.8.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6f9806dfa559a7adc068d0fe2f4b83078113884e91d14245c095391c3965ab0
|
|
BLAKE2b-256 checksum How to use checksums |
0f971afe63af47b892b4920b8e13f9e606f5974a003dd5f97902f3e5a939d583
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / txtai_xberg-1.3.8-py3-none-any.whl
| Download URL | txtai_xberg-1.3.8-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d62953e1f1c3ba68123670642077a6210b2b97334b4c081d3d0e835b7cb2b945
|
|
BLAKE2b-256 checksum How to use checksums |
56a64da2b0276c8aa9b745be5969d4ed658d95124464f5dd39b0996717731b9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for txtai-xberg 1.3.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.