Try out this example using this Colab Notebook
Closing Deals Faster with Signature Detection and LangGraph
Let’s set the context for this example, you will build a LangGraph agent for a real estate company to help track who has signed property documents, when they signed, and who still needs to sign. You’ll learn how to:- Use Tensorlake’s Signature Detection SDK
- Extract and summarize signature status per property
- Create a LangGraph agent that uses the structured data to answer questions like:
- How many signatures were detected in this document and who are the parties involved?
- What contextual information can you extract about any signatures?
- Are there any missing signatures on any pages?
Prerequisites
- Python 3.10+
- An OpenAI API key
- A Tensorlake API key
- Some sample real estate documents
- [Optional] A virtual Python environment to keep dependencies isolated
Build and test your LangGraph Agent
1
Set up your environment
Installing the
langchain-tensorlake
package will make sure that all relevant Tensorlake and LangChain packages are installed.For this tutorial, we’re using
.env
files for our OpenAI and Tensorlake API keys, so you need to install dotenv.
Tensorlake and LangGraph both look in environment variables for the necessary keys so that you don’t have to manually set them.1
Install necessary packages
2
Define your API keys
In
.env
, set your API keys:3
Prepare your imports
At the top, make sure you’ve imported all of the necessary Tensorlake, LangGraph, LangChain, and helper packages. Then, load your environment variables from
.env
:signature-detection-agent.py
2
Specify the document to be parsed and questions to be asked
In this example, we’re including the file and questions in the code. You could imagine this as input from the user
instead.
Make sure the file is at a publicly accessible URL.
signature-detection-agent.py
3
Define the LangGraph agent
Our goal is to create an agent that can communicate with the Tensorlake LangChain Tool to allow users to ask natural language questions about complex contractual documents.This agent will:
- Use the
document_markdown_tool
to: - Extract signature data from the document using Tensorlake’s Contextual Signature Detection
- Parse the documents into markdown chunks that are easily consumable by the LLM of our choice (in this case, ChatGPT)
- Interpret user questions (e.g. “Which pages are missing signatures?”)
- Return structured, accurate answers
signature-detection-agent.py
4
Invoke the agent and print the results
With the document, questions, and agent defined, you can invoke the agent and print the results.
signature-detection-agent.py
5
Test the Tensorlake powered LangGraph agent
Finally, run the script to see the agent in action. It will:
- Parse the document using Tensorlake’s signature detection
- Use the LangGraph agent to answer questions about the signatures
Don’t forget to
deactive venv
when you’re done testing the agent.