Skip to content

ItsPranavz/inteliboard-ai

Repository files navigation

InteliBoard AI

Generate 3Blue1Brown-style explainer videos from a natural-language prompt. Type "explain how a derivative works" and get back a short Manim animation with synchronized on-screen text labels, a natural-sounding voice narration, and optional real-world images / icons / charts pulled from external sources.

Powered by a plan-then-code LLM pipeline with a unified post-render vision-LLM QA pass (overlap detection + audio-visual sync verification) that attaches the actual failing frames to the repair prompt — visual reward weighted 4× the text reward per the April 2026 ManimAgent paper.

Powered by

  • DeepSeek v3.2 via OpenRouter for planning + code generation (default — cheap, structured-output friendly, Manim-savvy).
  • Claude Haiku 4.5 as the multimodal repair model (sees the broken frames when QA finds a problem).
  • Gemini 2.5 Flash for vision QA (overlap sweep + per-sentence sync check).
  • Override any model via the Advanced settings or INTELIBOARD_MODEL. For best-quality runs at ~3× cost, use INTELIBOARD_MODEL=anthropic/claude-sonnet-4.6.
  • Manim Community Edition v0.20.1 for rendering.
  • Microsoft Edge TTS (free, no key, ~100 natural voices) with word-level timestamps for sync verification.
  • External-graphics fallbacks: matplotlib charts → Wikimedia Commons → Iconify SVGs → Pollinations.ai AI-image (vision-vetted before code-gen sees the path).
  • Skill guides injected into the system prompts:
    • PLANNING_SKILL.md — pedagogy (Mayer's principles, Cognitive Load Theory, inverted-pedagogy hard rule), brainstorming framework, narrative-arc enum, style archetypes, difficulty calibration.
    • MANIM_SKILL.md — Manim primitives, region partitioning, transformation pacing, the 3B1B technique playbook.
  • Gradio for the optional web UI with live cost preview + multi-candidate display.

Quick start

1. Install system dependencies (macOS)

brew install ffmpeg cairo pango pkg-config libffi

2. (Optional) Install BasicTeX for math equations

Only needed if you want MathTex (rendered LaTeX formulas). Without it, InteliBoard auto-rewrites MathTexText with Unicode glyphs (a² + b² = c², ∫₀¹ x² dx, sin²θ + cos²θ = 1, Σ, π, ).

brew install --cask basictex
eval "$(/usr/libexec/path_helper)"

sudo tlmgr update --self
sudo tlmgr install standalone preview doublestroke ms setspace rsfs \
    relsize ragged2e fundus-calligra microtype wasysym physics dvisvgm \
    jknapltx wasy cm-super

3. Set up Python

cd "InteliBoard AI"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

4. Add your API key

cp .env.example .env
# Edit .env: OPENROUTER_API_KEY=sk-or-v1-...

5. Generate your first video

python main.py "explain the Pythagorean theorem"

The rendered video lands in output/. Default settings produce a ~30 s, 480p, narrated explainer for ~$0.10–$0.20 of OpenRouter credits.


Usage

CLI

python main.py "explain the Pythagorean theorem"

Options:

Flag Default Notes
--difficulty {beginner,intermediate,advanced} intermediate Beginner = visual, fewer formulas. Advanced = formula-heavy, fast pacing.
--length {auto,short,medium,long} auto short=15-30s, medium=30-60s, long=60-120s.
--style {auto,technical,storytelling,socratic,example-driven,visual-first,historical} auto Explanation archetype.
--quality {l,m,h} l l=480p15 (fast, ~30 s), m=720p30, h=1080p60.
--narrate on TTS voiceover muxed onto the video.
--voice en-US-AndrewNeural Any Edge TTS voice. List with python -m edge_tts --list-voices.
--model $INTELIBOARD_MODEL or deepseek/deepseek-v3.2 Code-gen model.
--planning-model DeepSeek v3.2 Planning model.
--repair-model Claude Haiku 4.5 (multimodal) Used on retries; sees the broken frames.
--vision-model Gemini 2.5 Flash Overlap + sync QA.
--max-retries 1 Repair attempts on QA failure. Each retry is one full render.
--output-dir output Where the .mp4, .py, and .plan.json land.
--no-open off Skip auto-launching QuickTime.
--no-strict-layout off Disable the post-render overlap sweep.
--no-strict-sync off Disable the narration-vs-screen sync check.
--no-strict-precheck off Disable pre-render static checks (LaTeX gate, axis-range, 3D mismatch).
--no-planning off Skip the planning phase (much faster, lower quality).
--enable-graphics / --no-graphics enabled Allow the planner to request matplotlib charts, Wikimedia images, Iconify SVGs, or Pollinations.ai fallbacks. Each fetched asset is vision-vetted.

Web UI (Gradio)

python web.py

Opens at http://localhost:7860. Features:

  • Live cost preview under the prompt textbox — recomputes as you change settings.
  • Two-step flow: enter a concept → get clarifying questions → answer them (or skip) → render. Answers go into the planner as context.
  • Best-of-N: in Advanced settings, set N=2..4 to render multiple candidates in parallel. A judge LLM ranks them by visual quality; all candidates are surfaced in the UI, best-first labelled "🏆 Best of N".
  • All five model fields are overridable: code-gen, planning, repair, vision QA, asset vetting.
  • External graphics on by default — uncheck for pure-Manim videos.

HTTP API

Two POST endpoints with full OpenAPI documentation at /docs:

  • POST /api/get_questions — submit a concept, get up to 5 clarifying questions back.
  • POST /api/render_video — submit the concept + answers, receive paths to the rendered MP4 + scene file + plan JSON.

See API.md for the full schema.


How it works

prompt
  │
  ▼
┌─────────────────────────────────────────────────────────┐
│ PLAN          DeepSeek v3.2                              │
│   • narrative_arc, aha_moment, primitive_manifest        │
│   • per-section: role, narration, visualization, caption │
└─────────────────────────────────────────────────────────┘
  │
  ├──▶ GRAPHICS  (when enable_graphics=true and the planner requested any)
  │      • matplotlib chart  /  Wikimedia image
  │      • Iconify SVG       /  Pollinations.ai AI fallback
  │      • Each vetted by Gemini Flash before code-gen sees the path
  │
  ├──▶ TTS       Edge TTS, per-section, with insight-beat dwell
  │
  ▼
┌─────────────────────────────────────────────────────────┐
│ CODE-GEN + STATIC CHECK + REPAIR (up to MAX_PRE_RENDER)  │
│   • DeepSeek v3.2 emits scene_name + python_code + narr │
│   • patch_implicit_latex auto-fixes Title / axis_config │
│   • static_check: LaTeX gate · axis-range fit ·         │
│     3D narration mismatch · duration sanity              │
│   • Failures → repair prompt → Haiku 4.5 (multimodal)    │
└─────────────────────────────────────────────────────────┘
  │
  ▼
┌─────────────────────────────────────────────────────────┐
│ RENDER  manim --save_sections                           │
└─────────────────────────────────────────────────────────┘
  │
  ▼
┌─────────────────────────────────────────────────────────┐
│ VISION QA (overlap + sync, parallel, Gemini Flash)       │
│   • overlap_check: 28 frames sweep · structured schema  │
│     with pattern + elements + fix_hint                   │
│   • sync_check:   per-sentence midpoint frame ·         │
│     expected_referent vs what_is_on_screen + fix_hint   │
└─────────────────────────────────────────────────────────┘
  │
  ▼ (clean)         (failing)
SHIP             REPAIR: failing frames attached to Haiku 4.5
                  → re-render (up to max_retries)
  │
  ▼
MUX  per-section audio + video → final MP4

For best-of-N: each candidate runs the full pipeline in its own isolated output/candidate_K/ directory (separate .manim_media/ per candidate so parallel renders don't collide). After all candidates finish, a judge LLM ranks them from a contact-sheet of one keyframe per candidate.


Visualization catalog

visualization_db/ contains 52 pre-validated Manim snippets used as templates during code generation, scored by topic-keyword + synonym + narrative-pattern matching:

Category Count Examples
Primitives 21 circle, axes, mathtex, number-plane, brace, polygon
Animations 7 transform-matching-tex, lagged-start, value-tracker, write
Compositions 24 pythagorean-squares, unit-circle-sine, taylor-series, gradient-descent, bayes-grid, morph-equivalence-algebra, before-after-area, zoom-into-curve, cancel-and-vanish, parameter-sweep-reveal, concrete-to-abstract-counting, term-to-region-color, lagged-decomposition-sum, layer-by-layer-fourier, indicate-sequence-proof, split-screen-method-compare, morph-graph-to-graph, options-payoff

Each entry includes a runnable code.py, a description.md with metadata (id, narrative_pattern, pedagogical_role, topic_keywords, when-to-use), and a rendered render.mp4.

Rebuild after editing:

python -m inteliboard.viz_catalog --build    # regenerate catalog.json
python -m inteliboard.viz_catalog --render   # render every code.py

Cost & performance

Typical numbers with the default models (DeepSeek v3.2 + Haiku 4.5 + Flash):

Configuration Wall-clock Cost
First-pass clean render, 480p ~30 s ~$0.05–0.08
Render + 1 repair retry, 480p ~60–90 s ~$0.10–0.15
Best-of-N=3, parallel, 480p ~60–90 s ~$0.15–0.30
720p +30–60 s same model cost
INTELIBOARD_MODEL=anthropic/claude-sonnet-4.6 same ~3× the LLM cost

Defaults are tuned for sub-1-minute typical generation. To dial up quality at the cost of time/money: bump --quality m, --max-retries 2, or set INTELIBOARD_MODEL=anthropic/claude-sonnet-4.6 for the code-gen pass.


Troubleshooting

! LaTeX Error: File 'standalone.cls' not found Missing LaTeX packages. Run the tlmgr install command from Quick start step 2. Or just skip LaTeX — InteliBoard auto-rewrites MathTex to Unicode Text when latex isn't on PATH.

Render failed after all retries. The LLM produced uncompilable Manim code N times in a row. Look at output/<SceneName>.py. Common causes: deprecated API (try --model anthropic/claude-sonnet-4.6 for a smarter coder), or a prompt that needs more clarifying context (use the web UI's two-step flow).

TruncatedResponseError: LLM response was truncated The LLM was cut off mid-string. Already mitigated by disabling reasoning tokens; if it still fires, the prompt is too long. Try --length short.

Provider returned error 400 ... 'minItems' values other than 0 or 1 are not supported A Bedrock provider quirk — should never happen now (InteliBoard pins Anthropic models to Anthropic-direct + Google Vertex only). If you see this, your INTELIBOARD_PLANNING_MODEL is a non-Anthropic model with a Bedrock route; pin it explicitly.

OPENROUTER_API_KEY is not set Copy .env.example to .env and fill in your key.

media/ directory growing unbounded Manim caches intermediate frames per render. Each render now nests its cache in output/<scene>/.manim_media/ (or output/candidate_K/.manim_media/ for best-of-N). Safe to delete between runs.

Gradio port 7860 in use Gradio auto-picks the next free port; check stdout for the actual URL.


Research

See RESEARCH_NOTES.md for the literature review that shaped the design — TEA, Manimator, ManimAgent (April 2026, the visual-reward 0.8 finding), ReLook, Self-Refine, Reflexion, CEDAR, Mayer's principles, the Oxford TEAMAT taxonomy of 3B1B didactic roles, and a model/library comparison table with InteliBoard's specific design decisions.


License

MIT — see LICENSE.

About

AI-powered 3b1b style manim video generator - visualize any concept.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages