mindsphere_coach / README.md
Mahault
Add HF Spaces metadata to README
12660b0
metadata
title: MindSphere Coach
emoji: 🧠
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860

MindSphere Coach

An interactive coaching agent that uses Active Inference, Theory of Mind, and empathic planning to help people identify and overcome personal growth bottlenecks.

Unlike standard coaching chatbots, MindSphere maintains a computational model of the user's mind β€” it infers why a recommendation will or won't work, and adapts in real time.

How It Works

  1. Calibration β€” 10 adaptive questions assess 8 skill dimensions (focus, follow-through, social courage, emotional regulation, systems thinking, self-trust, task clarity, consistency)
  2. Visualization β€” an interactive radar chart ("MindSphere") shows your skill profile with dependency edges highlighting bottlenecks
  3. Coaching β€” the agent proposes personalized micro-interventions, predicts your response via Theory of Mind, and adapts based on your feedback

The agent is a companion first, coach second β€” it follows your lead, talks about anything, and weaves coaching insights naturally into conversation.

Architecture

Core Engine (Active Inference)
β”œβ”€β”€ Factored POMDP β€” 12 state factors, mean-field belief updates
β”œβ”€β”€ EFE action selection β€” pragmatic + epistemic drives
└── Dirichlet parameter learning β€” A/B matrices refine with experience

Theory of Mind
β”œβ”€β”€ Particle filter β€” 50 particles over 7-dim user type space
β”œβ”€β”€ Reliability gating β€” entropy-based confidence threshold
└── Empathic planning β€” G_social blending with counterfactuals

User Profile (Bayesian Network)
β”œβ”€β”€ LLM-extracted facts β€” life events, goals, challenges, context
β”œβ”€β”€ Causal edges β€” "breakup β†’ emotional_stress β†’ focus_impaired"
└── Forward belief propagation β€” inferred states feed into POMDP

Emotional Inference (Circumplex Model)
β”œβ”€β”€ Predict β†’ Observe β†’ Update loop
β”œβ”€β”€ 8-state POMDP over valence Γ— arousal
└── Prediction error tracking

LLM Layer (Mistral)
β”œβ”€β”€ Dynamic system prompt β€” beliefs, ToM, emotions, profile injected
β”œβ”€β”€ Natural conversation β€” companion-style, not scripted
└── Structured extraction β€” profile facts + causal links via JSON

Quick Start

Option 1: Double-click (Windows)

Just double-click START.bat β€” it checks for Python, installs dependencies, and opens the app in your browser.

Option 2: Command line

Prerequisites: Python 3.10+

# Clone
git clone https://github.com/mahault/mindsphere-coach.git
cd mindsphere-coach

# Install
pip install -e .

# (Optional) Add your Mistral API key for LLM-powered conversation
cp .env.example .env
# Edit .env and add: MISTRAL_API_KEY=your_key_here

# Run
python scripts/run_demo.py

Then open http://localhost:8000 in your browser.

API Key

The app works without an API key (template-based responses), but for natural LLM-powered conversation you need a Mistral API key:

  1. Copy .env.example to .env
  2. Replace your_mistral_api_key_here with your actual key

Project Structure

src/mindsphere/
β”œβ”€β”€ core/           # Active Inference engine
β”‚   β”œβ”€β”€ agent.py        # Main orchestrator (~2100 lines)
β”‚   β”œβ”€β”€ model.py        # Factored POMDP: A/B/C/D matrices
β”‚   β”œβ”€β”€ inference.py    # Belief updates, EFE computation
β”‚   β”œβ”€β”€ user_profile.py # Bayesian network user model
β”‚   β”œβ”€β”€ emotional_state.py  # Circumplex emotion POMDP
β”‚   β”œβ”€β”€ learning.py     # Dirichlet parameter learning
β”‚   └── dependency_graph.py # Skill dependency DAG
β”‚
β”œβ”€β”€ tom/            # Theory of Mind module
β”‚   β”œβ”€β”€ particle_filter.py  # User type inference
β”‚   β”œβ”€β”€ empathy_planner.py  # G_social blending
β”‚   └── trust.py            # Reliability gating
β”‚
β”œβ”€β”€ llm/            # Mistral LLM layer
β”‚   β”œβ”€β”€ client.py       # API client
β”‚   β”œβ”€β”€ generator.py    # Conversational engine
β”‚   └── classifier.py   # Structured classification
β”‚
β”œβ”€β”€ content/        # Questions & interventions
β”œβ”€β”€ api/            # FastAPI + WebSocket backend
β”œβ”€β”€ viz/            # Plotly chart generation
└── frontend/       # Vanilla JS + Plotly SPA

Running Tests

pip install -e ".[dev]"
pytest tests/ -v

102 tests covering the POMDP model, inference, particle filter, empathy planner, emotional state, and full integration pipeline.

License

MIT