This guide will help you set up the simplified PDF chat functionality that allows you to select PDFs, preview them, and chat with their content using LlamaParse.
You need the following API keys:
- Go to DeepSeek Platform
- Sign up and create an API key
- This is used for the AI chat responses
- Go to LlamaCloud
- Sign up and get your API key
- This is used for document parsing with LlamaParse
Create a .env.local file in your project root:
# Required: DeepSeek API Key for the LLM
DEEPSEEK_API_KEY=your_deepseek_api_key_here
# Required: LlamaCloud API Key for document parsing
LLAMA_CLOUD_API_KEY=your_llamacloud_api_key_here
# Optional: DeepSeek model (defaults to "deepseek-chat")
DEEPSEEK_MODEL=deepseek-chat- Document Selection: Choose from PDFs in the
/documentsfolder using a dropdown - PDF Preview: Native browser PDF viewer on the right side
- Simple Chat: Ask questions about the selected PDF
- Text Extraction: Uses LlamaParse for reliable text extraction from PDFs
- In-Memory Caching: Parsed documents are cached in memory to avoid re-parsing
- Layout extraction and highlighting
- Complex file-based caching
- Source citations with visual mapping
- Multiple API endpoints
- Image serving
- Complex UI components
-
Access the Interface:
- Navigate to
/placeholderin your app - You'll see a two-panel layout: chat on left, PDF preview on right
- Navigate to
-
Add Documents:
- Place PDF files in the
/documentsfolder - They will automatically appear in the dropdown
- Place PDF files in the
-
Start Chatting:
- Select a document from the dropdown
- The PDF will load in the preview panel
- Start asking questions about the content
- Method: GET
- Description: Lists available PDF documents
- Returns: Array of document metadata
- Method: POST
- Body:
{ query: "your question", documentPath: "documents/filename.pdf" } - Description: Chat with a specific document using LlamaParse + DeepSeek
- Returns: Streaming text response
- Document Loading: When you select a PDF, it loads in the browser's native PDF viewer
- First Question: When you ask your first question about a document, LlamaParse extracts the text
- Vector Index: The extracted text is converted to a vector index for semantic search
- Chat Response: DeepSeek generates responses based on relevant document content
- Caching: The vector index is cached in memory to avoid re-parsing the same document
Most Common Causes:
- Invalid LlamaCloud API Key: Check your API key at LlamaCloud
- Insufficient Credits: Check your LlamaCloud account balance
- Unsupported PDF: Some PDFs may not be parseable
- Check that PDF files are in the
/documentsfolder - Ensure files have
.pdfextension - Check browser console for errors
- Verify
DEEPSEEK_API_KEYis set correctly - Ensure the document was successfully parsed
- Check browser network tab for API errors
- Ensure the PDF file is accessible
- Check browser console for loading errors
- Try a different PDF to isolate the issue
- Documents are parsed on first use (lazy loading)
- Vector indices are cached in memory during the session
- Large PDFs may take longer to parse initially
- No persistent caching (re-parses on server restart)
- Single document chat only (no multi-document queries)
- No visual highlighting or source citations
- Relies on browser's built-in PDF viewer
If needed, you could add back:
- File-based caching for persistence
- Multi-document chat capabilities
- Source citations (without visual highlighting)
- Document upload functionality
src/app/
├── placeholder/
│ └── page.tsx # Main chat interface
└── api/research/
├── documents/route.ts # List available documents
└── chat/route.ts # Chat with documents
documents/ # Place your PDFs here
├── paper1.pdf
├── paper2.pdf
└── ...
This simplified implementation focuses on the core functionality: select a PDF, preview it, and chat with its content using reliable LlamaParse text extraction.