← Back to The Sphinx

π“‚€ Architecture

Multi-model orchestration powering The Sphinx

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Browser (Chrome) β”‚ β”‚ FastAPI Server β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ index.html + app.js + style.css β”‚ β”‚ main.py β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ api/routes.py β”‚ β”‚ β”Œβ”€ Web Speech API (STT) ──┐ β”‚ β”‚ β”œβ”€β”€ game/engine.py (rules) β”‚ β”‚ β”‚ Voice β†’ text β†’ question β”‚ β”‚ POST β”‚ β”œβ”€β”€ game/judge.py (fuzzy match) β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”œβ”€β”€β”€β”€β”€β”€β–Ίβ”‚ β”œβ”€β”€ game/characters.py (data) β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ llm/interpreter.py β”‚ β”‚ β”Œβ”€ Audio playback ─────────┐ β”‚ JSON β”‚ β”‚ β”œβ”€ RuleMatcher (regex) β”‚ β”‚ β”‚ ElevenLabs TTS stream │◄───◄─────── β”‚ β”œβ”€ IntentClassifier β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ └─ LLM QuestionInterpreter β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ llm/voice.py (Sphinx mood) β”‚ β”‚ β”Œβ”€ Dual interface ─────────┐ β”‚ β”‚ β”œβ”€β”€ llm/full_llm_handler.py β”‚ β”‚ β”‚ Chat mode / Voice mode β”‚ β”‚ β”‚ β”œβ”€β”€ tts/client.py (ElevenLabs) β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ └── store/memory.py (sessions) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚ Mistral AI β”‚ β”‚ ElevenLabs β”‚ β”‚ Amazon β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ Bedrock β”‚ β”‚ Large: Sphinxβ”‚ β”‚ Flash v2.5 β”‚ β”‚ β”‚ β”‚ personality β”‚ β”‚ TTS voice β”‚ β”‚ Claude 3.5 β”‚ β”‚ + answers β”‚ β”‚ streaming β”‚ β”‚ Llama 3.1 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ Cohere R+ β”‚ β”‚ Small: Intentβ”‚ β”‚ "Adam" deep β”‚ β”‚ Nova Pro β”‚ β”‚ classifier β”‚ β”‚ mysterious β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ AI Opponentsβ”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ MCP Server β”‚ β”‚ β”‚ β”‚ 7 tools for β”‚ β”‚ AI agents to β”‚ β”‚ play the gameβ”‚ β”‚ via protocol β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

𓁹 The Sphinx Brain

Mistral Large interprets free-form questions, generates theatrical responses with mood-aware personality, and guards the secret character's identity.

mistral-large-latest

π“‚€ Intent Classifier

Mistral Small runs fast intent classification β€” is it a question, a guess, or something else? Sub-200ms pre-filter before the main LLM.

mistral-small-latest

𓆣 Voice of the Sphinx

ElevenLabs streams a deep, mysterious TTS voice in real-time. The Sphinx speaks with gravitas.

eleven_flash_v2_5

⚑ AI Opponents

Four AI personas powered by Amazon Bedrock compete against human players in duel mode, each with a unique strategy and personality.

Bedrock Converse API

π“Š— MCP Server

AI agents can play LeSphinx programmatically through 7 MCP tools. Connect via stdio or SSE transport.

Model Context Protocol

𓃭 Truth Engine

Deterministic answer resolution from structured character data. The LLM never decides what's true β€” only how to say it.

RuleMatcher + FactStore

Game Flow

  1. 1
    Player asks a question by voice or text
    Web Speech API β†’ FastAPI
  2. 2
    RuleMatcher tries regex patterns for common attributes
    Deterministic, <1ms
  3. 3
    Intent Classifier determines: question vs guess
    Mistral Small, ~150ms
  4. 4
    Question Interpreter parses the question into structured attributes
    Mistral Large, ~400ms
  5. 5
    Answer Resolver checks against character facts deterministically
    FactStore lookup
  6. 6
    Sphinx Voice generates a theatrical, mood-aware response
    Templates + Mistral Large fallback
  7. 7
    ElevenLabs streams the Sphinx's voice to the player
    TTS streaming, ~300ms first byte

API Endpoints

MethodPathDescription
POST/game/newCreate a new game session
POST/game/{id}/askAsk a yes/no question
POST/game/{id}/guessGuess the character
POST/game/{id}/hintRequest a hint
GET/game/{id}/stateGet current game state
POST/game/{id}/ai_turnExecute AI opponent's turn
GET/ai/personasList AI opponent personas
GET/leaderboardView top scores & stats
POST/leaderboardSubmit score

Character Database

161 curated famous characters across 14 themes, 3 difficulty levels. Each character has structured attributes, facts, aliases, bilingual summaries, and photos.