A Socratic TTS coding assistant that watches your Jupyter notebook and speaks guiding questions when you go off-track
Project description
๐ง Socratic Watchdog
A Socratic TTS coding assistant that watches your Jupyter notebook cells, analyzes them through the lens of the Socratic method, and speaks guiding questions when you go off-track. Stays silent when your code is correct โ and celebrates with confetti when you get it right.
"I cannot teach anybody anything, I can only make them think." โ Socrates
Features
| Feature | Description |
|---|---|
%%socratic cell magic |
Analyse one cell at a time |
%socratic_watch on |
Auto-watch every cell you run |
%socratic_task auto |
Auto-detect task from markdown above |
| Embedded test cases | %socratic_tests โ embed expected behaviour (--hidden for invisible tests) |
| Auto-generated tests | %socratic_generate_tests โ LLM writes test cases from the task |
| Fast path | When tests pass, skips LLM entirely โ instant silent + confetti |
| Three TTS backends | Kokoro (local neural, default) / edge-tts (cloud neural) / espeak-ng (local robotic) |
| Socratic method | Never gives answers โ only asks guiding questions |
| Subtitle boxes | Questions and praise shown as styled UI boxes alongside audio |
| Confetti + praise | Random Socratic praise + confetti animation on correct answers |
| Timing stats | %socratic_stats โ per-step wall-clock breakdown |
| Works everywhere | JupyterLab, Notebook, Colab, VS Code |
Quick start
%load_ext socratic_watchdog
%socratic_task Write a function that calculates Fibonacci numbers
%%socratic
def fib(n):
return fib(n-1) + fib(n-2) # missing base case!
Socrates will (verbally) ask something like:
"I see your function calls itself โ what condition would stop this recursion?"
When you fix it and it's correct, you'll get confetti and something like:
"Well done! You are thinking clearly."
Installation
pip install socratic-watchdog
The package has zero required dependencies beyond ipython. TTS backends and LLM access are configured via optional extras or environment variables:
# Optional: install a specific TTS backend
pip install socratic-watchdog[edge-tts] # Microsoft neural voices (cloud, free)
pip install socratic-watchdog[kokoro] # Local neural TTS (82M model, needs torch)
No extra install needed for espeak-ng โ it's invoked via the system espeak-ng binary if present.
LLM access
The package calls an LLM to analyse your code. Two backends, auto-fallback:
| Backend | Env var | Default? |
|---|---|---|
| Direct API (DeepSeek / OpenAI-compatible) | SOCRATIC_LLM_BACKEND=direct |
โ default |
Hermes CLI (hermes chat -q) |
SOCRATIC_LLM_BACKEND=hermes |
fallback |
The direct API path tries these env vars in order: SOCRATIC_LLM_API_KEY โ DEEPSEEK_API_KEY โ OPENAI_API_KEY. If none are set, it falls back to Hermes CLI automatically.
How it works
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโ
โ Cell runs โ โ โ Capture โ โ โ LLM with โ โ โ On track?โ
โ (source + โ โ source code โ โ Socrates โ โ โ SILENT โ
โ traceback) โ โ + error โ โ persona โ โ Off trackโ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโ โ โ TTS Q โ
โโโโโโโโโโโโ
When test cases are set (via %socratic_tests or %socratic_generate_tests), there's a fast path: if the code passes all tests, the LLM is skipped entirely โ instant silent + confetti.
The Socrates persona instructs the LLM to:
- Never give direct answers or show corrected code
- Ask exactly one guiding question
- Reference something specific in the student's code
- Stay completely silent when correct
Commands
| Magic | What it does |
|---|---|
%%socratic |
Run a cell with Socratic analysis |
%socratic_task <goal> |
Describe your coding goal |
%socratic_task auto |
Auto-detect task from markdown cell above |
%socratic_task clear |
Remove the task |
%socratic_task |
Show current task |
%socratic_tests |
Embed expected test cases (cell body becomes tests) |
%socratic_tests --hidden |
Same, but students never see the tests |
%socratic_generate_tests |
LLM auto-generates hidden test cases from the task |
%socratic_watch on |
Watch every cell automatically (3 s debounce) |
%socratic_watch off |
Stop auto-watching |
%socratic_off |
Quick alias to stop |
%socratic_reset |
Clear task, tests, and cached notebook data |
%socratic_stats |
Show timing breakdown of last analysis |
%socratic_help |
Show usage help |
Test cases
Pre-assigned test cases let Socrates check correctness deterministically โ no LLM guesswork:
%load_ext socratic_watchdog
%socratic_task Write a function that checks if a number is even
%%socratic_tests
assert is_even(0) == True
assert is_even(1) == False
assert is_even(42) == True
assert is_even(-7) == False
# Now Socrates knows the exact expected behaviour.
# When the student's code passes all tests โ instant silent + confetti.
# When it fails โ test failure output is fed to the LLM for better questions.
Use --hidden to keep tests invisible to students (they still run):
%%socratic_tests --hidden
assert is_even(0) == True
assert is_even(100) == True
Or let the LLM generate them from the task:
%socratic_task Write a function that reverses a string
%socratic_generate_tests # LLM writes 4-6 assert statements, cached on disk
Configuration
TTS
| Env var | Default | Description |
|---|---|---|
SOCRATIC_TTS_BACKEND |
kokoro |
kokoro (local neural, ~3.8 s), edge-tts (cloud neural, ~3 s), or espeak (local robotic, ~0.03 s) |
SOCRATIC_TTS_VOICE |
en-US-AndrewNeural |
Voice for edge-tts |
SOCRATIC_KOKORO_VOICE |
af_heart |
Kokoro voice pack (af_heart, am_adam, bm_lewis, etc.) |
SOCRATIC_ESPEAK_VOICE |
en-us |
Voice for espeak-ng |
LLM
| Env var | Default | Description |
|---|---|---|
SOCRATIC_LLM_BACKEND |
direct |
direct (API call) or hermes (CLI). Both auto-fallback to the other. |
SOCRATIC_LLM_BASE_URL |
https://api.deepseek.com |
API base URL (also reads OPENAI_BASE_URL) |
SOCRATIC_LLM_API_KEY |
โ | API key (also reads DEEPSEEK_API_KEY, OPENAI_API_KEY) |
SOCRATIC_LLM_MODEL |
deepseek-chat |
Model name |
SOCRATIC_LLM_TIMEOUT |
30 |
Seconds to wait for LLM |
HERMES_PROFILE |
dev |
Hermes profile used when SOCRATIC_LLM_BACKEND=hermes |
Other
| Env var | Default | Description |
|---|---|---|
SOCRATIC_DEBUG |
(unset) | Set to 1 to print timing breakdown after each analysis |
SOCRATIC_TESTS_CACHE |
~/.hermes/socratic_tests_cache/ |
Cache directory for auto-generated test cases |
Architecture
socratic_watchdog/
โโโ _core.py # Core engine (no IPython deps โ works anywhere)
โ โโโ SocraticWatchdog.analyze() # prompt โ LLM โ question/silence
โ โโโ SocraticWatchdog.speak() # text โ TTS (kokoro/edge-tts/espeak) โ Audio
โ โโโ SocraticWatchdog.generate_tests() # LLM โ test cases (disk-cached)
โ โโโ _call_llm() # direct API + hermes CLI fallback
โโโ magics.py # IPython magics + post-run hook
โ โโโ %%socratic, %socratic_task, %socratic_tests, etc.
โ โโโ _post_run_cell_hook # auto-watch mode
โ โโโ confetti animation # canvas confetti on correct answers
โ โโโ 90+ Socratic praise phrases # random praise on correct answers
โโโ __init__.py # %load_ext entry point
License
MIT
Related
- jupyter-hermes-personalities โ the Socrates personality source
- edge-tts โ free TTS engine
- Kokoro โ local neural TTS (82M model)
- Hermes Agent โ the agent framework
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file socratic_watchdog-0.2.0.tar.gz.
File metadata
- Download URL: socratic_watchdog-0.2.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
471ac923d29bb370d15f4b8b2136291e14a30b6b84285c5fb8ed818ffdd628ae
|
|
| MD5 |
ae9fdbf64d79329f5a78bf9cdc190da6
|
|
| BLAKE2b-256 |
20dabeefc5eaffcdf616eab02dc6effd53816616624b08a559cdf9f4773054b7
|
Provenance
The following attestation bundles were made for socratic_watchdog-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on xamzar/socratic-watchdog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
socratic_watchdog-0.2.0.tar.gz -
Subject digest:
471ac923d29bb370d15f4b8b2136291e14a30b6b84285c5fb8ed818ffdd628ae - Sigstore transparency entry: 1921457249
- Sigstore integration time:
-
Permalink:
xamzar/socratic-watchdog@58c7ef84da3b75017941ceb2d22f2e0cb33d0bd4 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/xamzar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@58c7ef84da3b75017941ceb2d22f2e0cb33d0bd4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file socratic_watchdog-0.2.0-py3-none-any.whl.
File metadata
- Download URL: socratic_watchdog-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
257bcf94fbb77cdd6ff22c3b29893da196cde5d3dd155fd69a56f86b910960db
|
|
| MD5 |
f426139d64b81f9f091dbe533454f687
|
|
| BLAKE2b-256 |
727648efd9d2fcd6cb8e5b8d762aa5503abdd5585fe969d3a910b7a3b63d89f7
|
Provenance
The following attestation bundles were made for socratic_watchdog-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on xamzar/socratic-watchdog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
socratic_watchdog-0.2.0-py3-none-any.whl -
Subject digest:
257bcf94fbb77cdd6ff22c3b29893da196cde5d3dd155fd69a56f86b910960db - Sigstore transparency entry: 1921457328
- Sigstore integration time:
-
Permalink:
xamzar/socratic-watchdog@58c7ef84da3b75017941ceb2d22f2e0cb33d0bd4 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/xamzar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@58c7ef84da3b75017941ceb2d22f2e0cb33d0bd4 -
Trigger Event:
push
-
Statement type: