A full-stack agentic RAG (Retrieval-Augmented Generation) application that allows users to upload PDF documents and chat with them using an intelligent AI agent.
- PDF Document Ingestion: Upload and process PDF files into a vector database
- Agentic Chat: Intelligent agent that decides when to search the knowledge base
- Conversation Memory: Maintains context across multiple questions
- Modern UI: ChatGPT-like interface with file upload capabilities
- Observability: Integrated with LangSmith for monitoring and tracing
- Server: Express.js API server with CORS and file upload support
- Agent: LangChain ReAct agent with OpenAI GPT-4o
- Vector Database: Pinecone for document storage and similarity search
- Embeddings: Pinecone-hosted
llama-text-embed-v2model - Observability: LangSmith for tracing and monitoring
- UI Framework: React with Vite for fast development
- Styling: ChatGPT-inspired dark theme interface
- File Upload: Drag-and-drop PDF upload with progress feedback
- Chat Interface: Real-time messaging with typing indicators
- Node.js (v18 or higher)
- npm or yarn
- Pinecone account with index created
- OpenAI API key
- LangSmith account (optional, for observability)
-
Clone the repository
git clone <repository-url> cd agentic-personal-assistant
-
Install dependencies
npm run install:all
-
Environment Configuration
cp .env.example .env
Edit
.envwith your API keys:# LLM OPENAI_API_KEY=your_openai_api_key # Vector DB (Pinecone) PINECONE_API_KEY=your_pinecone_api_key PINECONE_INDEX=your_pinecone_index_name # LangSmith tracing LANGSMITH_TRACING=true LANGSMITH_ENDPOINT=https://api.smith.langchain.com LANGSMITH_API_KEY=langsmith_key LANGSMITH_PROJECT="Project name"
npm run devThis starts both the server (port 3001) and client (port 5173) concurrently.
# Server only
npm run dev:server
# Client only
npm run dev:clientagentic-personal-assistant/
├── server/ # Backend API server
│ ├── index.js # Express server and API routes
│ ├── agent.js # Agent logic and memory management
│ ├── tools.js # Knowledge base search tool
│ ├── ingest.js # PDF ingestion pipeline
│ └── package.json # Server dependencies
├── client/ # Frontend React app
│ ├── src/
│ │ ├── App.jsx # Main application component
│ │ ├── App.css # ChatGPT-like styling
│ │ └── main.jsx # React entry point
│ └── package.json # Client dependencies
├── .env.example # Environment variables template
├── package.json # Root package with scripts
└── README.md # This file
- User uploads PDF via frontend
- Server receives file and extracts text using PDFLoader
- Text is split into chunks (1000 chars with 200 overlap)
- Chunks are converted to embeddings using Pinecone's model
- Embeddings are stored in Pinecone vector database
- User sends a message
- Agent receives message with conversation history
- Agent decides whether to search the knowledge base
- If needed, searches Pinecone for relevant document chunks
- Agent uses retrieved context to generate response
- Response is sent back to user and added to conversation history
- ReAct agent using LangChain's
createAgent - MemorySaver for conversation persistence
- Tool calling for knowledge base search
- Pinecone vector store integration
- Similarity search with top-k results
- Lazy initialization for environment variables
- PDF text extraction and chunking
- Batch processing (96 chunks per API call)
- Pinecone upsert operations
- React state management for chat and upload
- File upload with progress feedback
- Real-time chat interface with auto-scroll
-
Connection Refused Error
- Ensure server is running on port 3001
- Check for port conflicts:
lsof -i :3001
-
Environment Variables Missing
- Verify
.envfile exists in server directory - Check all required API keys are set
- Verify
-
Pinecone API Errors
- Verify Pinecone index exists
- Check API key permissions
- Ensure embedding model matches ingestion/retrieval
-
Dependency Installation Errors
- Use
--legacy-peer-depsflag for peer dependency conflicts - Clear node_modules and reinstall if needed
- Use
- Backend: Node.js, Express.js, Multer
- Frontend: React, Vite
- AI/ML: LangChain, OpenAI GPT-4o
- Vector DB: Pinecone
- Observability: LangSmith
- Development: Concurrently, ESLint
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.