Skip to main content

A LangChain tool for parsing documents using Tensorlake's DocumentAI.

Project description

langchain-tensorlake

langchain-tensorlake provides seamless integration between Tensorlake and LangChain, enabling you to build sophisticated document processing agents with structured extraction workflows.

This repository contains 1 package with Tensorlake integrations with LangChain:


Installation

pip install -U langchain-tensorlake

Quick Start

1. Set up your environment

You should configure credentials for Tensorlake and OpenAI by setting the following environment variables:

export TENSORLAKE_API_KEY="your-tensorlake-api-key"
export OPENAI_API_KEY = "your-openai-api-key"

Get your Tensorlake API key from the Tensorlake Cloud Console. New users get 100 free credits!

2. Do the necessary imports

from langchain_tensorlake import DocumentParserOptions, document_markdown_tool
from langgraph.prebuilt import create_react_agent
import asyncio
import os

3. Build a Signature Detection Agent

async def main(question):
    # Create the agent with the Tensorlake tool
    agent = create_react_agent(
            model="openai:gpt-4o-mini",
            tools=[document_markdown_tool],
            prompt=(
                """
                I have a document that needs to be parsed. \n\nPlease parse this document and answer the question about it.
                """
            ),
            name="real-estate-agent",
        )
    
    # Run the agent
    result = await agent.ainvoke({"messages": [{"role": "user", "content": question}]})

    # Print the result
    print(result["messages"][-1].content)

4. Example Usage

# Define the path to the document to be parsed
path = "path/to/your/document.pdf"

# Define the question to be asked and create the agent
question = f"What contextual information can you extract about the signatures in my document found at {path}?"

if __name__ == "__main__":
    asyncio.run(main(question))

Customization

You can configure how documents are parsed using DocumentParserOptions, such as:

  • chunking_strategy: fragment, page, or section
  • detect_tables: enable or disable table extraction
  • detect_signatures: flag signature pages
  • extract_structured: define a schema for structured output

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_tensorlake-0.1.4.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

langchain_tensorlake-0.1.4-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_tensorlake-0.1.4.tar.gz.

File metadata

  • Download URL: langchain_tensorlake-0.1.4.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for langchain_tensorlake-0.1.4.tar.gz
Algorithm Hash digest
SHA256 56552701a4f79eeabba981d0c82f0b2370bcd9a031100da3845204e4d2230bf6
MD5 4f1f46ff9ecfef388e16f655d113f0be
BLAKE2b-256 6ba4da4fd8042052629d4620f1f346f798574fd3db1e7f573ca3b3108125b458

See more details on using hashes here.

File details

Details for the file langchain_tensorlake-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_tensorlake-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 989f18f26c498ab566cb1809ee476095a6b87c5c20c09c0ce0fae944f81d7a88
MD5 c7010fd2249596c992abf9f45b4f66e3
BLAKE2b-256 bfb66e534977caaef03b6b8c8e58cc9fff9d8b31bbd7bc412ed32d7a2ad71997

See more details on using hashes here.

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