β 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
Player asks a question by voice or text
Web Speech API β FastAPI
- 2
RuleMatcher tries regex patterns for common attributes
Deterministic, <1ms
- 3
Intent Classifier determines: question vs guess
Mistral Small, ~150ms
- 4
Question Interpreter parses the question into structured attributes
Mistral Large, ~400ms
- 5
Answer Resolver checks against character facts deterministically
FactStore lookup
- 6
Sphinx Voice generates a theatrical, mood-aware response
Templates + Mistral Large fallback
- 7
ElevenLabs streams the Sphinx's voice to the player
TTS streaming, ~300ms first byte
API Endpoints
| Method | Path | Description |
POST | /game/new | Create a new game session |
POST | /game/{id}/ask | Ask a yes/no question |
POST | /game/{id}/guess | Guess the character |
POST | /game/{id}/hint | Request a hint |
GET | /game/{id}/state | Get current game state |
POST | /game/{id}/ai_turn | Execute AI opponent's turn |
GET | /ai/personas | List AI opponent personas |
GET | /leaderboard | View top scores & stats |
POST | /leaderboard | Submit score |
Character Database
161 curated famous characters across 14 themes, 3 difficulty levels. Each character has structured attributes, facts, aliases, bilingual summaries, and photos.