Spaces:
Sleeping
Sleeping
File size: 4,663 Bytes
0e0f222 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | # NeuroCheck v9.1 β Local Setup Guide
## Prerequisites
| Software | Version | Download |
|----------|---------|----------|
| Python | 3.10+ | https://python.org/downloads |
| Ollama | Latest | https://ollama.com/download |
| Git | Any | https://git-scm.com |
---
## One-Time Setup (run this once)
```bash
# 1. Clone / unzip the project, then enter it
cd neurocheck
# 2. Run the full setup script
python3 setup.py
```
The setup script will:
- Create a `.venv` virtual environment
- Install all Python packages from `requirements.txt`
- Build the spaCy English model (`en_model/`)
- Verify the NegEx negation pipeline
- Create and initialise the SQLite database (`neurocheck.db`)
- Check Ollama and pull `llama3.1:8b` if needed
---
## Before First Run β Set Your JWT Secret
Open `.env` and replace the placeholder:
```env
JWT_SECRET=CHANGE_THIS_TO_A_LONG_RANDOM_SECRET_BEFORE_RUNNING
```
Generate a real secret:
```bash
python3 -c "import secrets; print(secrets.token_hex(32))"
```
Copy the output into `.env`:
```env
JWT_SECRET=a1b2c3d4e5f6... (your generated value)
```
---
## Start the Server
```bash
python3 start.py
```
Or manually:
```bash
.venv/bin/python -m uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload
```
### Open in Browser
| URL | Description |
|-----|-------------|
| http://localhost:8000 | MS Symptom Classifier |
| http://localhost:8000/chat-ui | AI Chat (login required) |
| http://localhost:8000/docs | Swagger API docs |
---
## Ollama Setup (for AI Chat)
Ollama runs the local LLM (Llama 3.1) that powers the chat assistant.
### Install Ollama
**Windows / macOS:** Download from https://ollama.com/download and run the installer.
**Linux:**
```bash
curl -fsSL https://ollama.com/install.sh | sh
```
### Start Ollama and Pull the Model
```bash
# Start the Ollama server (runs in background)
ollama serve
# Pull the model (4.7 GB β do this once)
ollama pull llama3.1:8b
# Verify it's working
ollama run llama3.1:8b "Hello"
```
> **Note:** The MS Symptom Classifier (`/classify`) works without Ollama.
> Only the `/chat` AI assistant requires Ollama to be running.
---
## Database
NeuroCheck uses SQLite β no separate database server needed.
**File:** `neurocheck.db` (created automatically by `setup.py`)
**Tables:**
| Table | What it stores |
|-------|---------------|
| `users` | Registered accounts (username, email, hashed password) |
| `chat_sessions` | Each conversation linked to a user (title, timestamps) |
| `messages` | Every message with role and UTC timestamp |
### Inspect the Database
```bash
# Open SQLite shell
sqlite3 neurocheck.db
# Inside the shell:
.tables
SELECT * FROM users;
SELECT session_uuid, title, updated_at FROM chat_sessions ORDER BY updated_at DESC;
SELECT role, content, created_at FROM messages WHERE session_uuid='<uuid>' ORDER BY id;
.quit
```
---
## Project Structure
```
neurocheck/
βββ api/
β βββ main.py β FastAPI app + all endpoints
β βββ auth.py β JWT login / register (NEW)
β βββ database.py β SQLite layer (NEW)
β βββ memory.py β In-memory session store
β βββ agent.py β LangGraph AI agent
β βββ rag.py β ChromaDB RAG knowledge base
βββ frontend/
β βββ chat.html β AI Chat UI (login + session sidebar)
β βββ index.html β MS Classifier UI
βββ en_model/ β Built by setup.py (spaCy)
βββ neurocheck.db β Created by setup.py (SQLite)
βββ chroma_db/ β Created at runtime (ChromaDB)
βββ .env β Your config (never commit this)
βββ .env.example β Template
βββ setup.py β One-time setup script
βββ start.py β Start the server
βββ requirements.txt
```
---
## Auth Endpoints
| Method | URL | Description |
|--------|-----|-------------|
| `POST` | `/auth/register` | Create account |
| `POST` | `/auth/login` | Get JWT token |
| `GET` | `/auth/me` | Current user info |
---
## Common Issues
### `spacy.errors.E050` β Model not found
```bash
python3 setup.py # rebuilds en_model/
```
### `Connection refused` on `/chat`
Ollama is not running. Start it:
```bash
ollama serve
```
### `401 Unauthorized` on `/chat`
Your JWT token expired or you are not logged in.
Open `http://localhost:8000/chat-ui` and log in again.
### Port 8000 already in use
```bash
python3 start.py --port 8080
```
### Database errors
```bash
python3 -c "
import os; os.environ['NEUROCHECK_DB']='neurocheck.db'
from api.database import init_db; init_db(); print('OK')
"
```
|