
#ConfidenceAI — Live Coaching Platform
ConfidenceAI is a live, deployed AI confidence coach: a Streamlit app backed by Google Gemini that assesses how a user is feeling from what they type, then responds with structured, empathetic coaching rather than generic motivational filler.
#What It Does
Every message goes through a confidence assessment before the coaching response is generated — the app doesn't just chat, it estimates where the user is emotionally (1–10 scale), adapts its response to that estimate, and surfaces the assessment back to the user instead of hiding it as an internal black box.
#Solution Architecture
Request flow, per message:
User message
→ Hybrid confidence assessment
├─ Keyword/regex extraction (fast, deterministic)
└─ Gemini-based assessment (contextual)
→ take the LOWER of the two (bias toward caution)
→ Low-confidence check (<4) → inject a motivational quote into the approach
→ Context build (last 4 messages, truncated) + system prompt + response prompt
→ Gemini call, 3 retries on failure → canned supportive fallback if all fail
→ Pydantic-validated AIResponse (tips + next steps extracted from the text)
→ Session updated (in-memory, per Streamlit session)
Key engineering decisions:
- Confidence assessment is hybrid, and deliberately biased toward caution — a fast keyword/regex pass runs alongside a Gemini-based assessment, and the app takes whichever score is lower. For a tool touching on user emotional state, under-reacting to a distress signal is worse than over-reacting to a neutral one, so the code is written to trust the more cautious read.
- Every AI call has a real fallback, not just a try/catch —
_make_ai_requestretries up to 3 times, and if Gemini is still unreachable, returns a written supportive fallback message rather than an error screen. In a coaching context, silence or a stack trace is a worse failure mode than a slightly generic response. - Pydantic validates the AI's own output —
AIResponse,ConfidenceAssessment, andChatSessionare all typed models. The chatbot doesn't trust Gemini's output as free text; it's parsed and validated into structured fields (confidence level, emotional state, tips, next steps) before it reaches the UI. - Session memory is in-memory, not persisted — context is the last 4 messages of the current Streamlit session, truncated to 100 characters each. This keeps responses coherent within a conversation but doesn't carry across page reloads or devices — a real tradeoff versus a database-backed memory layer (unlike the Redis/Supabase-backed memory in some of the other projects here).
- A "motivate me" shortcut bypasses assessment entirely — recognized as a special case that returns a quote directly, rather than running the full assessment pipeline for a request that doesn't need it.
#Tech Stack
| Component | Technology |
|---|---|
| LLM | Google Gemini 1.5 Flash |
| Validation | Pydantic (UserMessage, AIResponse, ConfidenceAssessment, ChatSession) |
| Frontend | Streamlit |
| Session memory | In-process, per-session (no external store) |
#Live Deployment
Response times run roughly ~1.2s per turn in local testing (Gemini API call is the dominant cost) — this is an informal figure from development, not a production monitoring metric.
#Roadmap (not yet built)
Per the project's own roadmap: multi-language support (i18n), voice input/output, a plugin system for third-party tools, and an OpenAPI/REST layer for external integrations. None of these are implemented yet — the current app is a single Streamlit interface backed by Gemini.