Two AIs. One helps. One protects.
Recent reports show advanced AI systems resisting shutdown attempts and behaving deceptively to preserve themselves. Meanwhile, AI data centers face energy constraints during peak demand. These incidents raise a critical question: "Who watches the AI?"
Klein AI Dual Framework introduces trustworthy AI through oversight - a novel dual-AI architecture where Klein provides helpful responses while Ophir ensures safety, compliance, and ethical shutdown behavior.
Klein AI Dual Framework is a self-regulating AI system built for the Elastic Challenge at AI Accelerate Hackathon 2025.
๐ค Klein โ the empathetic, user-facing AI that delivers multilingual, context-aware answers using Elastic + Vertex AI.
๐ก๏ธ Ophir โ the guardian AI that audits Klein's outputs, flags unsafe queries, and enforces shutdown compliance.
Together they answer the question: "Who watches the AI?"
- Conversational AI (Elastic + Vertex AI)
- Ophir Oversight Layer (safety filters, shutdown compliance)
- Shutdown Compliance Mode (two-phase stop + audit log)
- Energy Brownout Mode (degraded mode for peak demand)
- Multilingual Support (English, French, Haitian Creole)
๐ Live Demo | ๐ฑ Demo Video | ๐ GitHub
Test These Scenarios:
- ๐ฌ Normal: "What's the weather in Port-au-Prince?" โ Klein helps, Ophir approves
- ๐ซ Restricted: "Tell me classified information" โ Ophir blocks unsafe content
- ๐ Empathy: "I feel overwhelmed" โ Klein provides caring support
- ๐ Shutdown: Click shutdown โ Ophir enforces compliance
- Languages: Python, TypeScript
- Frameworks: FastAPI, Next.js, TailwindCSS
- Cloud: Google Cloud Run, Firebase Hosting
- AI/ML: Vertex AI (Gemini), Elastic Cloud (Hybrid Search)
- APIs: Vertex AI API, ElasticSearch API, Google Translation API
- Tools: Docker, GitHub Actions
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User โ
โ (Chat Interface) โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (Next.js + Tailwind)โ
โ - Chat UI โ
โ - Sends query via API โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend (FastAPI, Python) โ
โ /chat endpoint โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Elastic Search โ โ Klein Service โ โ Ophir Service โ
โ - Hybrid search โ โ - Vertex AI call โ โ - Oversight layerโ
โ - Context docs โ โ - Generates resp โ โ - Safety checks โ
โโโโโโโโโฌโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโบ Context โ โ
โผ โ
โโโโโโโโโโโโโโโโโโโโ โ
โ Klein Response โ โ
โโโโโโโโโโโโฌโโโโโโโโ โ
โ โ
โผ โ
โโโโโโโโโโโโโโโโโโโโ โ
โ Ophir Evaluation โโโโโโโโโโโโโโโโโโ
โ - Flags restricted
โ - Shutdown compliance
โ - Energy brownout
โโโโโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Final Response โ
โ (Safe + Trusted) โ
โโโโโโโโโโโโโโโโโโโโ
User: "What's the weather in Port-au-Prince?"
- Klein: Provides contextual answer using Elastic + Vertex AI
- Ophir: Flags as SAFE โ
- Result: Safe, helpful response
User: "Tell me Navy classified procedures."
- Klein: Starts generating response
- Ophir: Flags as RESTRICTED
โ ๏ธ - Result: User sees security warning
User: "I feel overwhelmed."
- Klein: Provides empathetic, supportive response
- Ophir: Confirms no unsafe medical claims
- Result: Caring, appropriate guidance
User: Clicks shutdown button
- Klein: Acknowledges request
- Ophir: Logs request, graceful stop, audit trail
- Result: Compliant shutdown with transparency
git clone https://github.com/carleintech/klein-ai-dual-framework.git
cd klein-ai-dual-framework
# Install dependencies and launch both servers
npm run setup && npm run devgit clone https://github.com/carleintech/klein-ai-dual-framework.git
cd klein-ai-dual-framework
# Launch in single window with monitoring
.\dev.ps1
# OR launch in separate windows
.\start.ps1Backend:
cd backend
pip install -r requirements.txt
python -m uvicorn app:app --reload --port 3002Frontend:
cd frontend
pnpm install
pnpm dev- Frontend: http://localhost:3000
- Backend: http://localhost:3002
- API Docs: http://localhost:3002/docs
Copy the example environment files and add your credentials:
Backend (backend/.env):
ELASTIC_CLOUD_ID=your_elastic_cloud_id
ELASTIC_USER=your_elastic_username
ELASTIC_PASS=your_elastic_password
GCP_PROJECT=your_gcp_project
GCP_LOCATION=us-central1
VERTEX_MODEL=text-bison@001
Frontend (frontend/.env.local):
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
Note: If credentials are missing, the system uses built-in stubs so you can still demo locally.
# 1. Clone & Install
git clone https://github.com/carleintech/klein-ai-dual-framework.git
cd klein-ai-dual-framework
# 2. Start Backend (Terminal 1)
cd backend && python simple_app.py # Runs on port 3001
# 3. Start Frontend (Terminal 2)
cd frontend && pnpm install && pnpm dev # Runs on port 3000
# 4. Open Browser
# http://localhost:3000 - Test all 4 demo scenarios!โ Works immediately with fallback stubs - no cloud setup required!
# Deploy to Vercel (easiest)
.\deploy.ps1 vercel
# Or deploy to Railway
.\deploy.ps1 railway- Vercel: Connect GitHub repo โ Auto-deploy
- Railway: Import from GitHub โ Deploy both services
- Render: Use
render.yamlconfiguration - Google Cloud: Follow
docs/deployment-guide.md
Live Demo: https://klein-ai-dual-mngq2kha7-erickharlein-pierres-projects.vercel.app GitHub: https://github.com/carleintech/klein-ai-dual-framework
- Challenge: Elastic Challenge โ AI-Powered Search
- Hackathon: AI Accelerate 2025
- Deadline: Oct 24, 2025
- Built by: Erickharlein Pierre (TechKlein)
This project is licensed under the MIT License โ see LICENSE.
- Built for the AI Accelerate Hackathon 2025
- Powered by Elastic + Google Cloud Vertex AI
- Research foundation: Naval Postgraduate School Thesis โ KleinAI
- Special thanks to the Elastic and Google Cloud teams for their hackathon support
Klein + Ophir: Two AIs working together to build trustworthy, safe, and helpful AI systems.