A Next.js application that provides a conversational AI chatbot interface to answer questions about the Stoller Report using RAG (Retrieval Augmented Generation) technology.
Stoller Bot is designed to provide insights and information from the Stoller Report through a conversational interface. The application includes:
- A user-facing chatbot interface to ask questions about the Stoller Report
- An admin interface for knowledge management (uploading, vectorizing, and managing documents)
- Vector-based semantic search capabilities to retrieve relevant information from documents
- OpenAI integration for embedding generation and chat completion
- Conversational AI: Chat interface powered by OpenAI's GPT models
- RAG (Retrieval Augmented Generation): Enhances AI responses with information retrieved from a knowledge base
- Document Management: Upload, process, and manage knowledge base documents
- Vector Search: Semantic search capability using embeddings stored in Upstash Vector
- Authentication: Secure admin interface for knowledge management
- Framework: Next.js 15 (App Router)
- Frontend: React, Tailwind CSS, Shadcn UI
- Backend: Next.js API Routes, OpenAI API
- Database: Upstash Redis (document storage), Upstash Vector (vector database)
- AI: OpenAI embeddings and completions
- State Management: React Query, nuqs
- Document Processing: PDF/Document parsing and chunking
- Node.js 18+ and npm
- OpenAI API key
- Upstash Redis and Vector accounts
- Clone the repository:
git clone https://github.com/yourusername/stoller-bot.git
cd stoller-bot- Install dependencies:
npm install- Create a
.env.localfile in the root directory with the following environment variables:
# OpenAI
OPENAI_API_KEY=your_openai_api_key
# Upstash Redis
UPSTASH_REDIS_REST_URL=your_upstash_redis_url
UPSTASH_REDIS_REST_TOKEN=your_upstash_redis_token
# Upstash Vector
UPSTASH_VECTOR_REST_URL=your_upstash_vector_url
UPSTASH_VECTOR_REST_TOKEN=your_upstash_vector_token
# Admin Authentication
ENRICH_PASSWORD=your_admin_password
# Optional KV Storage (if used)
KV_REST_API_URL=your_kv_url
KV_REST_API_TOKEN=your_kv_token
- Run the development server:
npm run dev- Open http://localhost:3000 in your browser to see the application.
The main page at / provides a chat interface where users can:
- Ask questions about the Stoller Report
- View AI-generated responses with information from the knowledge base
- Select from example questions to get started
The admin interface at /manage allows authorized users to:
- Upload new documents to the knowledge base
- Vectorize documents for semantic search
- Edit document content
- Delete documents and their associated vectors
- Test vector search functionality
- Try the chatbot with the current knowledge base
| Variable | Description | Required |
|---|---|---|
OPENAI_API_KEY |
OpenAI API key for embeddings and completions | Yes |
UPSTASH_REDIS_REST_URL |
Upstash Redis REST API URL | Yes |
UPSTASH_REDIS_REST_TOKEN |
Upstash Redis REST API token | Yes |
UPSTASH_VECTOR_REST_URL |
Upstash Vector REST API URL | Yes |
UPSTASH_VECTOR_REST_TOKEN |
Upstash Vector REST API token | Yes |
ENRICH_PASSWORD |
Password for the admin interface | Yes |
KV_REST_API_URL |
KV storage REST API URL (if used) | No |
KV_REST_API_TOKEN |
KV storage REST API token (if used) | No |
-
Document Processing:
- Documents are uploaded and parsed into text
- Text is chunked into smaller segments with overlap
- Each chunk is embedded using OpenAI's text-embedding-3-small model
- Embeddings are stored in Upstash Vector with metadata
-
Chat Interface:
- User questions are processed through the
/api/chat-webendpoint - The system uses a multistep approach:
- User query is embedded
- Relevant document chunks are retrieved from Upstash Vector
- Retrieved content is used as context for OpenAI's completion
- Model generates a response based on the retrieved information
- User questions are processed through the
-
Knowledge Management:
- Admin interface allows uploading, editing, and managing documents
- Documents are stored in Upstash Redis
- Document chunks are embedded and stored in Upstash Vector
- Admin can test search and chat functionality
[Your License Information]