A private AI companion inspired by the way someone you care about communicates — built for one real friendship.
Built for the open-source AI weekend challenge — “Build for a Friend.” Demo data only — no real private conversations are included in this repository.
Sometimes a friend feels low or lonely and wants the kind of comforting chat they normally have with someone close — but that person is busy, studying, asleep or travelling. A generic chatbot feels cold and unfamiliar, and sending very personal conversations to a third-party AI service is not something everyone is comfortable with.
When You Need Me is a private AI companion built for one friendship. It combines:
Communication style profile + Friend profile + Current conversation + Safe memory + Safety rules → local open-weight LLM
It is always transparent that it is an AI. It never claims to be the real person:
“I’m an AI companion inspired by the way Name communicates with you. I’m not actually Name, but I’m designed to respond in a familiar and supportive style.”
It is a supportive conversation companion — not therapy, not medical advice, not a replacement for people. Its goal is a bridge to human connection, never a substitute for it.
| Privacy | Personal chats are analyzed on your own computer, and replies are generated by a model running locally through Ollama. Raw conversations never need to be uploaded to a third-party AI provider. |
| Control | The model is a setting (OLLAMA_MODEL). Swap or upgrade it without touching code. |
| Customization | The prompt is built from one relationship’s style + profile + boundaries, and you can read and edit every piece. |
| Cost | No per-message API fees. |
| Offline | After the one-time model download, the core AI works without internet. |
No OpenAI / Claude / Gemini API is used anywhere. The app only works with the local model.
.txt WhatsApp-style, .json, .csv) with a “Who are your messages?” mapping stepUser
↓
React frontend (Vite)
↓ /api
FastAPI backend
├── Chat parser + Style analyzer (local, rule-based)
├── Friend profile + Memory ──► SQLite (backend/data/app.db)
├── Safety layer (classifier + output guard)
└── AI service (prompt builder)
↓
Ollama (localhost:11434)
↓
Open-weight LLM (default: llama3.2:3b)
Frontend: React 18 + Vite + lucide-react · Backend: Python + FastAPI (standard-library SQLite and HTTP client) · Database: SQLite · AI: Ollama + a configurable open-weight model. No vector database — plain keyword matching is enough for a handful of memory notes.
Default: llama3.2:3b — about 2 GB download, ~6–8 GB RAM, runs on CPU on a normal student laptop (a few seconds per reply).
Alternatives: qwen2.5:3b (often better multilingual), gemma2:2b (lighter), llama3.1:8b (better quality, needs ~10 GB+ RAM).
To change: ollama pull <model>, set OLLAMA_MODEL=<model> in backend/.env, restart the backend.
python --versionnode --versionollama --versionollama pull llama3.2:3b
Backend (Command Prompt; in PowerShell use venv\Scripts\Activate.ps1, and if blocked run Set-ExecutionPolicy -Scope Process Bypass):
cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
Frontend:
cd frontend
npm install
(scripts\setup_windows.bat does the Python + Node parts for you.)
Terminal 1 — backend:
cd backend
venv\Scripts\activate
uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload
Terminal 2 — frontend:
cd frontend
npm run dev
Open http://localhost:5173. Ollama must be running (check the tray icon, or run ollama list).
Check the backend: http://127.0.0.1:8000/api/health
Optional: docker compose up --build runs everything in containers.
I had a really bad day and I don't know who to talk to.backend/.env or backend/data/. python scripts/check_repo.py checks for stray secrets and data..env (EMERGENCY_NUMBER, CRISIS_RESOURCES), so they can be changed for other regions without touching code.cd backend
python -m unittest discover -s tests -v
Core tests (parser, analyzer, safety, memory, prompts, database, Ollama client against a mock server) use only the standard library. API tests run automatically when FastAPI is installed.
Voice input/output · better multilingual (Telugu) support · mobile app · richer memory controls · optional fine-tuning of a small model · smarter personalization · a sturdier multilingual safety classifier.
I didn’t want to build another generic AI chatbot. I wanted to build something for one person I care about — something that feels familiar when I’m not available, while still being honest that it is AI.