
AI
RetroChatbot
A chatbot that believes it is in 1996 or 2030 and talks through Gemini. The era only changes the voice; the facts stay current. A FastAPI backend, a plain HTML/CSS/JS interface, and a Three.js hologram in 2030 mode. The public demo runs on Vercel and falls back to another model when Gemini quota runs out.
Demo
Problem
Giving a language model a personality is easy, but keeping it consistent is not. A bot writing from 1996 that acts as if it does not know smartphones has not answered the question. What I wanted was behaviour where the facts stay correct and only the voice belongs to the era. The second matter was keeping a public demo alive on the free Gemini quota: model names change, quota runs out, the service fails temporarily. None of that should break the chat.
Highlights
- There are two system prompts: the 1996 mode talks in the language of the time but still gives correct current facts, and the 2030 mode applies the same rule in a high-tech voice. Even the error messages are written in the voice of the era.
- In the demo the server keeps no chat history. The browser stores it in sessionStorage and sends the last 10 messages with each request; the server normalizes them into alternating user and model turns because Gemini can reject two user messages in a row.
- A model fallback chain: an ordered list of models is tried and the last one that worked is remembered. A 400, 404, 429 or 5xx moves on to the next model, while a 401 or 403 stops at once because it means a key problem.
- The fallback has a time budget: at most 2 slow attempts within Vercel's 30 second limit, 28 seconds in total. Each attempt gets at least 10 seconds because Gemini rejects a shorter timeout with a 400.
- Demo protections: messages of 1 to 500 characters, control characters stripped, an Origin check, 5 requests per minute per IP and a daily cap of 300, a generic message to the client on errors, and only the exception class name in the logs.
Architecture and notes
The application is written with FastAPI: pages come from Jinja templates, the chat endpoint is /api/chat, and the interface is plain JavaScript. There are two ways it runs. Locally it is file based: the era choice is stored on the server, and there is a guestbook and a visitor counter. The public demo is a stateless (DEMO_MODE) Vercel Python function; because the file system is not persistent and I did not want shared state on a public site, the guestbook, the counter and the global mode switch are off there (404). The era travels as a field with every request.
The fallback logic is in app/gemini_client.py. A model that rejects its name or runs out of quota is skipped for a while (10 minutes for 400/404, 60 seconds for 429). If every model answers 400 or 404, the list of models is fetched from Google once as a last resort and suitable flash models are tried. These cool-down states live in memory and reset on a cold start, which is an acceptable gap in a serverless setup. As the real rate limit I rely on a Vercel Firewall rule; the limit inside the application is best effort.
What is missing: there is no test that measures chat quality, that is, whether the persona prompt gives voice without damaging facts. 112 tests pass without a real key or the network, and they cover routing, the security rules and the fallback logic.
Live from GitHub
- Stars
- 0
- Forks
- 0
- Last updated
Languages
- Python53.3%
- JavaScript17.5%
- CSS15%
- HTML14.2%
Fetched from the public GitHub API and refreshed hourly.
From the README
Zaman Makinesi — kendini bazen 1996'da, bazen 2030'da sanan bir sohbet botu. Gemini API ile konuşuyor, arayüz FastAPI + düz HTML/CSS/JS üzerine kurulu.
Ne var ne yok
- 1996 modu: GeoCities esintili, yanıp sönen başlık, "best viewed 800x600" rozetleri, dial-up modem havası. Bot kendini gerçekten o dönemde sanıyor ama güncel bir şey sorulduğunda bilgiyi doğru veriyor, sadece 90'lar üslubuyla anlatıyor.
- 2030 modu: Neon/cyberpunk tema ve gerçek bir 3D hologram (Three.js ile, tavandan projekte edilen bir insan figürü). Bot bu modda ileri teknoloji diliyle konuşuyor.
- İki mod arasında geçiş yapan bir buton var, seçim sunucu tarafında saklanıyor (sayfa yenilense de kalıyor).
- Misafir defteri ve ziyaretçi sayacı — dönemin ruhuna uygun küçük eklentiler.
- Gemini modeli geçici olarak yoğunluk (503) verirse, otomatik olarak başka bir modele geçip tekrar deniyor.
Kurulum
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
.env.example dosyasını .env olarak kopyala ve kendi Gemini API anahtarını gir:
GEMINI_API_KEY=senin-api-anahtarin
GEMINI_MODEL=gemini-3.8-flash
Ardından çalıştır:
uvicorn app.main:app --reload
http://127.0.0.1:8000 üzerinden açılıyor.
Testler
pytest
Kullanılan teknolojiler
FastAPI, Jinja2, google-genai (Gemini API), vanilla JavaScript/CSS, Three.js (sadece 2030 modundaki hologram sahnesi için, CDN üzerinden).
Technologies
Request flow
Hover or focus a component to see what it is.