Spaces:
Sleeping
Sleeping
Commit
Β·
90160c5
1
Parent(s):
aa63765
update the code
Browse files- README.md +89 -35
- frontend/README.md +38 -5
README.md
CHANGED
|
@@ -77,6 +77,8 @@ Agents can intelligently:
|
|
| 77 |
- **Strict multi-tenant isolation** with tenant_id filtering
|
| 78 |
- **Intelligent text chunking** (~300 words per chunk)
|
| 79 |
- **Vector similarity search** using cosine distance
|
|
|
|
|
|
|
| 80 |
|
| 81 |
### 3. π Live Web Search Tool
|
| 82 |
|
|
@@ -121,6 +123,8 @@ Comprehensive insights for:
|
|
| 121 |
- π¨ Red-flag violation tracking
|
| 122 |
- π§ Agent reasoning traces
|
| 123 |
- π₯ Tenant activity monitoring
|
|
|
|
|
|
|
| 124 |
|
| 125 |
### 7. π’ Multi-Tenant Isolation
|
| 126 |
|
|
@@ -149,16 +153,20 @@ Isolation is guaranteed via **Supabase Row-Level Security (RLS)**.
|
|
| 149 |
| **Ollama / Groq** | LLM inference engine (configurable) |
|
| 150 |
| **DuckDuckGo Search** | Web search provider |
|
| 151 |
| **Slack / Email** | Alerting system |
|
|
|
|
|
|
|
| 152 |
|
| 153 |
### Frontend
|
| 154 |
|
| 155 |
| Technology | Purpose |
|
| 156 |
|------------|---------|
|
| 157 |
-
| **
|
|
|
|
| 158 |
| **TailwindCSS** | Utility-first styling |
|
| 159 |
-
| **
|
| 160 |
| **WebSocket** | Real-time streaming |
|
| 161 |
| **Admin Dashboard** | Analytics & governance UI |
|
|
|
|
| 162 |
|
| 163 |
---
|
| 164 |
|
|
@@ -245,10 +253,14 @@ IntegraChat/
|
|
| 245 |
β β βββ embeddings.py # Sentence transformers embeddings
|
| 246 |
β β
|
| 247 |
β βββ workers/
|
| 248 |
-
β β βββ ingestion_worker.py
|
| 249 |
-
β β βββ analytics_worker.py
|
| 250 |
-
β β βββ scheduler.py
|
| 251 |
-
β β βββ celeryconfig.py
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
β β
|
| 253 |
β βββ tests/
|
| 254 |
β β βββ test_agent.py
|
|
@@ -260,33 +272,20 @@ IntegraChat/
|
|
| 260 |
β βββ Dockerfile
|
| 261 |
β
|
| 262 |
βββ frontend/
|
| 263 |
-
β βββ
|
| 264 |
-
β β βββ
|
| 265 |
-
β β
|
| 266 |
-
β β
|
| 267 |
-
β β
|
| 268 |
-
β β
|
| 269 |
-
β
|
| 270 |
-
β β
|
| 271 |
-
β β
|
| 272 |
-
β β
|
| 273 |
-
β β
|
| 274 |
-
β β
|
| 275 |
-
β β
|
| 276 |
-
β β
|
| 277 |
-
β β β βββ ChatPage.jsx
|
| 278 |
-
β β β βββ AdminPage.jsx
|
| 279 |
-
β β β βββ AnalyticsPage.jsx
|
| 280 |
-
β β βββ store/
|
| 281 |
-
β β β βββ chatStore.js
|
| 282 |
-
β β β βββ adminStore.js
|
| 283 |
-
β β β βββ analyticsStore.js
|
| 284 |
-
β β βββ utils/
|
| 285 |
-
β β β βββ websocket.js
|
| 286 |
-
β β β βββ api.js
|
| 287 |
-
β β β βββ formatters.js
|
| 288 |
-
β β βββ App.jsx
|
| 289 |
-
β β βββ main.jsx
|
| 290 |
β βββ public/
|
| 291 |
β βββ package.json
|
| 292 |
β
|
|
@@ -372,6 +371,10 @@ Before you begin, ensure you have the following installed:
|
|
| 372 |
OLLAMA_MODEL=llama3
|
| 373 |
# Or use Groq instead:
|
| 374 |
# GROQ_API_KEY=your_groq_api_key
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
```
|
| 376 |
|
| 377 |
4. **Start the RAG MCP Server**
|
|
@@ -383,7 +386,16 @@ Before you begin, ensure you have the following installed:
|
|
| 383 |
- Server runs on `http://localhost:8001`
|
| 384 |
- API docs available at `http://localhost:8001/docs`
|
| 385 |
|
| 386 |
-
5. **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
```bash
|
| 388 |
cd backend
|
| 389 |
uvicorn api.main:app --reload
|
|
@@ -413,6 +425,34 @@ curl -X POST http://localhost:8001/search \
|
|
| 413 |
}'
|
| 414 |
```
|
| 415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
### Frontend Setup
|
| 417 |
|
| 418 |
1. **Navigate to frontend directory**
|
|
@@ -425,10 +465,22 @@ curl -X POST http://localhost:8001/search \
|
|
| 425 |
npm install
|
| 426 |
```
|
| 427 |
|
| 428 |
-
3. **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
```bash
|
| 430 |
npm run dev
|
| 431 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
|
| 433 |
### Quick Start with Docker
|
| 434 |
|
|
@@ -449,6 +501,8 @@ docker-compose up -d
|
|
| 449 |
| π **English Web Search** | Forces English language results for better accuracy |
|
| 450 |
| π’ **Production-Grade** | Multi-tenant design with strict Supabase RLS |
|
| 451 |
| π **Full Observability** | Logs, analytics, tool events, violations |
|
|
|
|
|
|
|
| 452 |
| π― **Demo-Ready** | Perfect for enterprise presentations |
|
| 453 |
|
| 454 |
---
|
|
|
|
| 77 |
- **Strict multi-tenant isolation** with tenant_id filtering
|
| 78 |
- **Intelligent text chunking** (~300 words per chunk)
|
| 79 |
- **Vector similarity search** using cosine distance
|
| 80 |
+
- **Async document ingestion** via Celery workers (PDF, DOCX, TXT support)
|
| 81 |
+
- **Knowledge base management UI** for document upload and search
|
| 82 |
|
| 83 |
### 3. π Live Web Search Tool
|
| 84 |
|
|
|
|
| 123 |
- π¨ Red-flag violation tracking
|
| 124 |
- π§ Agent reasoning traces
|
| 125 |
- π₯ Tenant activity monitoring
|
| 126 |
+
- **Real-time analytics panel** in the frontend UI
|
| 127 |
+
- **Async analytics processing** via Celery workers
|
| 128 |
|
| 129 |
### 7. π’ Multi-Tenant Isolation
|
| 130 |
|
|
|
|
| 153 |
| **Ollama / Groq** | LLM inference engine (configurable) |
|
| 154 |
| **DuckDuckGo Search** | Web search provider |
|
| 155 |
| **Slack / Email** | Alerting system |
|
| 156 |
+
| **Celery** | Async task queue for document ingestion and analytics |
|
| 157 |
+
| **Redis / RabbitMQ** | Message broker for Celery workers |
|
| 158 |
|
| 159 |
### Frontend
|
| 160 |
|
| 161 |
| Technology | Purpose |
|
| 162 |
|------------|---------|
|
| 163 |
+
| **Next.js 16** | React framework with App Router |
|
| 164 |
+
| **React 19** | Modern UI framework |
|
| 165 |
| **TailwindCSS** | Utility-first styling |
|
| 166 |
+
| **TypeScript** | Type-safe development |
|
| 167 |
| **WebSocket** | Real-time streaming |
|
| 168 |
| **Admin Dashboard** | Analytics & governance UI |
|
| 169 |
+
| **Knowledge Base UI** | Document management interface |
|
| 170 |
|
| 171 |
---
|
| 172 |
|
|
|
|
| 253 |
β β βββ embeddings.py # Sentence transformers embeddings
|
| 254 |
β β
|
| 255 |
β βββ workers/
|
| 256 |
+
β β βββ ingestion_worker.py # Celery tasks for document ingestion
|
| 257 |
+
β β βββ analytics_worker.py # Celery tasks for analytics processing
|
| 258 |
+
β β βββ scheduler.py # Scheduled task definitions
|
| 259 |
+
β β βββ celeryconfig.py # Celery app configuration
|
| 260 |
+
β β
|
| 261 |
+
β βββ api/
|
| 262 |
+
β β βββ ingestion/
|
| 263 |
+
β β β βββ pdf.py # PDF processing utilities
|
| 264 |
β β
|
| 265 |
β βββ tests/
|
| 266 |
β β βββ test_agent.py
|
|
|
|
| 272 |
β βββ Dockerfile
|
| 273 |
β
|
| 274 |
βββ frontend/
|
| 275 |
+
β βββ app/
|
| 276 |
+
β β βββ page.tsx # Main landing page
|
| 277 |
+
β β βββ layout.tsx # Root layout
|
| 278 |
+
β β βββ globals.css # Global styles
|
| 279 |
+
β β βββ knowledge-base/
|
| 280 |
+
β β βββ page.tsx # Knowledge base management page
|
| 281 |
+
β βββ components/
|
| 282 |
+
β β βββ chat-panel.tsx # Chat interface component
|
| 283 |
+
β β βββ analytics-panel.tsx # Analytics dashboard component
|
| 284 |
+
β β βββ knowledge-base-panel.tsx # Knowledge base search/ingest UI
|
| 285 |
+
β β βββ ingestion-card.tsx # Document ingestion card
|
| 286 |
+
β β βββ hero.tsx # Hero section
|
| 287 |
+
β β βββ feature-grid.tsx # Feature showcase grid
|
| 288 |
+
β β βββ footer.tsx # Footer component
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
β βββ public/
|
| 290 |
β βββ package.json
|
| 291 |
β
|
|
|
|
| 371 |
OLLAMA_MODEL=llama3
|
| 372 |
# Or use Groq instead:
|
| 373 |
# GROQ_API_KEY=your_groq_api_key
|
| 374 |
+
|
| 375 |
+
# Celery Configuration (for async workers)
|
| 376 |
+
CELERY_BROKER_URL=redis://localhost:6379/0
|
| 377 |
+
CELERY_RESULT_BACKEND=redis://localhost:6379/0
|
| 378 |
```
|
| 379 |
|
| 380 |
4. **Start the RAG MCP Server**
|
|
|
|
| 386 |
- Server runs on `http://localhost:8001`
|
| 387 |
- API docs available at `http://localhost:8001/docs`
|
| 388 |
|
| 389 |
+
5. **Start Celery workers** (for async document ingestion and analytics)
|
| 390 |
+
```bash
|
| 391 |
+
# Start Celery worker
|
| 392 |
+
celery -A backend.workers.celeryconfig worker --loglevel=info
|
| 393 |
+
|
| 394 |
+
# In another terminal, start Celery beat (for scheduled tasks)
|
| 395 |
+
celery -A backend.workers.celeryconfig beat --loglevel=info
|
| 396 |
+
```
|
| 397 |
+
|
| 398 |
+
6. **Run the main API server**
|
| 399 |
```bash
|
| 400 |
cd backend
|
| 401 |
uvicorn api.main:app --reload
|
|
|
|
| 425 |
}'
|
| 426 |
```
|
| 427 |
|
| 428 |
+
### Document Ingestion via Celery Workers
|
| 429 |
+
|
| 430 |
+
Documents can be ingested asynchronously using Celery workers:
|
| 431 |
+
|
| 432 |
+
**Via API endpoint (triggers Celery task):**
|
| 433 |
+
```bash
|
| 434 |
+
curl -X POST http://localhost:8000/rag/ingest \
|
| 435 |
+
-H "Content-Type: application/json" \
|
| 436 |
+
-H "x-tenant-id: tenant123" \
|
| 437 |
+
-d '{
|
| 438 |
+
"content": "Your document text here...",
|
| 439 |
+
"doc_id": "doc_001"
|
| 440 |
+
}'
|
| 441 |
+
```
|
| 442 |
+
|
| 443 |
+
**Supported formats:**
|
| 444 |
+
- Raw text content
|
| 445 |
+
- PDF files (via file upload)
|
| 446 |
+
- DOCX files (via file upload)
|
| 447 |
+
- TXT files (via file upload)
|
| 448 |
+
- URLs (web page content)
|
| 449 |
+
|
| 450 |
+
The ingestion worker automatically:
|
| 451 |
+
- Extracts text from files
|
| 452 |
+
- Chunks text with configurable overlap
|
| 453 |
+
- Generates embeddings using Sentence-Transformers
|
| 454 |
+
- Stores chunks and embeddings in Supabase/pgvector
|
| 455 |
+
|
| 456 |
### Frontend Setup
|
| 457 |
|
| 458 |
1. **Navigate to frontend directory**
|
|
|
|
| 465 |
npm install
|
| 466 |
```
|
| 467 |
|
| 468 |
+
3. **Configure environment variables** (optional)
|
| 469 |
+
|
| 470 |
+
Create a `.env.local` file in the frontend directory:
|
| 471 |
+
```env
|
| 472 |
+
NEXT_PUBLIC_API_URL=http://localhost:8000
|
| 473 |
+
```
|
| 474 |
+
|
| 475 |
+
4. **Start the development server**
|
| 476 |
```bash
|
| 477 |
npm run dev
|
| 478 |
```
|
| 479 |
+
|
| 480 |
+
The app will be available at `http://localhost:3000` with:
|
| 481 |
+
- **Main landing page** with hero, features, and chat panel
|
| 482 |
+
- **Knowledge base page** (`/knowledge-base`) for document management
|
| 483 |
+
- **Analytics panel** showing query metrics and tool usage
|
| 484 |
|
| 485 |
### Quick Start with Docker
|
| 486 |
|
|
|
|
| 501 |
| π **English Web Search** | Forces English language results for better accuracy |
|
| 502 |
| π’ **Production-Grade** | Multi-tenant design with strict Supabase RLS |
|
| 503 |
| π **Full Observability** | Logs, analytics, tool events, violations |
|
| 504 |
+
| π **Knowledge Base UI** | Complete document management interface with search and ingestion |
|
| 505 |
+
| β‘ **Async Processing** | Celery workers for scalable document ingestion and analytics |
|
| 506 |
| π― **Demo-Ready** | Perfect for enterprise presentations |
|
| 507 |
|
| 508 |
---
|
frontend/README.md
CHANGED
|
@@ -3,10 +3,12 @@
|
|
| 3 |
Next.js 16 / React 19 app that showcases everything wired up in `backend/`.
|
| 4 |
It provides a polished operator console with:
|
| 5 |
|
| 6 |
-
- Hero + feature overview describing the FastAPI + MCP stack
|
| 7 |
-
- Live chat panel that POSTs to `POST /agent/message`
|
| 8 |
-
- Analytics
|
| 9 |
-
- Knowledge
|
|
|
|
|
|
|
| 10 |
|
| 11 |
## Running Locally
|
| 12 |
|
|
@@ -16,7 +18,7 @@ npm install
|
|
| 16 |
npm run dev
|
| 17 |
```
|
| 18 |
|
| 19 |
-
Visit `http://localhost:3000
|
| 20 |
|
| 21 |
### API configuration
|
| 22 |
|
|
@@ -27,6 +29,37 @@ Update `.env.local` if your backend runs elsewhere:
|
|
| 27 |
NEXT_PUBLIC_API_URL=http://localhost:8000
|
| 28 |
```
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
## Deploy
|
| 31 |
|
| 32 |
Deploy like any Next.js app (Vercel, Docker, etc.). Ensure the backend endpoints are reachable from the browser and CORS is enabled (already configured in `backend/api/main.py`).
|
|
|
|
|
|
|
|
|
| 3 |
Next.js 16 / React 19 app that showcases everything wired up in `backend/`.
|
| 4 |
It provides a polished operator console with:
|
| 5 |
|
| 6 |
+
- **Hero section** + feature overview describing the FastAPI + MCP stack
|
| 7 |
+
- **Live chat panel** that POSTs to `POST /agent/message` for AI conversations
|
| 8 |
+
- **Analytics dashboard** pulling from `GET /analytics/overview` with real-time metrics
|
| 9 |
+
- **Knowledge base management** page (`/knowledge-base`) for document search and ingestion
|
| 10 |
+
- **Document ingestion UI** for uploading PDF, DOCX, TXT files or raw text
|
| 11 |
+
- **Feature grid** showcasing platform capabilities
|
| 12 |
|
| 13 |
## Running Locally
|
| 14 |
|
|
|
|
| 18 |
npm run dev
|
| 19 |
```
|
| 20 |
|
| 21 |
+
Visit `http://localhost:3000` for the main landing page, or `http://localhost:3000/knowledge-base` for document management.
|
| 22 |
|
| 23 |
### API configuration
|
| 24 |
|
|
|
|
| 29 |
NEXT_PUBLIC_API_URL=http://localhost:8000
|
| 30 |
```
|
| 31 |
|
| 32 |
+
## Features
|
| 33 |
+
|
| 34 |
+
### Main Landing Page (`/`)
|
| 35 |
+
- **Hero section** with platform introduction
|
| 36 |
+
- **Feature grid** showcasing key capabilities
|
| 37 |
+
- **Chat panel** for real-time AI conversations
|
| 38 |
+
- **Analytics panel** with query metrics and tool usage statistics
|
| 39 |
+
- **Ingestion card** for quick document uploads
|
| 40 |
+
|
| 41 |
+
### Knowledge Base Page (`/knowledge-base`)
|
| 42 |
+
- **Document listing** with pagination and filtering
|
| 43 |
+
- **Search interface** for semantic search across documents
|
| 44 |
+
- **Document ingestion** with support for:
|
| 45 |
+
- Raw text input
|
| 46 |
+
- PDF file uploads
|
| 47 |
+
- DOCX file uploads
|
| 48 |
+
- TXT file uploads
|
| 49 |
+
- **Document management** with tenant isolation
|
| 50 |
+
|
| 51 |
+
### Components
|
| 52 |
+
|
| 53 |
+
- `chat-panel.tsx` - Real-time chat interface with streaming responses
|
| 54 |
+
- `analytics-panel.tsx` - Analytics dashboard with metrics visualization
|
| 55 |
+
- `knowledge-base-panel.tsx` - Document search and ingestion component
|
| 56 |
+
- `ingestion-card.tsx` - Quick document upload card
|
| 57 |
+
- `hero.tsx` - Landing page hero section
|
| 58 |
+
- `feature-grid.tsx` - Feature showcase grid
|
| 59 |
+
- `footer.tsx` - Footer component
|
| 60 |
+
|
| 61 |
## Deploy
|
| 62 |
|
| 63 |
Deploy like any Next.js app (Vercel, Docker, etc.). Ensure the backend endpoints are reachable from the browser and CORS is enabled (already configured in `backend/api/main.py`).
|
| 64 |
+
|
| 65 |
+
**Note:** Make sure Celery workers are running in production for document ingestion and analytics processing to work properly.
|