Learn 🧠 All Concepts (20) 🤖 What is an LLM? 📚 RAG Explained ⚡ AI Agents 💻 Run AI Locally 🇮🇳 AI in India 📖 Learn Tracks 🔧 DevOps Track ⚙️ AI Ops Track 🗺️ AI Engineer Roadmap
Tools 🔧 AI Tools Directory 🔓 Open Source AI ⭐ Top GitHub Repos ✦ Claude Skill Repos 🚀 Ready-to-Deploy Projects
Build 🏗️ Build Hub 🎯 Master Prompts 🧩 RAG Agents 🚀 App Megaprompts
Workflows ⚡ All Workflows (22) 🎥 Text to Video 🎞️ Image to Video 🔊 Text to Speech ♻️ Automation
Resources 🧪 Colab Notebooks ⚙️ n8n Workflows 📈 Algo Trading 💰 Passive Income
🗂️ Browse All Topics About AItheGuru
← Megaprompts
🤖 Megaprompt · AI Apps

Build a custom AI chatbot with RAG

Chat interface with document upload, RAG retrieval, and conversation memory

Works on:
ClaudeGemini 3 ProGPT-4o

Copy this prompt

Fill in every [BRACKET] then paste

Works on: claude.ai · Google AI Studio · Replit

How to use

Fill in every [PLACEHOLDER] with your specifics before pasting. The more detail you provide, the better the output.

Fill in every [PLACEHOLDER] — vague inputs give generic outputs
Works best in Claude Projects with the Full-Stack Architect system prompt active
If the model stops mid-build, say "Continue from where you left off"
For Replit: paste in the Agent chat, not the editor

Best platforms

claude.aiGoogle AI StudioReplit

The megaprompt

Build a complete AI chatbot application with Retrieval Augmented Generation (RAG). ## Chatbot Purpose This chatbot is for: [DESCRIBE THE USE CASE — customer support / document Q&A / coding helper / etc] Knowledge base: [What documents/data it should know about] Target users: [WHO USES IT] ## Tech Stack - Frontend: Next.js 15 + Tailwind CSS - AI: Vercel AI SDK (supports Claude, OpenAI, Gemini) - Vector Database: Supabase pgvector (free, no separate service needed) - Embeddings: OpenAI text-embedding-3-small (cheap and excellent) - File parsing: LlamaIndex or unstructured.io for PDFs - Streaming: AI SDK's useChat hook for streaming responses ## Features to Build ### Chat Interface - Streaming responses (text appears word by word like ChatGPT) - Conversation history (persist in localStorage or database) - Copy message button - Regenerate response button - Model selector (switch between Claude/GPT-4o/Gemini) - Typing indicator while AI is thinking ### Document Upload & RAG - Drag-and-drop file upload (PDF, TXT, DOCX) - Progress bar during processing - Show which documents are in the knowledge base - Delete documents from knowledge base - When answering, show which source documents were used ### System Prompt Customization - UI to set the bot's persona and instructions - Preset personas to choose from - Save custom personas ## API Routes Required POST /api/chat — streaming chat endpoint POST /api/documents/upload — process and embed documents GET /api/documents — list uploaded documents DELETE /api/documents/:id — remove a document ## RAG Pipeline 1. User uploads document → chunk into 500-token segments 2. Generate embeddings for each chunk 3. Store in Supabase vector table 4. On each user message → embed the question 5. Find top-5 similar chunks via cosine similarity 6. Inject into system prompt as context 7. Stream AI response ## Design - Dark theme (code-friendly, professional) - ChatGPT-inspired layout: sidebar for conversations, main area for chat - Mobile responsive - Source citations shown inline in responses as [1], [2] footnotes ## Environment Variables Needed OPENAI_API_KEY or ANTHROPIC_API_KEY or GOOGLE_AI_API_KEY SUPABASE_URL SUPABASE_SERVICE_KEY