Tensorlake can be used with Langchain in two ways:
- Using the Python SDK
tensorlake
to upload files and parse them.
- Using the langchain-tensorlake package as a tool in LangGraph agents.
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.
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"
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"}]})