@lebiraja/plugintool 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1258 -0
- package/dist/App.d.ts +2 -0
- package/dist/api/chat.d.ts +17 -0
- package/dist/api/client.d.ts +2 -0
- package/dist/api/files.d.ts +10 -0
- package/dist/api/models.d.ts +4 -0
- package/dist/api/sessions.d.ts +75 -0
- package/dist/api/tools.d.ts +3 -0
- package/dist/components/ChatInterface.d.ts +6 -0
- package/dist/components/FileCard.d.ts +10 -0
- package/dist/components/LeftSidebar.d.ts +5 -0
- package/dist/components/MessageList.d.ts +7 -0
- package/dist/components/RightSidebar.d.ts +7 -0
- package/dist/components/SessionSidebar.d.ts +10 -0
- package/dist/components/SettingsModal.d.ts +6 -0
- package/dist/components/UnifiedChatInterface.d.ts +9 -0
- package/dist/components/common/BackendStatusBanner.d.ts +1 -0
- package/dist/components/common/ErrorBoundary.d.ts +18 -0
- package/dist/components/common/MarkdownRenderer.d.ts +7 -0
- package/dist/components/research/DeepResearchPanel.d.ts +2 -0
- package/dist/components/research/ResearchResultsView.d.ts +7 -0
- package/dist/hooks/useBackendStatus.d.ts +11 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +22703 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/services/deepResearchService.d.ts +36 -0
- package/dist/store/chatStore.d.ts +17 -0
- package/dist/store/deepResearchStore.d.ts +18 -0
- package/dist/store/fileStore.d.ts +12 -0
- package/dist/store/sessionStore.d.ts +32 -0
- package/dist/store/settingsStore.d.ts +24 -0
- package/dist/types/index.d.ts +170 -0
- package/package.json +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,1258 @@
|
|
|
1
|
+
# Local LLM Chat Interface π€β¨
|
|
2
|
+
|
|
3
|
+
A modern, feature-rich chat interface for interacting with local LLM backends like Ollama and LM Studio. Built with React, TypeScript, and FastAPI, featuring **persistent chat sessions**, MongoDB storage, RAG (Retrieval-Augmented Generation), web search, and a beautiful animated UI.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## β¨ What This App Does
|
|
12
|
+
|
|
13
|
+
This is an intelligent chat application that lets you interact with powerful local AI models (like Llama, Gemma, Qwen) running on your own machine. Think ChatGPT, but **completely private, customizable, and running locally**.
|
|
14
|
+
|
|
15
|
+
### Key Capabilities:
|
|
16
|
+
|
|
17
|
+
- π¬ **Persistent Chat Sessions** - ChatGPT-style interface with session management and smart auto-titles
|
|
18
|
+
- π **Knowledge Base (RAG)** - Upload documents (PDF, DOCX, TXT) and ask questions with MongoDB persistence
|
|
19
|
+
- π **Web Search** - Get real-time information from the internet with citations
|
|
20
|
+
- π¨ **Beautiful UI** - Smooth animations, gradient effects, file cards, and modern design
|
|
21
|
+
- π§ **Full Control** - Choose your AI model, toggle tools on/off, manage files per session
|
|
22
|
+
- π **100% Private** - Everything runs locally on your machine with MongoDB for data storage
|
|
23
|
+
|
|
24
|
+
## π Features
|
|
25
|
+
|
|
26
|
+
### πΎ Persistent Chat Sessions (NEW!)
|
|
27
|
+
|
|
28
|
+
- **ChatGPT-Style Interface** - Sidebar with session history organized by time (Today, Yesterday, This Week, Older)
|
|
29
|
+
- **Smart Auto-Titles** - AI generates 3-4 word titles after first exchange based on conversation context
|
|
30
|
+
- **MongoDB Storage** - All conversations, messages, and files persist across sessions
|
|
31
|
+
- **Session Management** - Create, view, delete sessions with full conversation history
|
|
32
|
+
- **Session-Based File Uploads** - Files are linked to specific chat sessions with metadata tracking
|
|
33
|
+
|
|
34
|
+
### π€ Multi-Backend LLM Support
|
|
35
|
+
|
|
36
|
+
- **Ollama** - Run models like Llama, Gemma, Qwen, DeepSeek locally
|
|
37
|
+
- **LM Studio** - Desktop LLM interface with OpenAI-compatible API
|
|
38
|
+
- **Dynamic Model Selection** - Interactive dropdowns to switch backends and models
|
|
39
|
+
- **Auto-Discovery** - Automatically detects available models from your LLM backend
|
|
40
|
+
- **Unified Sidebar** - Backend selector, model selector, and tools all in one place
|
|
41
|
+
|
|
42
|
+
### π§ Advanced Conversation Memory
|
|
43
|
+
|
|
44
|
+
- **Full Session History** - Remembers entire conversation within a session
|
|
45
|
+
- **Intelligent Context** - Uses last 10 messages for AI context
|
|
46
|
+
- **Message Persistence** - All messages stored in MongoDB with timestamps
|
|
47
|
+
- **Smart Title Generation** - Asynchronous title generation using LLM after first exchange
|
|
48
|
+
|
|
49
|
+
### π οΈ Powerful Tools (Toggle On/Off)
|
|
50
|
+
|
|
51
|
+
- π **Web Search** - Powered by Serper.dev (Google search API)
|
|
52
|
+
- π **RAG (Document Q&A)** - Ask questions about uploaded documents with persistent storage
|
|
53
|
+
- π§ͺ **Deep Research** - Multi-step iterative reasoning
|
|
54
|
+
- π **Real-time Stats** - Token counting and latency tracking
|
|
55
|
+
|
|
56
|
+
### π Enhanced Knowledge Base Management (NEW!)
|
|
57
|
+
|
|
58
|
+
- **File Cards Display** - ChatGPT-style file cards showing uploaded documents in chat
|
|
59
|
+
- **MongoDB Persistence** - File chunks and embeddings stored in MongoDB for permanent access
|
|
60
|
+
- **Session-Specific Files** - Each session maintains its own file collection
|
|
61
|
+
- **File Metadata** - Track filename, size, upload time, embedding status, and chunk count
|
|
62
|
+
- **Automatic Processing** - Files are chunked, embedded, and stored automatically on upload
|
|
63
|
+
- **Multi-Format Support** - PDF, DOCX, TXT with intelligent text extraction
|
|
64
|
+
- **Vector Search** - Semantic search across uploaded documents using embeddings
|
|
65
|
+
|
|
66
|
+
### π¨ Modern UI/UX
|
|
67
|
+
|
|
68
|
+
- β¨ **Spring Animations** - Smooth Framer Motion physics
|
|
69
|
+
- π **Gradient Backgrounds** - Dynamic color schemes for messages
|
|
70
|
+
- π **Glassmorphism Effects** - Frosted glass aesthetics
|
|
71
|
+
- π **File Cards** - Visual display of uploaded files with icons, size, and chunk info
|
|
72
|
+
- π **Loading Indicators** - Shows KB search, web search, and generation status
|
|
73
|
+
- π± **Responsive Design** - Works on desktop and mobile
|
|
74
|
+
- π **Time-Based Grouping** - Sessions organized by Today, Yesterday, This Week, Older
|
|
75
|
+
|
|
76
|
+
## π Quick Start
|
|
77
|
+
|
|
78
|
+
### π― Automated Setup (Recommended!)
|
|
79
|
+
|
|
80
|
+
We provide **automated setup scripts** for all platforms that install everything and launch the app automatically:
|
|
81
|
+
|
|
82
|
+
#### **Windows (Batch Script)**
|
|
83
|
+
|
|
84
|
+
```cmd
|
|
85
|
+
setup-and-run.bat
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- Double-click `setup-and-run.bat` or run in Command Prompt
|
|
89
|
+
- Automatically installs: MongoDB, Node.js, Python 3.11, Ollama
|
|
90
|
+
- Sets up backend and frontend dependencies
|
|
91
|
+
- Launches all services in separate windows
|
|
92
|
+
|
|
93
|
+
#### **Windows/Linux/macOS (PowerShell)**
|
|
94
|
+
|
|
95
|
+
```powershell
|
|
96
|
+
pwsh setup-and-run.ps1
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- Cross-platform PowerShell script
|
|
100
|
+
- Works on Windows, Linux, macOS
|
|
101
|
+
- Same functionality as batch script
|
|
102
|
+
- Requires PowerShell 7+ (pre-installed on Windows 10+)
|
|
103
|
+
|
|
104
|
+
#### **Linux/macOS (Bash Script)**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
chmod +x setup-and-run.sh
|
|
108
|
+
./setup-and-run.sh
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Native bash script for Unix systems
|
|
112
|
+
- Automatically detects Ubuntu/Debian/CentOS/macOS
|
|
113
|
+
- Uses system package managers (apt, yum, brew)
|
|
114
|
+
- Starts all services automatically
|
|
115
|
+
|
|
116
|
+
**What the scripts do:**
|
|
117
|
+
|
|
118
|
+
1. β
Check if MongoDB, Node.js, Python, Ollama are installed
|
|
119
|
+
2. β
Install missing prerequisites automatically
|
|
120
|
+
3. β
Create Python virtual environment
|
|
121
|
+
4. β
Install all dependencies (pip, npm)
|
|
122
|
+
5. β
Create `.env` from example if missing
|
|
123
|
+
6. β
Start MongoDB service
|
|
124
|
+
7. β
Start Ollama service
|
|
125
|
+
8. β
Pull default model (gemma2:2b)
|
|
126
|
+
9. β
Launch backend (FastAPI) in new terminal
|
|
127
|
+
10. β
Launch frontend (Vite) in new terminal
|
|
128
|
+
11. β
Log everything to `logs/` directory
|
|
129
|
+
|
|
130
|
+
**After running:** Just wait ~30 seconds and open http://localhost:5173
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### Manual Setup (If you prefer step-by-step)
|
|
135
|
+
|
|
136
|
+
If you prefer to install everything manually, follow the detailed instructions below.
|
|
137
|
+
|
|
138
|
+
### Prerequisites
|
|
139
|
+
|
|
140
|
+
Before you begin, make sure you have:
|
|
141
|
+
|
|
142
|
+
1. **Node.js 18+** - [Download here](https://nodejs.org/)
|
|
143
|
+
2. **Python 3.11+** - [Download here](https://www.python.org/downloads/)
|
|
144
|
+
3. **MongoDB 7.0+** - [Download here](https://www.mongodb.com/try/download/community)
|
|
145
|
+
- Or use **MongoDB Atlas** (free cloud tier) - [Sign up here](https://www.mongodb.com/cloud/atlas/register)
|
|
146
|
+
4. **Ollama** (recommended) - [Download here](https://ollama.ai/)
|
|
147
|
+
- Or **LM Studio** - [Download here](https://lmstudio.ai/)
|
|
148
|
+
5. **Git** - [Download here](https://git-scm.com/)
|
|
149
|
+
|
|
150
|
+
### MongoDB Setup
|
|
151
|
+
|
|
152
|
+
#### Option 1: Local MongoDB (Recommended for Development)
|
|
153
|
+
|
|
154
|
+
**Windows:**
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Download MongoDB Community Server from mongodb.com
|
|
158
|
+
# Install with default settings
|
|
159
|
+
# MongoDB will run as a Windows service automatically
|
|
160
|
+
|
|
161
|
+
# Verify it's running
|
|
162
|
+
mongosh
|
|
163
|
+
# You should see: "Connected to: mongodb://127.0.0.1:27017"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**macOS (using Homebrew):**
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Install MongoDB
|
|
170
|
+
brew tap mongodb/brew
|
|
171
|
+
brew install mongodb-community@7.0
|
|
172
|
+
|
|
173
|
+
# Start MongoDB service
|
|
174
|
+
brew services start mongodb-community@7.0
|
|
175
|
+
|
|
176
|
+
# Verify it's running
|
|
177
|
+
mongosh
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Linux (Ubuntu/Debian):**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Import MongoDB public key
|
|
184
|
+
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
|
|
185
|
+
|
|
186
|
+
# Add MongoDB repository
|
|
187
|
+
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
|
|
188
|
+
|
|
189
|
+
# Install MongoDB
|
|
190
|
+
sudo apt-get update
|
|
191
|
+
sudo apt-get install -y mongodb-org
|
|
192
|
+
|
|
193
|
+
# Start MongoDB service
|
|
194
|
+
sudo systemctl start mongod
|
|
195
|
+
sudo systemctl enable mongod
|
|
196
|
+
|
|
197
|
+
# Verify it's running
|
|
198
|
+
mongosh
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### Option 2: MongoDB Atlas (Cloud - Free Tier)
|
|
202
|
+
|
|
203
|
+
1. **Sign up** at [mongodb.com/cloud/atlas/register](https://www.mongodb.com/cloud/atlas/register)
|
|
204
|
+
2. **Create a free cluster** (M0 tier - no credit card required)
|
|
205
|
+
3. **Create a database user** with read/write permissions
|
|
206
|
+
4. **Whitelist your IP** or use `0.0.0.0/0` for development
|
|
207
|
+
5. **Get connection string** from "Connect" β "Connect your application"
|
|
208
|
+
6. **Copy the connection string** (looks like: `mongodb+srv://user:password@cluster.mongodb.net/`)
|
|
209
|
+
|
|
210
|
+
#### Verify MongoDB Installation
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Test local MongoDB connection
|
|
214
|
+
mongosh
|
|
215
|
+
|
|
216
|
+
# Or test with connection string
|
|
217
|
+
mongosh "mongodb://127.0.0.1:27017"
|
|
218
|
+
|
|
219
|
+
# Should see:
|
|
220
|
+
# Current Mongosh Log ID: ...
|
|
221
|
+
# Connecting to: mongodb://127.0.0.1:27017
|
|
222
|
+
# Using MongoDB: 7.0.x
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Installation
|
|
226
|
+
|
|
227
|
+
#### 1. Clone the Repository
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
git clone https://github.com/lebiraja/plugin.git
|
|
231
|
+
cd plugin
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### 2. Set Up the Backend
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Navigate to backend folder
|
|
238
|
+
cd backend
|
|
239
|
+
|
|
240
|
+
# Create a virtual environment
|
|
241
|
+
python -m venv venv
|
|
242
|
+
|
|
243
|
+
# Activate virtual environment
|
|
244
|
+
# On Windows:
|
|
245
|
+
.\venv\Scripts\activate
|
|
246
|
+
# On macOS/Linux:
|
|
247
|
+
source venv/bin/activate
|
|
248
|
+
|
|
249
|
+
# Install dependencies (using uv for faster installs, or use pip)
|
|
250
|
+
pip install uv
|
|
251
|
+
uv pip install -r requirements.txt
|
|
252
|
+
|
|
253
|
+
# Or with regular pip:
|
|
254
|
+
pip install -r requirements.txt
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### 3. Configure Environment Variables
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Copy the example .env file
|
|
261
|
+
cp .env.example .env
|
|
262
|
+
|
|
263
|
+
# Edit .env and configure MongoDB and other settings
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Your `backend/.env` should look like:
|
|
267
|
+
|
|
268
|
+
```env
|
|
269
|
+
# MongoDB Configuration
|
|
270
|
+
MONGODB_URL=mongodb://127.0.0.1:27017 # Local MongoDB
|
|
271
|
+
# Or for MongoDB Atlas:
|
|
272
|
+
# MONGODB_URL=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority
|
|
273
|
+
|
|
274
|
+
MONGODB_DB_NAME=chat_app # Database name (will be created automatically)
|
|
275
|
+
|
|
276
|
+
# Backend Configuration
|
|
277
|
+
OLLAMA_URL=http://127.0.0.1:11434
|
|
278
|
+
LMSTUDIO_URL=http://localhost:1234
|
|
279
|
+
|
|
280
|
+
# Web Search API (100 free searches/month)
|
|
281
|
+
SERPER_API_KEY=your_serper_api_key_here
|
|
282
|
+
|
|
283
|
+
# Vector Database (ChromaDB - local storage)
|
|
284
|
+
VECTOR_DB_PATH=./vector_db
|
|
285
|
+
|
|
286
|
+
# File Upload
|
|
287
|
+
UPLOAD_DIR=./uploads
|
|
288
|
+
MAX_FILE_SIZE=10485760 # 10MB in bytes
|
|
289
|
+
|
|
290
|
+
# CORS
|
|
291
|
+
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
292
|
+
|
|
293
|
+
# Server
|
|
294
|
+
HOST=0.0.0.0
|
|
295
|
+
PORT=8000
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Important MongoDB Notes:**
|
|
299
|
+
|
|
300
|
+
- For **local MongoDB**: Use `mongodb://127.0.0.1:27017`
|
|
301
|
+
- For **MongoDB Atlas**: Use your connection string from Atlas dashboard
|
|
302
|
+
- The database (`chat_app`) and collections will be created automatically
|
|
303
|
+
- Indexes are created automatically on first startup
|
|
304
|
+
|
|
305
|
+
#### 4. Set Up the Frontend
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Go back to project root
|
|
309
|
+
cd ..
|
|
310
|
+
|
|
311
|
+
# Install frontend dependencies
|
|
312
|
+
npm install
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### 5. Install and Configure Ollama
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
# Download Ollama from https://ollama.ai/
|
|
319
|
+
|
|
320
|
+
# Pull some models (examples)
|
|
321
|
+
ollama pull gemma2:2b # Small, fast model
|
|
322
|
+
ollama pull llama3.1:8b # Balanced model
|
|
323
|
+
ollama pull qwen2.5-coder:3b # Great for coding
|
|
324
|
+
|
|
325
|
+
# Start Ollama (it usually runs automatically)
|
|
326
|
+
ollama serve
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Running the Application
|
|
330
|
+
|
|
331
|
+
#### Method 1: Separate Terminals (Recommended for Development)
|
|
332
|
+
|
|
333
|
+
**Terminal 1 - Start MongoDB (if using local):**
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# Windows (if not running as service)
|
|
337
|
+
"C:\Program Files\MongoDB\Server\7.0\bin\mongod.exe" --dbpath="C:\data\db"
|
|
338
|
+
|
|
339
|
+
# macOS/Linux (if not running as service)
|
|
340
|
+
sudo systemctl start mongod # Linux
|
|
341
|
+
# or
|
|
342
|
+
brew services start mongodb-community@7.0 # macOS
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Terminal 2 - Backend:**
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
cd backend
|
|
349
|
+
.\venv\Scripts\activate # Windows
|
|
350
|
+
# or
|
|
351
|
+
source venv/bin/activate # macOS/Linux
|
|
352
|
+
|
|
353
|
+
# Start backend server with auto-reload
|
|
354
|
+
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
|
355
|
+
|
|
356
|
+
# You should see:
|
|
357
|
+
# INFO: Connected to MongoDB: chat_app
|
|
358
|
+
# INFO: Application startup complete
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Terminal 3 - Frontend:**
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# From project root
|
|
365
|
+
npm run dev
|
|
366
|
+
|
|
367
|
+
# You should see:
|
|
368
|
+
# VITE v5.4.x ready in xxx ms
|
|
369
|
+
# β Local: http://localhost:5173/
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### Method 2: Production Mode
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Build frontend
|
|
376
|
+
npm run build
|
|
377
|
+
|
|
378
|
+
# Start backend (serves both API and static frontend)
|
|
379
|
+
cd backend
|
|
380
|
+
python main.py
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Access the App
|
|
384
|
+
|
|
385
|
+
Open your browser and go to:
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
http://localhost:5173 # Development mode
|
|
389
|
+
# or
|
|
390
|
+
http://localhost:8000 # Production mode
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## π How to Use
|
|
394
|
+
|
|
395
|
+
### 1. First Time Setup
|
|
396
|
+
|
|
397
|
+
1. **Start MongoDB** - Make sure MongoDB is running (locally or Atlas connection)
|
|
398
|
+
2. **Start Backend** - Run `uvicorn main:app --reload` from `backend/` directory
|
|
399
|
+
3. **Start Frontend** - Run `npm run dev` from project root
|
|
400
|
+
4. **Open the app** - Navigate to `http://localhost:5173`
|
|
401
|
+
5. **Select Backend** - Click backend dropdown in the left sidebar and choose "Ollama" or "LM Studio"
|
|
402
|
+
6. **Choose Model** - Select a model from the model dropdown (auto-populates from your LLM backend)
|
|
403
|
+
7. **Start Chatting!** - Type a message and press Enter
|
|
404
|
+
|
|
405
|
+
### 2. Chat Sessions (ChatGPT-Style)
|
|
406
|
+
|
|
407
|
+
The app now features persistent chat sessions similar to ChatGPT:
|
|
408
|
+
|
|
409
|
+
**Creating Sessions:**
|
|
410
|
+
|
|
411
|
+
- Click **"+ New Chat"** button to start a fresh conversation
|
|
412
|
+
- Each session gets a unique ID and is stored in MongoDB
|
|
413
|
+
- Sessions automatically get smart titles after the first exchange
|
|
414
|
+
|
|
415
|
+
**Session History:**
|
|
416
|
+
|
|
417
|
+
- Left sidebar shows all your chat sessions organized by time:
|
|
418
|
+
- **Today** - Sessions created today
|
|
419
|
+
- **Yesterday** - Sessions from yesterday
|
|
420
|
+
- **This Week** - Sessions from the past 7 days
|
|
421
|
+
- **Older** - Sessions older than a week
|
|
422
|
+
- Click any session to load its full conversation history
|
|
423
|
+
|
|
424
|
+
**Smart Auto-Titles:**
|
|
425
|
+
|
|
426
|
+
- After your first message and AI response, the session automatically gets a 3-4 word title
|
|
427
|
+
- Title is generated by the AI based on the conversation context
|
|
428
|
+
- Example: "Python Programming Help" or "Database Design Questions"
|
|
429
|
+
|
|
430
|
+
**Session Management:**
|
|
431
|
+
|
|
432
|
+
- Hover over a session to see the delete button
|
|
433
|
+
- Delete unwanted sessions (permanently removes from MongoDB)
|
|
434
|
+
- Sessions persist across browser refreshes and app restarts
|
|
435
|
+
|
|
436
|
+
### 3. Using Conversation Memory
|
|
437
|
+
|
|
438
|
+
The app automatically remembers your conversation:
|
|
439
|
+
|
|
440
|
+
```
|
|
441
|
+
You: My name is Alex and I love Python programming.
|
|
442
|
+
AI: Nice to meet you, Alex! Python is a great language...
|
|
443
|
+
|
|
444
|
+
You: What's my name?
|
|
445
|
+
AI: Your name is Alex!
|
|
446
|
+
|
|
447
|
+
You: What language did I mention?
|
|
448
|
+
AI: You mentioned that you love Python programming!
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
- **Full Session History** - All messages in a session are stored in MongoDB
|
|
452
|
+
- **Intelligent Context** - AI uses last 10 messages for generating responses
|
|
453
|
+
- **Persistent Storage** - Conversations survive server restarts and browser refreshes
|
|
454
|
+
|
|
455
|
+
### 4. Toggle Tools On/Off
|
|
456
|
+
|
|
457
|
+
In the left sidebar, click the tool buttons to enable/disable:
|
|
458
|
+
|
|
459
|
+
- **RAG** - For uploaded document Q&A (blue when active)
|
|
460
|
+
- **Web Search** - For current information (blue when active)
|
|
461
|
+
- **Deep Research** - For complex multi-step reasoning (blue when active)
|
|
462
|
+
|
|
463
|
+
Tools are session-specific and persist with your session settings.
|
|
464
|
+
|
|
465
|
+
### 5. Upload and Query Documents (Enhanced with File Cards!)
|
|
466
|
+
|
|
467
|
+
**Upload Files:**
|
|
468
|
+
|
|
469
|
+
1. **Click paperclip icon** π in the chat input area
|
|
470
|
+
2. **Select files** - PDF, DOCX, or TXT (max 10MB per file)
|
|
471
|
+
3. **Files are processed** - Automatically chunked, embedded, and stored in MongoDB
|
|
472
|
+
4. **File cards appear** - See your uploaded files displayed as cards in the chat
|
|
473
|
+
|
|
474
|
+
**File Cards Display:**
|
|
475
|
+
|
|
476
|
+
- Each uploaded file shows as a card with:
|
|
477
|
+
- π **File icon** (color-coded by type)
|
|
478
|
+
- π **Filename**
|
|
479
|
+
- π **File size** (formatted in KB/MB)
|
|
480
|
+
- π§© **Chunk count** (number of text chunks created)
|
|
481
|
+
- Files are organized in a "Knowledge Base" section above the chat input
|
|
482
|
+
|
|
483
|
+
**Query Documents:**
|
|
484
|
+
|
|
485
|
+
1. **Enable RAG** - Click the RAG button in left sidebar (turns blue)
|
|
486
|
+
2. **Ask questions** - "What are the main points in the document?"
|
|
487
|
+
3. **Get contextualized answers** - AI uses relevant chunks from your files
|
|
488
|
+
4. **See sources** - Citations show which file chunks were used
|
|
489
|
+
|
|
490
|
+
**File Persistence:**
|
|
491
|
+
|
|
492
|
+
- Files are linked to specific chat sessions
|
|
493
|
+
- File metadata and embeddings stored in MongoDB
|
|
494
|
+
- Files persist across sessions and app restarts
|
|
495
|
+
- Each session has its own file collection
|
|
496
|
+
|
|
497
|
+
### 6. Web Search
|
|
498
|
+
|
|
499
|
+
1. **Get Serper API Key** - Free 100 searches/month at [serper.dev](https://serper.dev/api-keys)
|
|
500
|
+
2. **Add to .env** - Put key in `backend/.env` as `SERPER_API_KEY`
|
|
501
|
+
3. **Enable Tool** - Click "Web Search" button in left sidebar (turns blue)
|
|
502
|
+
4. **Ask Current Events** - "What's the latest news about AI?"
|
|
503
|
+
5. **See Citations** - Sources shown in right sidebar
|
|
504
|
+
|
|
505
|
+
### 7. View Statistics
|
|
506
|
+
|
|
507
|
+
Right sidebar shows session statistics:
|
|
508
|
+
|
|
509
|
+
- π **Message count** - Total messages in current session
|
|
510
|
+
- π **Token usage** - Estimated tokens used
|
|
511
|
+
- π **Files uploaded** - Number of files in knowledge base
|
|
512
|
+
- π **Context sources** - Citations from RAG/web search
|
|
513
|
+
- π **Session created** - Timestamp of session creation
|
|
514
|
+
|
|
515
|
+
## ποΈ Architecture
|
|
516
|
+
|
|
517
|
+
### Frontend Stack
|
|
518
|
+
|
|
519
|
+
- **React 18.3** - Modern UI library with hooks
|
|
520
|
+
- **TypeScript 5.5** - Type-safe JavaScript
|
|
521
|
+
- **Vite 5.4** - Lightning-fast build tool
|
|
522
|
+
- **Framer Motion 11.5** - Smooth spring animations
|
|
523
|
+
- **Zustand 4.5** - Lightweight state management
|
|
524
|
+
- **Axios** - HTTP client for API calls
|
|
525
|
+
- **React Markdown** - Beautiful markdown rendering with syntax highlighting
|
|
526
|
+
- **React Router** - Session-based routing (`/chat/:sessionId`)
|
|
527
|
+
|
|
528
|
+
### Backend Stack
|
|
529
|
+
|
|
530
|
+
- **FastAPI 0.115** - High-performance async Python API
|
|
531
|
+
- **MongoDB (Motor 3.6)** - Async MongoDB driver for Python
|
|
532
|
+
- **Collections**: `chat_sessions` (sessions & messages), `knowledge_base` (RAG chunks)
|
|
533
|
+
- **Indexes**: Optimized for session_id, file_id, timestamps
|
|
534
|
+
- **ChromaDB 0.5.15** - Vector database for embeddings (local storage)
|
|
535
|
+
- **sentence-transformers 3.0** - nomic-ai/nomic-embed-text-v1.5 (547MB)
|
|
536
|
+
- **httpx 0.27** - Async HTTP client
|
|
537
|
+
- **pypdf, python-docx** - Document processing (PDF, DOCX, TXT)
|
|
538
|
+
- **duckduckgo-search** - Fallback web search
|
|
539
|
+
- **Serper.dev** - Primary web search (Google results)
|
|
540
|
+
|
|
541
|
+
### LLM Integrations
|
|
542
|
+
|
|
543
|
+
- **Ollama API** - Local model serving (127.0.0.1:11434)
|
|
544
|
+
- **LM Studio** - OpenAI-compatible API (localhost:1234)
|
|
545
|
+
- **Custom backends** - Bring your own API
|
|
546
|
+
|
|
547
|
+
### Database Schema
|
|
548
|
+
|
|
549
|
+
**MongoDB Collections:**
|
|
550
|
+
|
|
551
|
+
```javascript
|
|
552
|
+
// chat_sessions collection
|
|
553
|
+
{
|
|
554
|
+
session_id: string (UUID),
|
|
555
|
+
title: string (auto-generated),
|
|
556
|
+
backend: string,
|
|
557
|
+
model: string,
|
|
558
|
+
created_at: datetime,
|
|
559
|
+
updated_at: datetime,
|
|
560
|
+
messages: [
|
|
561
|
+
{
|
|
562
|
+
role: "user" | "assistant",
|
|
563
|
+
content: string,
|
|
564
|
+
timestamp: datetime,
|
|
565
|
+
tokens: number (optional),
|
|
566
|
+
sources: array (optional)
|
|
567
|
+
}
|
|
568
|
+
],
|
|
569
|
+
files: [
|
|
570
|
+
{
|
|
571
|
+
file_id: string (UUID),
|
|
572
|
+
filename: string,
|
|
573
|
+
file_path: string,
|
|
574
|
+
size: number,
|
|
575
|
+
uploaded_at: datetime,
|
|
576
|
+
embedded: boolean,
|
|
577
|
+
chunks: number
|
|
578
|
+
}
|
|
579
|
+
],
|
|
580
|
+
config: {
|
|
581
|
+
temperature: float,
|
|
582
|
+
topP: float,
|
|
583
|
+
maxTokens: int
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// knowledge_base collection
|
|
588
|
+
{
|
|
589
|
+
file_id: string,
|
|
590
|
+
session_id: string,
|
|
591
|
+
chunk_text: string,
|
|
592
|
+
chunk_index: number,
|
|
593
|
+
embedding: array<float>,
|
|
594
|
+
metadata: {
|
|
595
|
+
source: string,
|
|
596
|
+
chunk_index: number,
|
|
597
|
+
total_chunks: number
|
|
598
|
+
},
|
|
599
|
+
created_at: datetime
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
**Indexes:**
|
|
604
|
+
|
|
605
|
+
- `chat_sessions`: session_id, created_at, updated_at
|
|
606
|
+
- `knowledge_base`: file_id, session_id, created_at, compound(session_id + file_id)
|
|
607
|
+
|
|
608
|
+
## π Project Structure
|
|
609
|
+
|
|
610
|
+
```
|
|
611
|
+
plugin/
|
|
612
|
+
βββ src/ # Frontend source
|
|
613
|
+
β βββ components/
|
|
614
|
+
β β βββ ChatInterface.tsx # Main chat with session management & file cards
|
|
615
|
+
β β βββ SessionSidebar.tsx # Unified sidebar (history, backend, model, tools)
|
|
616
|
+
β β βββ RightSidebar.tsx # Stats & session info
|
|
617
|
+
β β βββ MessageList.tsx # Animated message display
|
|
618
|
+
β β βββ FileCard.tsx # File card component (NEW!)
|
|
619
|
+
β β βββ FileUpload.tsx # Drag & drop file upload
|
|
620
|
+
β βββ store/
|
|
621
|
+
β β βββ chatStore.ts # Conversation state
|
|
622
|
+
β β βββ settingsStore.ts # App configuration
|
|
623
|
+
β βββ api/
|
|
624
|
+
β β βββ chat.ts # Chat API (legacy)
|
|
625
|
+
β β βββ sessions.ts # Session management API (NEW!)
|
|
626
|
+
β β βββ models.ts # Model fetching
|
|
627
|
+
β β βββ files.ts # File upload/delete
|
|
628
|
+
β βββ index.css # Global styles & animations
|
|
629
|
+
βββ backend/
|
|
630
|
+
β βββ routers/
|
|
631
|
+
β β βββ sessions.py # Session CRUD & messaging (NEW!)
|
|
632
|
+
β β βββ chat.py # Legacy chat endpoint
|
|
633
|
+
β β βββ models.py # Model listing (Ollama/LM Studio)
|
|
634
|
+
β β βββ files.py # File upload/delete/list
|
|
635
|
+
β β βββ tools.py # RAG & web search endpoints
|
|
636
|
+
β βββ services/
|
|
637
|
+
β β βββ session_service.py # Session business logic (NEW!)
|
|
638
|
+
β β βββ database_service.py # MongoDB connection & schema (NEW!)
|
|
639
|
+
β β βββ llm_service.py # LLM backend abstraction with memory
|
|
640
|
+
β β βββ search_service.py # Serper.dev + DuckDuckGo fallback
|
|
641
|
+
β β βββ rag_service.py # Vector search & MongoDB storage (UPDATED!)
|
|
642
|
+
β β βββ document_processor.py # File parsing & embedding
|
|
643
|
+
β βββ main.py # FastAPI app with CORS & MongoDB startup
|
|
644
|
+
β βββ requirements.txt # Python dependencies
|
|
645
|
+
β βββ .env.example # Environment template
|
|
646
|
+
β βββ .env # Your config (not committed)
|
|
647
|
+
βββ public/ # Static assets
|
|
648
|
+
βββ package.json # Node dependencies
|
|
649
|
+
βββ README.md # This file
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
## βοΈ Configuration Files
|
|
653
|
+
|
|
654
|
+
### Backend `.env` Configuration
|
|
655
|
+
|
|
656
|
+
Located in `backend/.env` (create from `.env.example`):
|
|
657
|
+
|
|
658
|
+
```env
|
|
659
|
+
# MongoDB Configuration (Required)
|
|
660
|
+
MONGODB_URL=mongodb://127.0.0.1:27017
|
|
661
|
+
# For MongoDB Atlas cloud:
|
|
662
|
+
# MONGODB_URL=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority
|
|
663
|
+
|
|
664
|
+
MONGODB_DB_NAME=chat_app # Database name (auto-created)
|
|
665
|
+
|
|
666
|
+
# LLM Backend URLs
|
|
667
|
+
OLLAMA_URL=http://127.0.0.1:11434
|
|
668
|
+
LMSTUDIO_URL=http://localhost:1234
|
|
669
|
+
|
|
670
|
+
# Web Search API (Required for web search tool)
|
|
671
|
+
# Get free key at: https://serper.dev/api-keys
|
|
672
|
+
SERPER_API_KEY=your_serper_api_key_here
|
|
673
|
+
|
|
674
|
+
# Vector Database (ChromaDB - local file storage)
|
|
675
|
+
VECTOR_DB_PATH=./vector_db
|
|
676
|
+
|
|
677
|
+
# File Upload
|
|
678
|
+
UPLOAD_DIR=./uploads
|
|
679
|
+
MAX_FILE_SIZE=10485760 # 10MB in bytes
|
|
680
|
+
|
|
681
|
+
# CORS (frontend URLs)
|
|
682
|
+
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
683
|
+
|
|
684
|
+
# Server
|
|
685
|
+
HOST=0.0.0.0
|
|
686
|
+
PORT=8000
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### Frontend Configuration
|
|
690
|
+
|
|
691
|
+
All settings are now stored in MongoDB per session:
|
|
692
|
+
|
|
693
|
+
- Selected backend and model (per session)
|
|
694
|
+
- Tool toggles (RAG, web search, deep research)
|
|
695
|
+
- Conversation history (messages array)
|
|
696
|
+
- File list (session-specific files)
|
|
697
|
+
- Session metadata (title, timestamps)
|
|
698
|
+
|
|
699
|
+
To reset: Delete sessions via UI or MongoDB directly
|
|
700
|
+
|
|
701
|
+
## π§ Advanced Usage
|
|
702
|
+
|
|
703
|
+
### API Endpoints
|
|
704
|
+
|
|
705
|
+
The backend exposes a RESTful API for session management:
|
|
706
|
+
|
|
707
|
+
#### Session Endpoints
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
# Create new session
|
|
711
|
+
POST /api/sessions
|
|
712
|
+
Body: {
|
|
713
|
+
"backend": "ollama",
|
|
714
|
+
"model": "gemma2:2b",
|
|
715
|
+
"config": {
|
|
716
|
+
"temperature": 0.7,
|
|
717
|
+
"topP": 0.9,
|
|
718
|
+
"maxTokens": 2048
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
# Get all sessions (with time grouping)
|
|
723
|
+
GET /api/sessions
|
|
724
|
+
|
|
725
|
+
# Get specific session
|
|
726
|
+
GET /api/sessions/{session_id}
|
|
727
|
+
|
|
728
|
+
# Delete session (removes all messages and files)
|
|
729
|
+
DELETE /api/sessions/{session_id}
|
|
730
|
+
|
|
731
|
+
# Send message to session
|
|
732
|
+
POST /api/sessions/{session_id}/message
|
|
733
|
+
Body: {
|
|
734
|
+
"message": "Hello, how are you?",
|
|
735
|
+
"config": { ... } # Optional
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
# Upload file to session
|
|
739
|
+
POST /api/sessions/{session_id}/upload
|
|
740
|
+
Body: multipart/form-data with file
|
|
741
|
+
|
|
742
|
+
# Get session files
|
|
743
|
+
GET /api/sessions/{session_id}/files
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
#### Model Endpoints
|
|
747
|
+
|
|
748
|
+
```bash
|
|
749
|
+
# List Ollama models
|
|
750
|
+
GET /api/models/ollama
|
|
751
|
+
|
|
752
|
+
# List LM Studio models
|
|
753
|
+
GET /api/models/lmstudio
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
### MongoDB Collections
|
|
757
|
+
|
|
758
|
+
**Accessing data directly:**
|
|
759
|
+
|
|
760
|
+
```javascript
|
|
761
|
+
// Connect to MongoDB
|
|
762
|
+
mongosh "mongodb://127.0.0.1:27017"
|
|
763
|
+
|
|
764
|
+
// Switch to chat database
|
|
765
|
+
use chat_app
|
|
766
|
+
|
|
767
|
+
// List all sessions
|
|
768
|
+
db.chat_sessions.find({})
|
|
769
|
+
|
|
770
|
+
// Find session by ID
|
|
771
|
+
db.chat_sessions.findOne({session_id: "your-session-id"})
|
|
772
|
+
|
|
773
|
+
// Count total messages across all sessions
|
|
774
|
+
db.chat_sessions.aggregate([
|
|
775
|
+
{$unwind: "$messages"},
|
|
776
|
+
{$count: "total_messages"}
|
|
777
|
+
])
|
|
778
|
+
|
|
779
|
+
// Find sessions created today
|
|
780
|
+
db.chat_sessions.find({
|
|
781
|
+
created_at: {
|
|
782
|
+
$gte: new Date(new Date().setHours(0,0,0,0))
|
|
783
|
+
}
|
|
784
|
+
})
|
|
785
|
+
|
|
786
|
+
// Get all file chunks for a session
|
|
787
|
+
db.knowledge_base.find({session_id: "your-session-id"})
|
|
788
|
+
|
|
789
|
+
// Count total chunks
|
|
790
|
+
db.knowledge_base.countDocuments()
|
|
791
|
+
|
|
792
|
+
// Delete old sessions (older than 30 days)
|
|
793
|
+
db.chat_sessions.deleteMany({
|
|
794
|
+
created_at: {
|
|
795
|
+
$lt: new Date(Date.now() - 30*24*60*60*1000)
|
|
796
|
+
}
|
|
797
|
+
})
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
### Custom Model Parameters
|
|
801
|
+
|
|
802
|
+
Models use these default parameters (can be modified per message):
|
|
803
|
+
|
|
804
|
+
```typescript
|
|
805
|
+
{
|
|
806
|
+
temperature: 0.7, // Creativity (0.0 = focused, 1.0 = creative)
|
|
807
|
+
topP: 0.9, // Nucleus sampling
|
|
808
|
+
maxTokens: 2048, // Maximum response length
|
|
809
|
+
frequencyPenalty: 0.0, // Reduce repetition
|
|
810
|
+
presencePenalty: 0.0 // Encourage new topics
|
|
811
|
+
}
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
### Adding More Backends
|
|
815
|
+
|
|
816
|
+
Edit `src/store/settingsStore.ts`:
|
|
817
|
+
|
|
818
|
+
```typescript
|
|
819
|
+
backends: [
|
|
820
|
+
{
|
|
821
|
+
id: "ollama",
|
|
822
|
+
name: "Ollama",
|
|
823
|
+
url: "http://127.0.0.1:11434",
|
|
824
|
+
type: "ollama",
|
|
825
|
+
isActive: true,
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
id: "custom",
|
|
829
|
+
name: "My Custom Backend",
|
|
830
|
+
url: "https://my-api.example.com",
|
|
831
|
+
type: "openai", // Use OpenAI-compatible format
|
|
832
|
+
apiKey: "optional-key",
|
|
833
|
+
isActive: true,
|
|
834
|
+
},
|
|
835
|
+
];
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
### Customizing Embeddings
|
|
839
|
+
|
|
840
|
+
The app uses `nomic-ai/nomic-embed-text-v1.5` (547MB, excellent quality).
|
|
841
|
+
|
|
842
|
+
To use a different model, edit `backend/services/document_processor.py`:
|
|
843
|
+
|
|
844
|
+
```python
|
|
845
|
+
from sentence_transformers import SentenceTransformer
|
|
846
|
+
|
|
847
|
+
self.embedding_model = SentenceTransformer('your-model-name')
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
## π¨ UI Customization
|
|
851
|
+
|
|
852
|
+
### Animation Speeds
|
|
853
|
+
|
|
854
|
+
Edit `src/components/MessageList.tsx`:
|
|
855
|
+
|
|
856
|
+
```typescript
|
|
857
|
+
animate={{ opacity: 1, y: 0 }}
|
|
858
|
+
transition={{
|
|
859
|
+
type: "spring",
|
|
860
|
+
stiffness: 100, // Lower = slower bounce
|
|
861
|
+
damping: 15 // Higher = less bounce
|
|
862
|
+
}}
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
### Color Schemes
|
|
866
|
+
|
|
867
|
+
Edit `src/index.css`:
|
|
868
|
+
|
|
869
|
+
```css
|
|
870
|
+
.assistant-message {
|
|
871
|
+
background: linear-gradient(
|
|
872
|
+
135deg,
|
|
873
|
+
rgba(59, 130, 246, 0.1),
|
|
874
|
+
/* Adjust colors */ rgba(147, 51, 234, 0.1)
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
## π Troubleshooting
|
|
880
|
+
|
|
881
|
+
### Automated Setup Script Issues
|
|
882
|
+
|
|
883
|
+
#### **Script execution disabled (PowerShell)**
|
|
884
|
+
|
|
885
|
+
**Problem:** `setup-and-run.ps1 cannot be loaded because running scripts is disabled`
|
|
886
|
+
|
|
887
|
+
**Solution:**
|
|
888
|
+
|
|
889
|
+
```powershell
|
|
890
|
+
# Run PowerShell as Administrator
|
|
891
|
+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
892
|
+
# Then run the script again
|
|
893
|
+
pwsh setup-and-run.ps1
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
#### **Permission denied (Linux/macOS)**
|
|
897
|
+
|
|
898
|
+
**Problem:** `bash: ./setup-and-run.sh: Permission denied`
|
|
899
|
+
|
|
900
|
+
**Solution:**
|
|
901
|
+
|
|
902
|
+
```bash
|
|
903
|
+
chmod +x setup-and-run.sh
|
|
904
|
+
./setup-and-run.sh
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
#### **Script hangs during installation**
|
|
908
|
+
|
|
909
|
+
**Problem:** Script appears stuck during MongoDB/Ollama installation
|
|
910
|
+
|
|
911
|
+
**Solution:**
|
|
912
|
+
|
|
913
|
+
- Check `logs/setup_*.log` for detailed error messages
|
|
914
|
+
- Ensure you have internet connection
|
|
915
|
+
- Run with administrator/sudo privileges if needed
|
|
916
|
+
- Manually install the stuck component and rerun script
|
|
917
|
+
|
|
918
|
+
#### **Services won't start**
|
|
919
|
+
|
|
920
|
+
**Problem:** MongoDB or Ollama service fails to start
|
|
921
|
+
|
|
922
|
+
**Solution:**
|
|
923
|
+
|
|
924
|
+
```bash
|
|
925
|
+
# Check if ports are already in use
|
|
926
|
+
# Windows:
|
|
927
|
+
netstat -ano | findstr :27017
|
|
928
|
+
netstat -ano | findstr :11434
|
|
929
|
+
|
|
930
|
+
# Linux/macOS:
|
|
931
|
+
lsof -i :27017
|
|
932
|
+
lsof -i :11434
|
|
933
|
+
|
|
934
|
+
# Kill processes using the ports if needed
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
### MongoDB connection failed
|
|
938
|
+
|
|
939
|
+
**Problem:** `Failed to connect to MongoDB` error on startup
|
|
940
|
+
|
|
941
|
+
**Solution:**
|
|
942
|
+
|
|
943
|
+
```bash
|
|
944
|
+
# Check if MongoDB is running
|
|
945
|
+
mongosh
|
|
946
|
+
|
|
947
|
+
# Start MongoDB service
|
|
948
|
+
# Windows:
|
|
949
|
+
net start MongoDB
|
|
950
|
+
|
|
951
|
+
# macOS:
|
|
952
|
+
brew services start mongodb-community@7.0
|
|
953
|
+
|
|
954
|
+
# Linux:
|
|
955
|
+
sudo systemctl start mongod
|
|
956
|
+
|
|
957
|
+
# For MongoDB Atlas:
|
|
958
|
+
# - Check connection string in .env
|
|
959
|
+
# - Verify IP whitelist in Atlas dashboard
|
|
960
|
+
# - Check username/password are correct
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
### Backend won't start
|
|
964
|
+
|
|
965
|
+
**Problem:** `ModuleNotFoundError` or import errors
|
|
966
|
+
|
|
967
|
+
**Solution:**
|
|
968
|
+
|
|
969
|
+
```bash
|
|
970
|
+
cd backend
|
|
971
|
+
.\venv\Scripts\activate
|
|
972
|
+
pip install -r requirements.txt
|
|
973
|
+
|
|
974
|
+
# If still failing, reinstall dependencies:
|
|
975
|
+
pip install --upgrade -r requirements.txt
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
### No models showing up
|
|
979
|
+
|
|
980
|
+
**Problem:** Model dropdown is empty
|
|
981
|
+
|
|
982
|
+
**Solution:**
|
|
983
|
+
|
|
984
|
+
1. Make sure Ollama is running: `ollama serve`
|
|
985
|
+
2. Pull at least one model: `ollama pull gemma2:2b`
|
|
986
|
+
3. Check Ollama URL in `.env`: `OLLAMA_URL=http://127.0.0.1:11434`
|
|
987
|
+
4. Click the refresh button (π) next to model selector
|
|
988
|
+
5. Check browser console for API errors
|
|
989
|
+
|
|
990
|
+
### Sessions not persisting
|
|
991
|
+
|
|
992
|
+
**Problem:** Chat sessions disappear after refresh
|
|
993
|
+
|
|
994
|
+
**Solution:**
|
|
995
|
+
|
|
996
|
+
1. Verify MongoDB is running: `mongosh`
|
|
997
|
+
2. Check `MONGODB_URL` in `backend/.env`
|
|
998
|
+
3. Look for connection errors in backend logs
|
|
999
|
+
4. Test MongoDB connection: `mongosh "mongodb://127.0.0.1:27017"`
|
|
1000
|
+
5. Check database exists: In mongosh, run `show dbs`
|
|
1001
|
+
|
|
1002
|
+
### File upload fails
|
|
1003
|
+
|
|
1004
|
+
**Problem:** Files don't upload or process
|
|
1005
|
+
|
|
1006
|
+
**Solution:**
|
|
1007
|
+
|
|
1008
|
+
1. Check file size (default max: 10MB)
|
|
1009
|
+
2. Ensure `backend/uploads/` directory exists
|
|
1010
|
+
3. Check backend logs for errors
|
|
1011
|
+
4. Supported formats: PDF, DOCX, TXT
|
|
1012
|
+
5. Make sure session exists before uploading
|
|
1013
|
+
6. Check MongoDB `knowledge_base` collection for chunks
|
|
1014
|
+
|
|
1015
|
+
### RAG not working
|
|
1016
|
+
|
|
1017
|
+
**Problem:** "what is in the file" doesn't use document content
|
|
1018
|
+
|
|
1019
|
+
**Solution:**
|
|
1020
|
+
|
|
1021
|
+
1. Ensure RAG toggle is ON (blue) in left sidebar
|
|
1022
|
+
2. Check that file was uploaded successfully (file card appears)
|
|
1023
|
+
3. Wait for embedding to complete (check `embedded: true` in file metadata)
|
|
1024
|
+
4. Verify chunks were created in MongoDB:
|
|
1025
|
+
```javascript
|
|
1026
|
+
// In mongosh:
|
|
1027
|
+
use chat_app
|
|
1028
|
+
db.knowledge_base.find({session_id: "your-session-id"})
|
|
1029
|
+
```
|
|
1030
|
+
5. Check backend logs for RAG processing errors
|
|
1031
|
+
|
|
1032
|
+
### Web search not working
|
|
1033
|
+
|
|
1034
|
+
**Problem:** "Web Search Unavailable" message
|
|
1035
|
+
|
|
1036
|
+
**Solution:**
|
|
1037
|
+
|
|
1038
|
+
1. Get free API key from [serper.dev](https://serper.dev/api-keys)
|
|
1039
|
+
2. Add to `backend/.env`: `SERPER_API_KEY=your_key_here`
|
|
1040
|
+
3. Restart backend server
|
|
1041
|
+
4. Enable "Web Search" toggle in left sidebar (turns blue)
|
|
1042
|
+
5. Check backend logs for API errors
|
|
1043
|
+
|
|
1044
|
+
### File cards not showing
|
|
1045
|
+
|
|
1046
|
+
**Problem:** Uploaded files don't display as cards
|
|
1047
|
+
|
|
1048
|
+
**Solution:**
|
|
1049
|
+
|
|
1050
|
+
1. Check that file upload completed successfully
|
|
1051
|
+
2. Verify session has files array in MongoDB:
|
|
1052
|
+
```javascript
|
|
1053
|
+
// In mongosh:
|
|
1054
|
+
use chat_app
|
|
1055
|
+
db.chat_sessions.findOne({session_id: "your-session-id"})
|
|
1056
|
+
```
|
|
1057
|
+
3. Refresh the chat session
|
|
1058
|
+
4. Check browser console for React errors
|
|
1059
|
+
|
|
1060
|
+
### Conversation memory not working
|
|
1061
|
+
|
|
1062
|
+
**Problem:** AI doesn't remember previous messages in session
|
|
1063
|
+
|
|
1064
|
+
**Solution:**
|
|
1065
|
+
|
|
1066
|
+
- This is built-in now! Uses full session history from MongoDB
|
|
1067
|
+
- Make sure you're in the same session (check session_id in URL)
|
|
1068
|
+
- Check MongoDB for messages: `db.chat_sessions.findOne({session_id: "..."})`
|
|
1069
|
+
- Backend uses last 10 messages for context automatically
|
|
1070
|
+
- Check browser console for errors
|
|
1071
|
+
|
|
1072
|
+
### Session titles not generating
|
|
1073
|
+
|
|
1074
|
+
**Problem:** Sessions show as "New Chat" instead of AI-generated titles
|
|
1075
|
+
|
|
1076
|
+
**Solution:**
|
|
1077
|
+
|
|
1078
|
+
1. Title generates after first message exchange (user + assistant)
|
|
1079
|
+
2. Check backend logs for title generation errors
|
|
1080
|
+
3. Make sure LLM backend is responding correctly
|
|
1081
|
+
4. Title generation is async - may take a few seconds
|
|
1082
|
+
5. Check MongoDB: `db.chat_sessions.findOne({session_id: "..."})` for `title` field
|
|
1083
|
+
|
|
1084
|
+
### Frontend shows old version
|
|
1085
|
+
|
|
1086
|
+
**Problem:** Changes don't appear after updates
|
|
1087
|
+
|
|
1088
|
+
**Solution:**
|
|
1089
|
+
|
|
1090
|
+
```bash
|
|
1091
|
+
# Hard refresh
|
|
1092
|
+
Ctrl + F5 (Windows)
|
|
1093
|
+
Cmd + Shift + R (Mac)
|
|
1094
|
+
|
|
1095
|
+
# Or clear cache
|
|
1096
|
+
# Browser DevTools β Application β Clear storage
|
|
1097
|
+
|
|
1098
|
+
# Or rebuild
|
|
1099
|
+
npm run build
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
## π οΈ Development
|
|
1103
|
+
|
|
1104
|
+
### Run Backend Tests
|
|
1105
|
+
|
|
1106
|
+
```bash
|
|
1107
|
+
cd backend
|
|
1108
|
+
pytest
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
### Run Frontend in Dev Mode
|
|
1112
|
+
|
|
1113
|
+
```bash
|
|
1114
|
+
npm run dev
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
### Build for Production
|
|
1118
|
+
|
|
1119
|
+
```bash
|
|
1120
|
+
npm run build
|
|
1121
|
+
cd backend
|
|
1122
|
+
python main.py # Serves built frontend + API
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
### Lint and Format
|
|
1126
|
+
|
|
1127
|
+
```bash
|
|
1128
|
+
# Frontend
|
|
1129
|
+
npm run lint
|
|
1130
|
+
|
|
1131
|
+
# Backend
|
|
1132
|
+
cd backend
|
|
1133
|
+
black .
|
|
1134
|
+
flake8 .
|
|
1135
|
+
```
|
|
1136
|
+
|
|
1137
|
+
### Hot Reload
|
|
1138
|
+
|
|
1139
|
+
Both frontend (Vite) and backend (uvicorn --reload) support hot reloading in development mode.
|
|
1140
|
+
|
|
1141
|
+
## π Performance Tips
|
|
1142
|
+
|
|
1143
|
+
1. **Use smaller models for speed** - `gemma2:2b` is very fast
|
|
1144
|
+
2. **Limit conversation history** - Uses last 10 messages for context (configurable)
|
|
1145
|
+
3. **Chunk large documents** - Files are auto-chunked to 512 characters
|
|
1146
|
+
4. **Use RAG only when needed** - Toggle off when not querying docs
|
|
1147
|
+
5. **Web search is rate-limited** - Serper.dev offers 100 free searches/month
|
|
1148
|
+
6. **MongoDB indexes** - Automatically created for optimal query performance
|
|
1149
|
+
7. **Clean old sessions** - Periodically delete unused sessions to save space
|
|
1150
|
+
8. **Local MongoDB** - Use local MongoDB for best performance vs Atlas cloud
|
|
1151
|
+
9. **File size limits** - Keep files under 10MB for faster processing
|
|
1152
|
+
10. **GPU acceleration** - RAG embedding uses GPU if available (CUDA)
|
|
1153
|
+
|
|
1154
|
+
## π Privacy & Security
|
|
1155
|
+
|
|
1156
|
+
- β
**100% Local Processing** - All AI inference happens on your machine
|
|
1157
|
+
- β
**Local Data Storage** - MongoDB can run locally, no cloud required
|
|
1158
|
+
- β
**No Data Sent to Cloud** - Except web search queries (via Serper.dev) and if using MongoDB Atlas
|
|
1159
|
+
- β
**API Keys Protected** - `.env` file not committed to Git
|
|
1160
|
+
- β
**CORS Configured** - Only allows localhost origins
|
|
1161
|
+
- β
**Session Isolation** - Each session has its own files and context
|
|
1162
|
+
- β
**No Analytics** - No tracking or telemetry sent anywhere
|
|
1163
|
+
- β οΈ **Development Mode** - Not hardened for public deployment
|
|
1164
|
+
- π‘ **MongoDB Options**:
|
|
1165
|
+
- **Local MongoDB**: Complete privacy, all data on your machine
|
|
1166
|
+
- **MongoDB Atlas**: Convenient cloud option, data encrypted at rest and in transit
|
|
1167
|
+
|
|
1168
|
+
## π€ Contributing
|
|
1169
|
+
|
|
1170
|
+
Contributions are welcome! Here's how:
|
|
1171
|
+
|
|
1172
|
+
1. Fork the repository
|
|
1173
|
+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
1174
|
+
3. Commit changes: `git commit -m 'Add amazing feature'`
|
|
1175
|
+
4. Push to branch: `git push origin feature/amazing-feature`
|
|
1176
|
+
5. Open a Pull Request
|
|
1177
|
+
|
|
1178
|
+
### Development Guidelines
|
|
1179
|
+
|
|
1180
|
+
- Follow TypeScript/Python best practices
|
|
1181
|
+
- Add comments for complex logic
|
|
1182
|
+
- Test before submitting
|
|
1183
|
+
- Update README if adding features
|
|
1184
|
+
|
|
1185
|
+
## π License
|
|
1186
|
+
|
|
1187
|
+
This project is licensed under the MIT License - see LICENSE file for details.
|
|
1188
|
+
|
|
1189
|
+
## π Acknowledgments
|
|
1190
|
+
|
|
1191
|
+
- **Ollama Team** - Amazing local LLM runtime
|
|
1192
|
+
- **FastAPI** - High-performance Python framework
|
|
1193
|
+
- **Framer Motion** - Beautiful React animations
|
|
1194
|
+
- **ChromaDB** - Excellent vector database
|
|
1195
|
+
- **Serper.dev** - Reliable Google search API
|
|
1196
|
+
- **Nomic AI** - High-quality embedding models
|
|
1197
|
+
- **Open Source Community** - For all the incredible tools
|
|
1198
|
+
|
|
1199
|
+
## π§ Support & Contact
|
|
1200
|
+
|
|
1201
|
+
- **Issues** - [GitHub Issues](https://github.com/lebiraja/plugin/issues)
|
|
1202
|
+
- **Discussions** - [GitHub Discussions](https://github.com/lebiraja/plugin/discussions)
|
|
1203
|
+
|
|
1204
|
+
## πΊοΈ Roadmap
|
|
1205
|
+
|
|
1206
|
+
Future features planned:
|
|
1207
|
+
|
|
1208
|
+
- [ ] Multi-modal support (image input)
|
|
1209
|
+
- [ ] Voice chat integration
|
|
1210
|
+
- [ ] Custom prompt templates
|
|
1211
|
+
- [ ] Conversation export/import (JSON, Markdown)
|
|
1212
|
+
- [ ] Advanced RAG with re-ranking
|
|
1213
|
+
- [x] Multiple conversation threads (β
Implemented v2.0)
|
|
1214
|
+
- [x] MongoDB persistent storage (β
Implemented v2.0)
|
|
1215
|
+
- [ ] Conversation search and filtering
|
|
1216
|
+
- [ ] Session sharing and collaboration
|
|
1217
|
+
- [ ] File version control in knowledge base
|
|
1218
|
+
- [ ] Plugin system for extensions
|
|
1219
|
+
- [ ] Mobile app (React Native)
|
|
1220
|
+
- [ ] Batch file uploads
|
|
1221
|
+
- [ ] Advanced analytics dashboard
|
|
1222
|
+
|
|
1223
|
+
## π Changelog
|
|
1224
|
+
|
|
1225
|
+
### Version 2.0.0 (November 2025) - Major Update π
|
|
1226
|
+
|
|
1227
|
+
- β
**Persistent Chat Sessions** - MongoDB-backed session management
|
|
1228
|
+
- β
**ChatGPT-Style Interface** - Session history sidebar with time-based grouping
|
|
1229
|
+
- β
**Smart Auto-Titles** - AI generates 3-4 word titles after first exchange
|
|
1230
|
+
- β
**File Cards Display** - ChatGPT-style file cards in chat interface
|
|
1231
|
+
- β
**MongoDB Knowledge Base** - Persistent RAG chunks storage
|
|
1232
|
+
- β
**Session-Based Files** - Files linked to specific sessions
|
|
1233
|
+
- β
**Unified Sidebar** - Backend, model, and tools in one sidebar
|
|
1234
|
+
- β
**Enhanced RAG Service** - MongoDB storage with automatic text extraction
|
|
1235
|
+
- β
**File Metadata Tracking** - Track embedded status, chunk count, file size
|
|
1236
|
+
- β
**Async Title Generation** - Non-blocking title creation
|
|
1237
|
+
- β
**Session CRUD API** - Full REST API for session management
|
|
1238
|
+
- β
**Database Indexes** - Optimized queries for sessions and files
|
|
1239
|
+
|
|
1240
|
+
### Version 1.0.0 (October 2025)
|
|
1241
|
+
|
|
1242
|
+
- β
Interactive model selector with auto-fetch
|
|
1243
|
+
- β
Conversation memory (last 10 messages)
|
|
1244
|
+
- β
Interactive tool toggle buttons
|
|
1245
|
+
- β
Knowledge base file management with delete
|
|
1246
|
+
- β
Enhanced UI with spring animations
|
|
1247
|
+
- β
Web search via Serper.dev
|
|
1248
|
+
- β
RAG with nomic-embed-text-v1.5
|
|
1249
|
+
- β
Loading status indicators
|
|
1250
|
+
- β
Glassmorphism design
|
|
1251
|
+
- β
Gradient message backgrounds
|
|
1252
|
+
- β
Citation display for sources
|
|
1253
|
+
|
|
1254
|
+
---
|
|
1255
|
+
|
|
1256
|
+
**Made with β€οΈ by [lebiraja](https://github.com/lebiraja)**
|
|
1257
|
+
|
|
1258
|
+
_Star β this repo if you find it helpful!_
|