Tensorlake can be used with Langchain in two ways:

  1. Using the Python SDK tensorlake to upload files and parse them.
  2. Using the langchain-tensorlake package as a tool in LangGraph agents.

Using the Langchain Tool

The lanchain-tensorlake package provides a tool that can be used in LangGraph agents. This enables your agents to automatically use Tensorlake for Document Parsing, without having to write any code to parse the documents.

1. Install the Langchain Tool

pip install langchain-tensorlake langgraph

2. Setup the Environment

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

3. Use the Tool

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

agent = create_react_agent(
    model="openai:gpt-4o-mini",
    tools=[document_markdown_tool],
    name="financial-analyst",
)

result = agent.invoke({"messages": [{"role": "user", "content": "What is the quarterly revenue of Apple based on this file? https://www.apple.com/newsroom/pdfs/fy2025-q2/FY25_Q2_Consolidated_Financial_Statements.pdf"}]})