Skip to main content

LangChain document loader for the DocDigitizer document processing API

Project description

langchain-docdigitizer

LangChain document loader for the DocDigitizer document processing API.

v0.1.x is deprecated. Upgrade to v0.2.0+ for the new API endpoint. The previous endpoint (https://apix.docdigitizer.com/sync) will be removed in a future release.

Installation

pip install langchain-docdigitizer

Usage

from langchain_docdigitizer import DocDigitizerLoader

# Load a single PDF
loader = DocDigitizerLoader(api_key="dd_live_...")
docs = loader.load("invoice.pdf")

print(docs[0].page_content)       # JSON with extracted fields
print(docs[0].metadata)           # document_type, confidence, country_code, etc.

# Load all PDFs from a directory
loader = DocDigitizerLoader(api_key="dd_live_...", file_path="invoices/")
docs = loader.load()

# Use in a RAG pipeline
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import FAISS

splitter = RecursiveCharacterTextSplitter(chunk_size=1000)
chunks = splitter.split_documents(docs)
vectorstore = FAISS.from_documents(chunks, OpenAIEmbeddings())

Configuration

Parameter Environment Variable Default
api_key DOCDIGITIZER_API_KEY
base_url DOCDIGITIZER_BASE_URL https://api.docdigitizer.com/v3/docingester
timeout DOCDIGITIZER_TIMEOUT 300
max_retries 3
pipeline None
content_format "json"

Content Formats

  • "json" (default): page_content is a JSON string of extracted fields
  • "text": page_content is key-value pairs separated by newlines (key: value)
  • "kv": page_content is key=value pairs separated by newlines

Document Metadata

Each LangChain Document includes metadata:

Field Type Description
source str File path of the processed PDF
document_type str Detected document type (e.g., "Invoice")
confidence float Classification confidence (0-1)
country_code str Detected country code (e.g., "PT")
pages list[int] Page numbers where document was found
page_range dict Start/end page range
trace_id str Unique trace identifier

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_docdigitizer-0.2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_docdigitizer-0.2.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file langchain_docdigitizer-0.2.0.tar.gz.

File metadata

  • Download URL: langchain_docdigitizer-0.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_docdigitizer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e85c10019d5a95ca1483ccb058522189ddcb04bce0ace17d21ea92afdf4ea4e7
MD5 7091ef741077c6de685579209592ceaf
BLAKE2b-256 6d82c66fbcda9acc2c4353d0c68a888c444390c4852e5d27e4291a440766853c

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_docdigitizer-0.2.0.tar.gz:

Publisher: publish-langchain-python.yml on DocDigitizer/dd-v3-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_docdigitizer-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_docdigitizer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8354466a3156f33a952c898a3b5772f1eeaa44fe462befe8efb526e6fb13512d
MD5 3ce8b3a92d5610f80fe1d960f49dda49
BLAKE2b-256 551b5ac8fcf8371c788638ecabc6e4f1a8fea1b5cfe98e3bf56d811b4885f986

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_docdigitizer-0.2.0-py3-none-any.whl:

Publisher: publish-langchain-python.yml on DocDigitizer/dd-v3-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page