Spaces:
Sleeping
Sleeping
Girish Jeswani commited on
Commit ·
4f0dfc7
1
Parent(s): 34e36f5
update setup instructions
Browse files
README.md
CHANGED
|
@@ -4,204 +4,419 @@ An AI-powered academic guidance system that provides personalized advice through
|
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
-
- **Multiple AI Advisor Personas**: Chat with specialized advisors including Methodologist
|
| 8 |
-
- **Document Upload
|
| 9 |
-
- **
|
| 10 |
-
- **
|
| 11 |
-
- **
|
| 12 |
-
- **
|
| 13 |
-
- **
|
|
|
|
| 14 |
|
| 15 |
## Architecture
|
| 16 |
|
| 17 |
### Frontend (React)
|
| 18 |
- **Technology**: React 18 with modern hooks and functional components
|
| 19 |
- **Styling**: CSS custom properties with dark/light theme support
|
| 20 |
-
- **
|
| 21 |
-
- **
|
| 22 |
-
- **Icons**: Lucide React for consistent iconography
|
| 23 |
|
| 24 |
### Backend (FastAPI)
|
| 25 |
- **Framework**: FastAPI with automatic API documentation
|
| 26 |
-
- **
|
| 27 |
-
- **
|
| 28 |
-
- **
|
| 29 |
-
- **
|
|
|
|
| 30 |
|
| 31 |
-
##
|
| 32 |
|
| 33 |
-
|
| 34 |
-
- Node.js 16+ and npm
|
| 35 |
-
- Python 3.8+
|
| 36 |
-
- (Optional) Gemini API key for Google's models
|
| 37 |
-
- (Optional) Ollama installation for local models
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
```bash
|
| 43 |
cd multi_llm_chatbot_backend
|
| 44 |
```
|
| 45 |
|
| 46 |
-
2. **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
```bash
|
| 48 |
pip install -r requirements.txt
|
| 49 |
```
|
| 50 |
|
| 51 |
-
|
| 52 |
-
Create a `.env` file:
|
|
|
|
| 53 |
```env
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
GEMINI_API_KEY=your_gemini_api_key_here
|
| 55 |
GEMINI_MODEL=gemini-2.0-flash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
```
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
```bash
|
| 60 |
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
| 61 |
```
|
| 62 |
|
| 63 |
The API will be available at `http://localhost:8000` with interactive docs at `http://localhost:8000/docs`
|
| 64 |
|
| 65 |
-
### Frontend Setup
|
| 66 |
|
| 67 |
-
1. **Navigate to frontend directory**
|
| 68 |
```bash
|
| 69 |
-
cd phd-advisor-frontend
|
| 70 |
```
|
| 71 |
|
| 72 |
-
2. **Install dependencies**
|
| 73 |
```bash
|
| 74 |
npm install
|
| 75 |
```
|
| 76 |
|
| 77 |
-
3. **Start the development server**
|
| 78 |
```bash
|
| 79 |
npm start
|
| 80 |
```
|
| 81 |
|
| 82 |
The application will open at `http://localhost:3000`
|
| 83 |
|
| 84 |
-
##
|
| 85 |
|
| 86 |
-
###
|
| 87 |
-
- **Focus**: Research design, validity, sampling, methodological rigor
|
| 88 |
-
- **Style**: Precise, analytical, methodology-focused
|
| 89 |
-
- **Best for**: Research design questions, data collection methods, validity concerns
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
-
###
|
| 97 |
-
- **Focus**: Practical next steps, immediate actions, progress over perfection
|
| 98 |
-
- **Style**: Warm, motivational, results-oriented
|
| 99 |
-
- **Best for**: Getting unstuck, prioritizing tasks, actionable advice
|
| 100 |
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
| 104 |
-
-
|
| 105 |
-
-
|
| 106 |
-
-
|
| 107 |
|
| 108 |
-
|
| 109 |
-
-
|
| 110 |
-
-
|
| 111 |
-
-
|
| 112 |
|
| 113 |
-
|
| 114 |
-
-
|
| 115 |
-
-
|
|
|
|
| 116 |
|
| 117 |
-
##
|
| 118 |
-
- `GET /debug/personas` - Debug persona configurations
|
| 119 |
-
- `GET /` - API health check
|
| 120 |
|
| 121 |
-
##
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
| 126 |
-
- Requires GEMINI_API_KEY environment variable
|
| 127 |
-
- Uses gemini-2.0-flash model by default
|
| 128 |
-
- Cloud-based, requires internet connection
|
| 129 |
|
| 130 |
-
|
| 131 |
-
- Requires Ollama installation
|
| 132 |
-
- Uses llama3.2:1b model by default
|
| 133 |
-
- Runs locally, no internet required
|
| 134 |
|
| 135 |
-
|
| 136 |
-
-
|
| 137 |
-
-
|
| 138 |
-
-
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
```
|
| 149 |
|
| 150 |
-
##
|
| 151 |
|
| 152 |
-
###
|
| 153 |
-
``
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
```
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
-
|
| 179 |
-
Use the test script:
|
| 180 |
```bash
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
```
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
-
###
|
| 194 |
-
1. In the chat interface, click the upload button
|
| 195 |
-
2. Select your PDF, DOCX, or TXT file
|
| 196 |
-
3. The document content will be added to the conversation context
|
| 197 |
-
4. Ask questions about your uploaded documents
|
| 198 |
|
| 199 |
-
### Switching LLM Providers
|
| 200 |
```bash
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
## Contributing
|
| 207 |
|
|
@@ -211,10 +426,16 @@ curl -X POST "http://localhost:8000/switch-provider" \
|
|
| 211 |
4. Push to the branch (`git push origin feature/amazing-feature`)
|
| 212 |
5. Open a Pull Request
|
| 213 |
|
| 214 |
-
|
| 215 |
## Support
|
| 216 |
|
| 217 |
-
- Check the API
|
| 218 |
-
-
|
| 219 |
-
-
|
| 220 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
+
- **Multiple AI Advisor Personas**: Chat with 10+ specialized advisors including Methodologist, Theorist, Pragmatist, and more
|
| 8 |
+
- **Document Upload & Analysis**: Upload PDFs, Word documents, and text files for context-aware advice
|
| 9 |
+
- **Intelligent Document Retrieval (RAG)**: Advanced semantic search through your uploaded documents
|
| 10 |
+
- **Multi-LLM Backend**: Supports both Gemini API and local Ollama models
|
| 11 |
+
- **User Authentication**: Secure user accounts with persistent chat sessions
|
| 12 |
+
- **Chat Session Management**: Save, load, and manage multiple conversation threads
|
| 13 |
+
- **Export Capabilities**: Export chats and summaries in TXT, PDF, and DOCX formats
|
| 14 |
+
- **Real-time Chat Interface**: Modern, responsive UI with advisor-specific styling
|
| 15 |
|
| 16 |
## Architecture
|
| 17 |
|
| 18 |
### Frontend (React)
|
| 19 |
- **Technology**: React 18 with modern hooks and functional components
|
| 20 |
- **Styling**: CSS custom properties with dark/light theme support
|
| 21 |
+
- **State Management**: React Context and hooks
|
| 22 |
+
- **Authentication**: JWT-based authentication with persistent sessions
|
|
|
|
| 23 |
|
| 24 |
### Backend (FastAPI)
|
| 25 |
- **Framework**: FastAPI with automatic API documentation
|
| 26 |
+
- **Database**: MongoDB for user data and chat sessions
|
| 27 |
+
- **Vector Database**: ChromaDB for document storage and semantic search
|
| 28 |
+
- **LLM Integration**: Support for Gemini API and Ollama models
|
| 29 |
+
- **Document Processing**: PDF, DOCX, and text file extraction with intelligent chunking
|
| 30 |
+
- **Authentication**: JWT tokens with bcrypt password hashing
|
| 31 |
|
| 32 |
+
## Prerequisites
|
| 33 |
|
| 34 |
+
Before you begin, ensure you have the following installed:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
- **Python 3.8+** (3.9+ recommended)
|
| 37 |
+
- **Node.js 16+** and npm
|
| 38 |
+
- **MongoDB** (Community Edition)
|
| 39 |
+
- **Git**
|
| 40 |
|
| 41 |
+
## Installation Guide
|
| 42 |
+
|
| 43 |
+
### Step 1: Clone the Repository
|
| 44 |
+
|
| 45 |
+
```bash
|
| 46 |
+
git clone https://github.com/sohank-17/Neon-AI-Project.git
|
| 47 |
+
cd Neon-AI-Project
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Step 2: MongoDB Setup
|
| 51 |
+
|
| 52 |
+
#### Option A: Local MongoDB Installation
|
| 53 |
+
|
| 54 |
+
**On Windows:**
|
| 55 |
+
1. Download MongoDB Community Server from [mongodb.com](https://www.mongodb.com/try/download/community)
|
| 56 |
+
2. Install with default settings
|
| 57 |
+
3. MongoDB will run as a Windows Service automatically
|
| 58 |
+
|
| 59 |
+
**On macOS:**
|
| 60 |
+
```bash
|
| 61 |
+
# Using Homebrew
|
| 62 |
+
brew tap mongodb/brew
|
| 63 |
+
brew install mongodb-community
|
| 64 |
+
brew services start mongodb/brew/mongodb-community
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
**On Linux (Ubuntu/Debian):**
|
| 68 |
+
```bash
|
| 69 |
+
# Import MongoDB public GPG key
|
| 70 |
+
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
|
| 71 |
+
|
| 72 |
+
# Create list file
|
| 73 |
+
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
| 74 |
+
|
| 75 |
+
# Install MongoDB
|
| 76 |
+
sudo apt-get update
|
| 77 |
+
sudo apt-get install -y mongodb-org
|
| 78 |
+
|
| 79 |
+
# Start MongoDB
|
| 80 |
+
sudo systemctl start mongod
|
| 81 |
+
sudo systemctl enable mongod
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
#### Option B: MongoDB Atlas (Cloud)
|
| 85 |
+
1. Create a free account at [MongoDB Atlas](https://www.mongodb.com/atlas)
|
| 86 |
+
2. Create a new cluster
|
| 87 |
+
3. Get your connection string
|
| 88 |
+
4. Skip the local MongoDB setup
|
| 89 |
+
|
| 90 |
+
### Step 3: Ollama Installation (for Local LLM Support)
|
| 91 |
+
|
| 92 |
+
#### Install Ollama
|
| 93 |
+
|
| 94 |
+
**On Windows:**
|
| 95 |
+
1. Download Ollama from [ollama.ai](https://ollama.ai)
|
| 96 |
+
2. Run the installer
|
| 97 |
+
3. Ollama will start automatically
|
| 98 |
+
|
| 99 |
+
**On macOS:**
|
| 100 |
+
```bash
|
| 101 |
+
# Using Homebrew
|
| 102 |
+
brew install ollama
|
| 103 |
+
|
| 104 |
+
# Or download from ollama.ai
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
**On Linux:**
|
| 108 |
+
```bash
|
| 109 |
+
# Install Ollama
|
| 110 |
+
curl -fsSL https://ollama.ai/install.sh | sh
|
| 111 |
+
|
| 112 |
+
# Start Ollama service
|
| 113 |
+
sudo systemctl start ollama
|
| 114 |
+
sudo systemctl enable ollama
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
#### Download Required Models
|
| 118 |
+
|
| 119 |
+
Once Ollama is installed, download the recommended models:
|
| 120 |
+
|
| 121 |
+
```bash
|
| 122 |
+
# Download the default model (recommended for development)
|
| 123 |
+
ollama pull llama3.2:1b
|
| 124 |
+
|
| 125 |
+
# Optional: Download larger, more capable models
|
| 126 |
+
ollama pull llama3.2:3b
|
| 127 |
+
ollama pull mistral:7b
|
| 128 |
+
|
| 129 |
+
# Verify installation
|
| 130 |
+
ollama list
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
**Note**: The `llama3.2:1b` model is small (~1.3GB) and fast, perfect for development. For production, consider larger models for better quality.
|
| 134 |
+
|
| 135 |
+
### Step 4: Backend Setup
|
| 136 |
+
|
| 137 |
+
1. **Navigate to the backend directory:**
|
| 138 |
```bash
|
| 139 |
cd multi_llm_chatbot_backend
|
| 140 |
```
|
| 141 |
|
| 142 |
+
2. **Create a Python virtual environment:**
|
| 143 |
+
```bash
|
| 144 |
+
# Create virtual environment
|
| 145 |
+
python -m venv venv
|
| 146 |
+
|
| 147 |
+
# Activate virtual environment
|
| 148 |
+
# On Windows:
|
| 149 |
+
venv\Scripts\activate
|
| 150 |
+
# On macOS/Linux:
|
| 151 |
+
source venv/bin/activate
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
3. **Install Python dependencies:**
|
| 155 |
```bash
|
| 156 |
pip install -r requirements.txt
|
| 157 |
```
|
| 158 |
|
| 159 |
+
4. **Set up environment variables:**
|
| 160 |
+
Create a `.env` file in the `multi_llm_chatbot_backend` directory:
|
| 161 |
+
|
| 162 |
```env
|
| 163 |
+
# MongoDB Configuration
|
| 164 |
+
MONGODB_CONNECTION_STRING=mongodb://localhost:27017
|
| 165 |
+
MONGODB_DATABASE_NAME=phd_advisor
|
| 166 |
+
|
| 167 |
+
# JWT Configuration
|
| 168 |
+
JWT_SECRET_KEY=your-super-secret-jwt-key-change-this-in-production-please-make-it-long-and-random
|
| 169 |
+
|
| 170 |
+
# Gemini API Configuration (Optional - for cloud LLM)
|
| 171 |
GEMINI_API_KEY=your_gemini_api_key_here
|
| 172 |
GEMINI_MODEL=gemini-2.0-flash
|
| 173 |
+
|
| 174 |
+
# Ollama Configuration (for local LLM)
|
| 175 |
+
OLLAMA_BASE_URL=http://localhost:11434
|
| 176 |
+
|
| 177 |
+
# Application Settings
|
| 178 |
+
CORS_ORIGINS=http://localhost:3000
|
| 179 |
```
|
| 180 |
|
| 181 |
+
**Getting a Gemini API Key (Optional):**
|
| 182 |
+
1. Go to [Google AI Studio](https://makersuite.google.com/app/apikey)
|
| 183 |
+
2. Create a new API key
|
| 184 |
+
3. Add it to your `.env` file
|
| 185 |
+
|
| 186 |
+
5. **Start the backend server:**
|
| 187 |
```bash
|
| 188 |
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
| 189 |
```
|
| 190 |
|
| 191 |
The API will be available at `http://localhost:8000` with interactive docs at `http://localhost:8000/docs`
|
| 192 |
|
| 193 |
+
### Step 5: Frontend Setup
|
| 194 |
|
| 195 |
+
1. **Navigate to the frontend directory:**
|
| 196 |
```bash
|
| 197 |
+
cd ../phd-advisor-frontend
|
| 198 |
```
|
| 199 |
|
| 200 |
+
2. **Install dependencies:**
|
| 201 |
```bash
|
| 202 |
npm install
|
| 203 |
```
|
| 204 |
|
| 205 |
+
3. **Start the development server:**
|
| 206 |
```bash
|
| 207 |
npm start
|
| 208 |
```
|
| 209 |
|
| 210 |
The application will open at `http://localhost:3000`
|
| 211 |
|
| 212 |
+
## Quick Start Guide
|
| 213 |
|
| 214 |
+
### First Time Setup Checklist
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
+
1. MongoDB is running (check with `mongosh` or MongoDB Compass)
|
| 217 |
+
2. Ollama is running with models downloaded (`ollama list`)
|
| 218 |
+
3. Backend is running on port 8000
|
| 219 |
+
4. Frontend is running on port 3000
|
| 220 |
+
5. Create your first user account
|
| 221 |
|
| 222 |
+
### Basic Usage
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
+
1. **Create an Account:**
|
| 225 |
+
- Open `http://localhost:3000`
|
| 226 |
+
- Click "Sign Up"
|
| 227 |
+
- Fill in your details
|
| 228 |
|
| 229 |
+
2. **Start Your First Chat:**
|
| 230 |
+
- Click "New Chat"
|
| 231 |
+
- Ask a question like "I need help with my research methodology"
|
| 232 |
+
- Get responses from multiple advisor personas
|
| 233 |
|
| 234 |
+
3. **Upload Documents:**
|
| 235 |
+
- Click the upload button in the chat
|
| 236 |
+
- Upload a PDF, DOCX, or TXT file
|
| 237 |
+
- Ask questions about your document
|
| 238 |
|
| 239 |
+
4. **Manage Chats:**
|
| 240 |
+
- Save important conversations
|
| 241 |
+
- Switch between different chat sessions
|
| 242 |
+
- Export chats in various formats
|
| 243 |
|
| 244 |
+
## 🔧 Configuration
|
|
|
|
|
|
|
| 245 |
|
| 246 |
+
### Environment Variables Reference
|
| 247 |
|
| 248 |
+
| Variable | Description | Default | Required |
|
| 249 |
+
|----------|-------------|---------|----------|
|
| 250 |
+
| `MONGODB_CONNECTION_STRING` | MongoDB connection URL | `mongodb://localhost:27017` | Yes |
|
| 251 |
+
| `MONGODB_DATABASE_NAME` | Database name | `phd_advisor` | Yes |
|
| 252 |
+
| `JWT_SECRET_KEY` | Secret key for JWT tokens | - | Yes |
|
| 253 |
+
| `GEMINI_API_KEY` | Google Gemini API key | - | No |
|
| 254 |
+
| `GEMINI_MODEL` | Gemini model to use | `gemini-2.0-flash` | No |
|
| 255 |
+
| `OLLAMA_BASE_URL` | Ollama server URL | `http://localhost:11434` | No |
|
| 256 |
|
| 257 |
+
### Switching Between LLM Providers
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
+
The application supports two LLM providers:
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
+
1. **Ollama (Local, Free):**
|
| 262 |
+
- Ensure Ollama is running
|
| 263 |
+
- Models run locally on your machine
|
| 264 |
+
- No API costs, complete privacy
|
| 265 |
|
| 266 |
+
2. **Gemini (Cloud, Paid):**
|
| 267 |
+
- Requires API key
|
| 268 |
+
- Higher quality responses
|
| 269 |
+
- Faster response times
|
| 270 |
|
| 271 |
+
Switch providers using the API:
|
| 272 |
+
```bash
|
| 273 |
+
curl -X POST "http://localhost:8000/switch-provider" \
|
| 274 |
+
-H "Content-Type: application/json" \
|
| 275 |
+
-d '{"provider": "ollama"}'
|
| 276 |
```
|
| 277 |
|
| 278 |
+
## API Documentation
|
| 279 |
|
| 280 |
+
### Authentication Endpoints
|
| 281 |
+
- `POST /auth/signup` - Create new user account
|
| 282 |
+
- `POST /auth/login` - Login with email/password
|
| 283 |
+
- `GET /auth/me` - Get current user profile
|
| 284 |
+
|
| 285 |
+
### Chat Endpoints
|
| 286 |
+
- `POST /chat-sequential` - Get responses from all advisors
|
| 287 |
+
- `POST /chat/{persona_id}` - Chat with specific advisor
|
| 288 |
+
- `POST /reply-to-advisor` - Reply to specific advisor message
|
| 289 |
+
|
| 290 |
+
### Document Management
|
| 291 |
+
- `POST /upload-document` - Upload PDF, DOCX, or TXT files
|
| 292 |
+
- `GET /uploaded-files` - List uploaded files
|
| 293 |
+
- `GET /document-stats` - Get document statistics
|
| 294 |
|
| 295 |
+
### Session Management
|
| 296 |
+
- `GET /context` - Get current session context
|
| 297 |
+
- `POST /reset-session` - Reset current session
|
| 298 |
+
- `GET /session-stats` - Get session statistics
|
| 299 |
+
|
| 300 |
+
### Export & Summary
|
| 301 |
+
- `GET /export-chat` - Export chat (txt, pdf, docx)
|
| 302 |
+
- `GET /chat-summary` - Generate chat summary
|
| 303 |
+
|
| 304 |
+
Full API documentation is available at `http://localhost:8000/docs` when the server is running.
|
| 305 |
+
|
| 306 |
+
## Troubleshooting
|
| 307 |
+
|
| 308 |
+
### Common Issues
|
| 309 |
+
|
| 310 |
+
**Backend won't start:**
|
| 311 |
+
```bash
|
| 312 |
+
# Check if port 8000 is already in use
|
| 313 |
+
netstat -an | grep :8000
|
| 314 |
+
|
| 315 |
+
# Check Python virtual environment is activated
|
| 316 |
+
which python # Should point to your venv
|
| 317 |
+
|
| 318 |
+
# Check all dependencies are installed
|
| 319 |
+
pip list
|
| 320 |
```
|
| 321 |
|
| 322 |
+
**MongoDB connection issues:**
|
| 323 |
+
```bash
|
| 324 |
+
# Test MongoDB connection
|
| 325 |
+
mongosh
|
| 326 |
+
|
| 327 |
+
# Check if MongoDB service is running
|
| 328 |
+
# Windows: Check Services app
|
| 329 |
+
# macOS: brew services list | grep mongodb
|
| 330 |
+
# Linux: systemctl status mongod
|
| 331 |
+
```
|
| 332 |
|
| 333 |
+
**Ollama not working:**
|
|
|
|
| 334 |
```bash
|
| 335 |
+
# Check if Ollama is running
|
| 336 |
+
curl http://localhost:11434/api/tags
|
| 337 |
+
|
| 338 |
+
# Check downloaded models
|
| 339 |
+
ollama list
|
| 340 |
+
|
| 341 |
+
# Test model directly
|
| 342 |
+
ollama run llama3.2:1b "Hello"
|
| 343 |
```
|
| 344 |
|
| 345 |
+
**Frontend won't connect to backend:**
|
| 346 |
+
- Verify backend is running on port 8000
|
| 347 |
+
- Check CORS settings in backend `.env`
|
| 348 |
+
- Check browser developer console for errors
|
| 349 |
+
|
| 350 |
+
### Performance Tips
|
| 351 |
+
|
| 352 |
+
1. **For faster local LLM responses:**
|
| 353 |
+
- Use smaller models like `llama3.2:1b` for development
|
| 354 |
+
- Ensure sufficient RAM (8GB+ recommended)
|
| 355 |
+
- Use SSD storage for better model loading
|
| 356 |
|
| 357 |
+
2. **For better document search:**
|
| 358 |
+
- Upload focused, relevant documents
|
| 359 |
+
- Use clear, descriptive filenames
|
| 360 |
+
- Break large documents into smaller sections
|
| 361 |
+
|
| 362 |
+
3. **For production deployment:**
|
| 363 |
+
- Use larger, more capable models
|
| 364 |
+
- Consider GPU acceleration for Ollama
|
| 365 |
+
- Use MongoDB Atlas for cloud database
|
| 366 |
+
- Set up proper authentication and HTTPS
|
| 367 |
+
|
| 368 |
+
## Development
|
| 369 |
|
| 370 |
+
### Running Tests
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
|
|
|
| 372 |
```bash
|
| 373 |
+
# Backend tests
|
| 374 |
+
cd multi_llm_chatbot_backend
|
| 375 |
+
python -m pytest app/tests/
|
| 376 |
+
|
| 377 |
+
# Test specific functionality
|
| 378 |
+
python app/tests/test_rag_system.py
|
| 379 |
+
python app/tests/debug_rag.py
|
| 380 |
+
```
|
| 381 |
+
|
| 382 |
+
### Project Structure
|
| 383 |
+
|
| 384 |
```
|
| 385 |
+
phd-advisor-panel/
|
| 386 |
+
├── multi_llm_chatbot_backend/
|
| 387 |
+
│ ├── app/
|
| 388 |
+
│ │ ├── api/routes/ # API route handlers
|
| 389 |
+
│ │ ├── core/ # Core business logic
|
| 390 |
+
│ │ ├── llm/ # LLM client implementations
|
| 391 |
+
│ │ ├── models/ # Data models and schemas
|
| 392 |
+
│ │ ├── utils/ # Utility functions
|
| 393 |
+
│ │ └── tests/ # Test files
|
| 394 |
+
│ ├── requirements.txt
|
| 395 |
+
│ └── .env
|
| 396 |
+
├── phd-advisor-frontend/
|
| 397 |
+
│ ├── src/
|
| 398 |
+
│ │ ├── components/ # React components
|
| 399 |
+
│ │ ├── pages/ # Page components
|
| 400 |
+
│ │ ├── styles/ # CSS files
|
| 401 |
+
│ │ └── utils/ # Frontend utilities
|
| 402 |
+
│ ├── package.json
|
| 403 |
+
│ └── public/
|
| 404 |
+
└── README.md
|
| 405 |
+
```
|
| 406 |
+
|
| 407 |
+
### Adding New Advisor Personas
|
| 408 |
+
|
| 409 |
+
1. Edit `app/models/default_personas.py`
|
| 410 |
+
2. Add your persona configuration
|
| 411 |
+
3. Restart the backend server
|
| 412 |
+
4. The new persona will be available in chat
|
| 413 |
+
|
| 414 |
+
### Extending Document Support
|
| 415 |
+
|
| 416 |
+
1. Add new file type to `app/utils/document_extractor.py`
|
| 417 |
+
2. Update the upload endpoint in `app/api/routes/documents.py`
|
| 418 |
+
3. Test with sample files
|
| 419 |
+
|
| 420 |
|
| 421 |
## Contributing
|
| 422 |
|
|
|
|
| 426 |
4. Push to the branch (`git push origin feature/amazing-feature`)
|
| 427 |
5. Open a Pull Request
|
| 428 |
|
|
|
|
| 429 |
## Support
|
| 430 |
|
| 431 |
+
- Check the [API Documentation](http://localhost:8000/docs)
|
| 432 |
+
- Report bugs by opening an issue
|
| 433 |
+
- Request features by opening an issue
|
| 434 |
+
- Contact the development team
|
| 435 |
+
|
| 436 |
+
## Acknowledgments
|
| 437 |
+
|
| 438 |
+
- Built with [FastAPI](https://fastapi.tiangolo.com/) and [React](https://reactjs.org/)
|
| 439 |
+
- Powered by [Ollama](https://ollama.ai/) for local LLM support
|
| 440 |
+
- Uses [ChromaDB](https://www.trychroma.com/) for vector storage
|
| 441 |
+
- Document processing with [PyPDF2](https://pypdf2.readthedocs.io/) and [python-docx](https://python-docx.readthedocs.io/)
|