Skip to content

About

Open-source local-first AI mental health chatbot and CBT journal powered by Ollama, with RAG, session memory, mood and sleep tracking, self-assessments, and guided SOS exercises.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

23 stars

Watchers

0 watching

Forks

Repository files navigation

CBT Assistant — local-first CBT journal and AI mental health chatbot on Ollama

An offline, self-hosted cognitive behavioral therapy (CBT) app: structured thought records, mood and sleep tracking, clinical self-assessments, and guided SOS exercises — plus a chat assistant grounded in a built-in CBT knowledge base via RAG. No cloud and no account; the model runs on your own machine through Ollama.

CBT Assistant opening SOS breathing support, reframing an anxious thought, and saving it to the Thought Diary

Quick start

# macOS 14+
git clone https://github.com/KazKozDev/cbt-assistant.git && cd cbt-assistant && ./start_cbt_assistant.command
# Windows 10 22H2+ (PowerShell or cmd)
git clone https://github.com/KazKozDev/cbt-assistant.git
cd cbt-assistant
start_cbt_assistant.bat

The launcher sets up the Python environment, prepares Ollama, downloads qwen3.5:9b (~6.6 GB), starts the server on port 8000, and opens your browser; later launches reuse the same setup. On Linux, make sure ollama serve is running, run the steps manually, and open http://localhost:8000. English and Russian are switchable in Settings.

Hardware requirements: 16 GB RAM recommended for qwen3.5:9b (8 GB is sufficient if switching to smaller 3B/4B models in Settings), ~10 GB free disk space for model weights and the local embedding index.

Important

CBT Assistant is a self-help and journaling tool — not a therapist, medical device, or crisis service. Its knowledge base follows evidence-based CBT protocols, but AI responses and self-assessments can still be wrong. If you may be in immediate danger or at risk of harming yourself or someone else, contact local emergency services or a crisis line now.

CBT journal, mood tracker, self-assessments, and SOS exercises

  • Thought Diary — situations, automatic thoughts, emotions and intensities, cognitive distortions, rational responses.
  • Mood & Sleep Logs — daily scores and notes, sleep duration, interruptions, quality.
  • Self-Assessments — PHQ-9, GAD-7, Rosenberg Self-Esteem, and Burnout, with score interpretation.
  • Dashboard & Calendar — mood and sleep trends over time, and a month view unifying every daily entry.
  • SOS Portals — fullscreen paced breathing, 5-4-3-2-1 grounding, progressive muscle relaxation, and STOP, with scenes, sound, and countdowns.
  • Reports — text summaries or printable PDF, generated in the browser.

Private AI mental health chatbot with local memory

  • Warm, non-judgmental dialogue with qwen3.5:9b running locally — core chat generation never leaves your machine.
  • Grounded, not improvised: clinical guidance is retrieved from the bundled CBT library via FastEmbed RAG and cited as [KB:chunk_id]. Below the similarity threshold (0.46) the assistant offers supportive conversation instead of inventing protocols — measured at recall@3 85.7%, MRR 0.70, 100% abstention accuracy across 18 retrieval cases.
  • Writes your records for you: ask it to log a thought record or a sleep entry, launch an agreed SOS portal, or schedule a planned activity.
  • Remembers you across restarts: a personal profile and rolling summary persist in SQLite, so chats aren't isolated.
  • Voice mode (optional) — speech recognition and neural text-to-speech in English and Russian (requires internet access).

How the local CBT assistant works

CBT Assistant architecture

At startup the Markdown CBT library is split by heading hierarchy and embedded locally with FastEmbed (paraphrase-multilingual-mpnet-base-v2); semantic retrieval strictly runs before response generation. Messages, structured records, and profile memory live in SQLite (data/cbt_sessions.db), while interface logs and screening state also use browser localStorage. Frontend UI assets (Inter font, Lucide icons, and Chart.js for dashboard and PDF reports) are bundled locally for 100% offline use.

GET    /api/knowledge/search?q=sleep&top_k=3
GET    /api/knowledge/status
GET    /api/memory/{session_id}
DELETE /api/memory/{session_id}

Retrieval quality

The threshold is measured, not guessed. evals/rag_retrieval.json holds 18 versioned cases — 14 that must return a specific knowledge-base section and 4 out-of-scope questions that must return nothing at all — scored by src/rag/evaluation.py:

Metric Result
recall@3 85.7% (0.857)
MRR 0.702
Abstention accuracy (negative cases) 100% (1.0)

Measured on paraphrase-multilingual-mpnet-base-v2 at threshold 0.46, index version a07db2f30577badb, 53 chunks. The lowest passing positive scored 0.495 and the highest negative scored 0.255 — the threshold sits in that gap. Reproduce with:

python scripts/evaluate_rag.py --top-k 3 --threshold 0.46

This is a repository regression set, not a clinical-quality evaluation.

Data sovereignty & storage

  • Database location: data/cbt_sessions.db (single-file SQLite database).
  • Backups: Copy data/cbt_sessions.db to back up all diary entries, tests, and conversation memory.
  • Data deletion: Delete data/cbt_sessions.db and click Reset all data in Settings to clear browser localStorage.

Index caching, rebuilds, and degraded-mode behaviour are described in ARCHITECTURE.

Limitations & Safety

  • Crisis safety — CBT Assistant is designed for self-help and mild-to-moderate distress; it does not include automated real-time suicide or crisis detection. If you are experiencing acute distress, self-harm impulses, or suicidal thoughts, please contact local emergency services or a crisis line (e.g., 988 in the US/Canada, 112 in the EU).
  • Network — core chat, RAG, and journaling are 100% offline. Optional voice features (edge-tts synthesis, browser Web Speech API) and YouTube ambient media connect to external services.
  • Security — binds to 127.0.0.1:8000 by default (safe on public Wi-Fi). If you expose it to a local network (HOST=0.0.0.0), note that it has permissive CORS and no authentication layer; keep it off public or untrusted networks.
  • Performance — chat quality, latency, and memory use depend on your hardware and model; chat is unavailable until the embedding index finishes building.
  • Platform — no Docker image and no Linux launcher; Linux setup is manual.


CBT Assistant Art Flow   CBT Assistant Art Mind



macOS Windows Linux CI Python 3.10+ License: MIT

Issues · ARCHITECTURE · Privacy & Safety · LICENSE · LinkedIn

About

Open-source local-first AI mental health chatbot and CBT journal powered by Ollama, with RAG, session memory, mood and sleep tracking, self-assessments, and guided SOS exercises.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

23 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages