Talk to Your PDF
Overview
This tutorial demonstrates how to build a PDF chat application using Letta. You’ll learn how to upload PDF documents to the Letta Filesystem, attach them to an agent, and query the agent about the content. Letta automatically extracts text from PDFs using OCR, making the content accessible to your agents.
By the end of this guide, you’ll understand how to create document analysis workflows where agents can read, understand, and answer questions about PDF files.
This tutorial uses Letta Cloud. Generate an API key at app.letta.com/api-keys and set it as LETTA_API_KEY in your environment. Self-hosted servers only need an API key if authentication is enabled. You can learn more about self-hosting here.
What You’ll Learn
- Creating folders to organize documents
- Uploading PDF files to Letta
- Creating agents configured for document analysis
- Attaching folders to give agents access to files
- Querying agents about PDF content
- Understanding how Letta processes PDFs
Prerequisites
Install the required dependencies:
Steps
Step 1: Initialize Client
Step 2: Create a Folder for PDFs
Folders in the Letta Filesystem organize files and make them accessible to agents. Create a folder specifically for storing PDF documents:
Expected Output
If the folder already exists, you’ll see:
Step 3: Download and Upload a PDF
Let’s download a sample PDF (the MemGPT research paper) and upload it to the folder. Letta will automatically extract the text content using OCR.
Expected Output
PDF Processing: Letta extracts text from PDFs using OCR automatically during upload. The extracted text becomes searchable and accessible to agents attached to the folder.
Step 4: Create an Agent for Document Analysis
Create an agent with a persona configured for analyzing documents. The agent’s memory blocks define its purpose and capabilities:
Expected Output
Step 5: Attach the Folder to the Agent
Attach the folder containing the PDF to the agent. This gives the agent the ability to search through all files in the folder:
Expected Output
Once a folder is attached, the agent can use search tools to retrieve relevant content from files in the folder. Learn more in the Letta Filesystem guide.
Step 6: Query the PDF Content
Now ask the agent questions about the PDF. The agent will search through the document content to find relevant information:
Expected Output
Step 7: Ask Specific Questions
You can continue the conversation to ask more specific questions about the document:
Expected Output
Complete Example
Here’s the full code in one place that you can run:
Key Concepts
Folders in the Letta Filesystem organize and group files, making them easy to manage and attach to agents
PDFs are automatically processed using OCR to extract searchable text content during upload
Attaching folders gives agents search capabilities to retrieve relevant content from files
Agents use search tools to find relevant passages in documents when answering questions
Use Cases
Research Paper Analysis
Upload academic papers and have agents summarize findings, extract key concepts, or compare methodologies.
Document Q&A
Build customer support systems that answer questions based on product documentation or manuals.
Legal Document Review
Analyze contracts, agreements, or legal documents to extract clauses, identify risks, or summarize terms.
Knowledge Base Creation
Process multiple PDFs to build a searchable knowledge base that agents can query for information.