Local-first medical assistant chat app powered by Ollama, with Wikipedia-based retrieval and a Playwright-driven browser agent under the hood.
- Quick Start
- Overview
- Features
- Tech Stack
- Prerequisites
- Configuration
- Running the Application
- API Documentation
- Project Structure
- Environment Variables
- Useful Commands
- Troubleshooting
Already have all dependencies? Jump straight to running the app:
# 1. Clone and setup
git clone <repository-url>
cd MediSimpleGPT
make install
# 2. Start Ollama (in separate terminal)
ollama serve
# 3. Run the application (in two terminals)
make backend # Terminal 1: http://127.0.0.1:8000
make frontend # Terminal 2: http://localhost:5173Need to install dependencies? → Go to Prerequisites
Having issues? → Go to Troubleshooting
This repo contains:
- A FastAPI backend that:
- Drives a real Chromium browser via Playwright.
- Calls a local Ollama model for planning/simplification.
- Stores chat history in a local SQLite database.
- A React + Vite frontend that provides the chat UI.
- Medical Q&A chat
- Persists conversations per
session_id. - Uses Wikipedia as a retrieval source for new topics.
- Detects typos for short medical-term queries and asks for confirmation.
- Handles conversational queries like "summarize our discussion" or "what are the pain points".
- Persists conversations per
- DOM-driven web automation
POST /connectopens a browser and extracts a simplified list of visible elements.POST /planturns{dom + instruction}into a JSON action plan.POST /executeexecutes those actions in the browser.POST /simplifyextracts “article-like” content from the current page and simplifies it.
- Backend: Python, FastAPI, Uvicorn, Playwright, Ollama, SQLite (
aiosqlite) - Frontend: React, TypeScript, Vite, TanStack Query, Axios
- Python:
>= 3.13(seebackend/pyproject.toml) - Node.js:
>= 18.0.0(for npm and Vite) - Operating System: macOS, Linux, or Windows
macOS:
# Using Homebrew (recommended)
brew install python@3.13
# Or download from python.org
# Visit: https://www.python.org/downloads/Linux (Ubuntu/Debian):
# Add deadsnakes PPA for latest Python versions
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.13 python3.13-venv python3.13-pipWindows:
# Download from python.org and run installer
# Visit: https://www.python.org/downloads/
# Make sure to check "Add Python to PATH" during installationAll Platforms:
# Using pip (after Python is installed)
pip install uv
# Or using curl (macOS/Linux)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using PowerShell (Windows)
powershell -c "irm https://astral.sh/uv/install.sh | iex"
# Or using Homebrew (macOS)
brew install uvVerify installation:
uv --versionmacOS:
# Using Homebrew (recommended)
brew install node
# Or download from nodejs.org
# Visit: https://nodejs.org/Linux (Ubuntu/Debian):
# Using NodeSource repository (recommended)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Or using snap
sudo snap install node --classicWindows:
# Download from nodejs.org and run installer
# Visit: https://nodejs.org/
# npm is included with Node.jsVerify installation:
node --version
npm --versionmacOS:
# Using Homebrew (recommended)
brew install ollama
# Or download from ollama.com
# Visit: https://ollama.comLinux:
# Using curl
curl -fsSL https://ollama.com/install.sh | shWindows:
# Download from ollama.com
# Visit: https://ollama.comStart Ollama service:
ollama serveDownload the required model:
ollama pull granite3.1-dense:8bVerify installation:
ollama list
# You should see granite3.1-dense:8b in the listNote: You can change the model by setting
OLLAMA_MODELin.env. The default isgranite3.1-dense:8b.
After installing all dependencies, verify everything is working:
# Check Python
python3 --version # Should be 3.13+
# Check uv
uv --version
# Check Node.js and npm
node --version # Should be 18+
npm --version
# Check Ollama
ollama list # Should show your installed modelsThe application uses a single environment file for configuration:
.env- All configuration variables.env.example- Example configuration file
Key configuration options:
- OLLAMA_MODEL: The Ollama model to use (default:
granite3.1-dense:8b) - OLLAMA_HOST: Ollama server URL (default:
http://localhost:11434) - VITE_API_BASE_URL: Backend API URL for frontend (default:
http://127.0.0.1:8000) - BROWSER_HEADLESS: Run browser in headless mode (default:
false) - MAX_QUERY_LENGTH: Maximum query length (default:
500)
The make install command will automatically create .env file from the example if it doesn't exist.
make installThis runs:
uv syncfor the backendplaywright install chromiumfor the backendnpm installfor the frontend
In two terminals:
make backendmake frontendThen open:
- Frontend:
http://localhost:5173 - Backend:
http://127.0.0.1:8000
Base URL: http://127.0.0.1:8000
GET /health- Returns backend status, whether a browser is connected, and the active model name.
POST /chat- Body:
query: stringsession_id: string (optional; frontend stores one inlocalStorage)
- Body:
GET /history/{session_id}DELETE /history/{session_id}
-
POST /connect- Body:
url: string
- Returns extracted DOM element summaries.
- Body:
-
POST /plan- Body:
instruction: stringdom: string
- Returns an LLM-generated plan (intended to be a JSON array of actions).
- Body:
-
POST /execute- Body:
actions: string (LLM output containing a JSON array)url: string
- Body:
-
POST /simplify- Extracts article-like content from the current page and simplifies it.
- Chat history DB:
backend/conversations.db(SQLite) - Browser state: the backend keeps a single global browser/page (single-user assumption).
.
├─ backend/
│ ├─ api_server.py # FastAPI server (main backend entrypoint)
│ ├─ server.py # MCP server (stdio transport)
│ ├─ prompts.json # Prompt templates
│ ├─ pyproject.toml # Python deps
│ └─ uv.lock
├─ frontend/
│ ├─ src/
│ │ ├─ App.tsx # MediSimpleGPT chat UI
│ │ └─ hooks/useAgent.ts # Helper hooks for connect/plan/execute/simplify
│ └─ package.json
└─ Makefile
make install- Install all dependencies and setup environmentmake setup-env- Create .env files from examplesmake backend- Start the backend servermake frontend- Start the frontend development servermake clean- Clean build artifacts and dependencies
All configuration is managed through a single .env file at the project root:
| Variable | Default | Description |
|---|---|---|
OLLAMA_MODEL |
granite3.1-dense:8b |
Ollama model to use |
OLLAMA_HOST |
http://localhost:11434 |
Ollama server URL |
HOST |
127.0.0.1 |
Backend server host |
PORT |
8000 |
Backend server port |
FRONTEND_URL |
http://localhost:5173 |
Frontend URL for CORS |
VITE_API_BASE_URL |
http://127.0.0.1:8000 |
Backend API URL (frontend) |
VITE_MAX_QUERY_LENGTH |
500 |
Maximum query length (frontend) |
DB_PATH |
backend/conversations.db |
SQLite database file path |
MAX_QUERY_LENGTH |
500 |
Maximum query length (backend) |
WIKIPEDIA_BASE |
https://www.wikipedia.org |
Wikipedia base URL |
BROWSER_HEADLESS |
false |
Run browser in headless mode |
BROWSER_TIMEOUT |
15000 |
Browser navigation timeout (ms) |
PAGE_TIMEOUT |
10000 |
Page load timeout (ms) |
ACTION_TIMEOUT |
5000 |
Browser action timeout (ms) |
LOG_LEVEL |
INFO |
Logging level |
-
Python version errors
- Ensure you have Python 3.13+:
python3 --version - On some systems, use
python3.13instead ofpython3 - Make sure Python is in your PATH
- Ensure you have Python 3.13+:
-
uv installation issues
- If
pip install uvfails, try the curl method:curl -LsSf https://astral.sh/uv/install.sh | sh - Restart your terminal after installation
- On Windows, you may need to add uv to your PATH manually
- If
-
Node.js/npm issues
- Use Node.js LTS version (18+) for best compatibility
- If npm is slow, try using a different registry:
npm config set registry https://registry.npmjs.org/ - Clear npm cache if having issues:
npm cache clean --force
-
Ollama installation issues
- Make sure Ollama service is running:
ollama serve - If model download fails, check your internet connection and try again
- On Linux, you may need to add your user to the ollama group
- Make sure Ollama service is running:
-
Ollama errors / empty responses
- Make sure Ollama is running:
ollama serve - Verify the model exists:
ollama list(should show your configured model) - If model is missing:
ollama pull <model-name>(e.g.,ollama pull granite3.1-dense:8b) - Check Ollama is accessible:
curl http://localhost:11434/api/tags - Verify
OLLAMA_MODELin.envmatches an available model
- Make sure Ollama is running:
-
Environment configuration issues
- Ensure
.envfile exists:make setup-envwill create it from example - Check
.envhas correct values for your setup - Restart services after changing environment variables
- Ensure
-
Playwright browser not launching
- Re-run
uv run python -m playwright install chromiuminbackend/ - Make sure you have sufficient permissions to launch browsers
- Try setting
BROWSER_HEADLESS=truein.envif having display issues
- Re-run
-
CORS issues
- Update
FRONTEND_URLin.envto match your frontend URL - Default allows
http://localhost:5173only
- Update
-
Backend startup issues
- Ensure all dependencies are installed:
cd backend && uv sync - Check Python version:
python --version(should be >= 3.13) - Verify uv is installed:
uv --version - Check environment variables are loaded correctly
- Ensure all dependencies are installed: