help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
rag-chatbot
RSK World
rag-chatbot
RAG Chatbot - Python + LangChain + ChromaDB + OpenAI API + Vector Search + Knowledge Base
rag-chatbot
  • __pycache__
  • analytics
  • conversations
  • knowledge_base
  • static
  • templates
  • vector_db
  • .env.example502 B
  • .gitignore519 B
  • ADVANCED_FEATURES.md5.2 KB
  • GITHUB_PUSH_SUMMARY.md3.6 KB
  • ISSUES_FIXED.md3.3 KB
  • LICENSE1.2 KB
  • PROJECT_INFO.md3 KB
  • QUICKSTART.md1.5 KB
  • README.md3.9 KB
  • RELEASE_NOTES.md3.7 KB
  • analytics.py6.9 KB
  • app.py8.3 KB
  • chatbot.py10.8 KB
  • config.py1.8 KB
  • conversation_manager.py5.8 KB
  • embeddings.py1.9 KB
  • hybrid_search.py4 KB
  • prepare_knowledge_base.py6.8 KB
  • requirements.txt377 B
  • setup.py2.8 KB
  • vector_store.py6.7 KB
index.htmldownload_real_videos.pyISSUES_FIXED.mdLICENSErequirements.txt
templates/index.html
Raw Download
Find: Go to:
<!DOCTYPE html>
<!--
RAG Chatbot - Main HTML Template
Project: RAG Chatbot
Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
Description: Main chat interface for the RAG chatbot with advanced features
-->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RAG Chatbot - RSK World</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <div class="container">
        <header>
            <div class="header-content">
                <i class="fas fa-database header-icon"></i>
                <h1>RAG Chatbot</h1>
                <p class="subtitle">Retrieval-Augmented Generation with Knowledge Base</p>
                <div class="header-actions">
                    <button class="btn-icon" id="settingsBtn" title="Settings">
                        <i class="fas fa-cog"></i>
                    </button>
                    <button class="btn-icon" id="analyticsBtn" title="Analytics">
                        <i class="fas fa-chart-bar"></i>
                    </button>
                    <button class="btn-icon" id="uploadBtn" title="Upload Document">
                        <i class="fas fa-upload"></i>
                    </button>
                </div>
            </div>
        </header>

        <main>
            <div class="chat-container">
                <div class="chat-header">
                    <div class="chat-controls">
                        <button class="btn-small" id="clearChatBtn">
                            <i class="fas fa-trash"></i> Clear Chat
                        </button>
                        <button class="btn-small" id="exportChatBtn">
                            <i class="fas fa-download"></i> Export
                        </button>
                        <div class="settings-toggle">
                            <label class="switch">
                                <input type="checkbox" id="hybridSearchToggle">
                                <span class="slider"></span>
                            </label>
                            <span class="toggle-label">Hybrid Search</span>
                        </div>
                        <div class="settings-toggle">
                            <label class="switch">
                                <input type="checkbox" id="streamingToggle" checked>
                                <span class="slider"></span>
                            </label>
                            <span class="toggle-label">Streaming</span>
                        </div>
                    </div>
                </div>

                <div class="chat-messages" id="chatMessages">
                    <div class="message bot-message">
                        <div class="message-icon">
                            <i class="fas fa-robot"></i>
                        </div>
                        <div class="message-content">
                            <p>Hello! I'm your RAG-powered chatbot with advanced features. I can answer questions based on my knowledge base. How can I help you today?</p>
                        </div>
                    </div>
                </div>

                <div class="chat-input-container">
                    <div class="input-wrapper">
                        <input 
                            type="text" 
                            id="userInput" 
                            placeholder="Ask me anything..." 
                            autocomplete="off"
                        >
                        <button id="sendButton" class="send-button">
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                </div>
            </div>

            <div class="info-panel">
                <h3><i class="fas fa-info-circle"></i> About</h3>
                <p>This chatbot uses RAG (Retrieval-Augmented Generation) architecture with advanced features.</p>
                
                <h3><i class="fas fa-feather-alt"></i> Features</h3>
                <ul>
                    <li>Knowledge base integration</li>
                    <li>Vector + Keyword hybrid search</li>
                    <li>Conversation history</li>
                    <li>Streaming responses</li>
                    <li>Document upload</li>
                    <li>Analytics & statistics</li>
                    <li>Feedback system</li>
                    <li>Export conversations</li>
                </ul>

                <div class="footer-info">
                    <p><i class="fas fa-code"></i> Developed by <a href="https://rskworld.in" target="_blank">RSK World</a></p>
                    <p><i class="fas fa-envelope"></i> <a href="mailto:help@rskworld.in">help@rskworld.in</a></p>
                    <p><i class="fas fa-phone"></i> +91 93305 39277</p>
                    <p class="copyright">&copy; 2026 RSK World</p>
                </div>
            </div>
        </main>
    </div>

    <!-- Modals -->
    <div class="modal" id="uploadModal">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-upload"></i> Upload Document</h2>
                <button class="modal-close" id="closeUploadModal">&times;</button>
            </div>
            <div class="modal-body">
                <form id="uploadForm">
                    <div class="file-upload-area" id="fileUploadArea">
                        <i class="fas fa-cloud-upload-alt"></i>
                        <p>Drag and drop a file here or click to browse</p>
                        <p class="file-info">Supported: PDF, TXT, MD (Max 16MB)</p>
                        <input type="file" id="fileInput" accept=".pdf,.txt,.md" hidden>
                    </div>
                    <div id="filePreview" class="file-preview"></div>
                    <button type="submit" class="btn-primary" id="uploadSubmitBtn" disabled>
                        <i class="fas fa-upload"></i> Upload and Process
                    </button>
                </form>
            </div>
        </div>
    </div>

    <div class="modal" id="analyticsModal">
        <div class="modal-content modal-large">
            <div class="modal-header">
                <h2><i class="fas fa-chart-bar"></i> Analytics & Statistics</h2>
                <button class="modal-close" id="closeAnalyticsModal">&times;</button>
            </div>
            <div class="modal-body">
                <div id="analyticsContent">
                    <div class="stats-grid">
                        <div class="stat-card">
                            <div class="stat-value" id="totalQueries">0</div>
                            <div class="stat-label">Total Queries</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-value" id="totalSessions">0</div>
                            <div class="stat-label">Total Sessions</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-value" id="avgResponseTime">0s</div>
                            <div class="stat-label">Avg Response Time</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-value" id="feedbackScore">0%</div>
                            <div class="stat-label">Feedback Score</div>
                        </div>
                    </div>
                    <div class="analytics-section">
                        <h3>Top Queries</h3>
                        <div id="topQueries"></div>
                    </div>
                    <div class="analytics-section">
                        <h3>Top Sources</h3>
                        <div id="topSources"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="loading-overlay" id="loadingOverlay">
        <div class="spinner"></div>
        <p>Thinking...</p>
    </div>

    <script src="{{ url_for('static', filename='js/app.js') }}"></script>
</body>
</html>
191 lines•8.4 KB
markup
ISSUES_FIXED.md
Raw Download

ISSUES_FIXED.md

# Issues Found and Fixed

<!--
Project: RAG Chatbot
Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
-->

## Issues Identified and Resolved

### 1. Unused Imports ✅ FIXED
- **File**: `chatbot.py`
- **Issue**: Unused import `ConversationBufferMemory` from langchain.memory
- **Fix**: Removed the unused import

### 2. Unused Imports ✅ FIXED
- **File**: `app.py`
- **Issue**: Unused imports `send_file` and `Path`
- **Fix**: Removed unused imports

### 3. Vector Store Collection Count ✅ FIXED
- **File**: `vector_store.py`
- **Issue**: `get_collection_count()` method used private attribute `_collection` which might not work in all LangChain versions
- **Fix**: Added multiple fallback methods to get collection count safely:
- Try `_collection.count()`
- Try `collection.count()`
- Fallback to similarity search with empty query

### 4. Streaming Implementation ✅ FIXED
- **File**: `chatbot.py`
- **Issue**: Streaming might fail if chat_history is empty string
- **Fix**: Added fallback value "No previous conversation." when chat_history is empty

### 5. File Upload Import Handling ✅ FIXED
- **File**: `app.py`
- **Issue**: Import statements for document loaders not properly handled with fallback
- **Fix**: Added proper try/except for langchain_community imports with fallback to langchain

### 6. Missing Directories ✅ FIXED
- **Issue**: Required directories for conversations, analytics, and vector_db might not exist
- **Fix**: Created directories:
- `conversations/` - for conversation history storage
- `analytics/` - for analytics data storage
- `vector_db/` - for vector database storage

### 7. Git Ignore Updates ✅ FIXED
- **File**: `.gitignore`
- **Issue**: Missing entries for conversations and analytics directories
- **Fix**: Added `conversations/` and `analytics/` to .gitignore

## Verification

### Syntax Check ✅
- All Python files compiled successfully with `py_compile`
- No syntax errors found

### Linter Check ✅
- All files passed linter checks
- No linting errors

### Import Structure ✅
- All imports are properly structured
- Fallback imports added where needed for compatibility

## Remaining Notes

1. **Dependencies**: The project requires dependencies to be installed via `pip install -r requirements.txt`
2. **Environment Variables**: Make sure `.env` file is created with `OPENAI_API_KEY`
3. **Knowledge Base**: Run `python prepare_knowledge_base.py` to initialize the knowledge base

## Files Verified

✅ `app.py` - Flask application
✅ `chatbot.py` - RAG chatbot implementation
✅ `vector_store.py` - Vector database operations
✅ `embeddings.py` - Embedding utilities
✅ `conversation_manager.py` - Conversation history
✅ `analytics.py` - Analytics tracking
✅ `hybrid_search.py` - Hybrid search
✅ `prepare_knowledge_base.py` - Knowledge base preparation
✅ `config.py` - Configuration
✅ `setup.py` - Setup script
✅ `templates/index.html` - Web interface
✅ `static/css/style.css` - Styles
✅ `static/js/app.js` - Frontend JavaScript

## All Issues Resolved ✅

The project is now ready for use. All identified issues have been fixed and the codebase is clean and functional.

© 2026 RSK World - https://rskworld.in

LICENSE
Raw Download
Find: Go to:
MIT License

Copyright (c) 2026 RSK World

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---
Project: RAG Chatbot
Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026

31 lines•1.2 KB
text
requirements.txt
Raw Download
Find: Go to:
# RAG Chatbot - Python Dependencies
# Project: RAG Chatbot
# Developer: RSK World
# Website: https://rskworld.in
# Email: help@rskworld.in
# Phone: +91 93305 39277
# Year: 2026

flask==3.0.0
langchain==0.1.0
langchain-openai==0.0.2
langchain-community==0.0.10
chromadb==0.4.22
openai==1.10.0
python-dotenv==1.0.0
pypdf2==3.0.1
tiktoken==0.5.2
numpy==1.26.3

20 lines•377 B
text
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer