An academic doubt-resolution assistant powered by Google Gemini (gemini-1.5-flash). The working implementation is a command-line chatbot (main.py) that keeps a local JSON conversation history and answers questions with a Gemini-API-key-help system prompt. Two HTML fragments (login.html, doubt.html) provide a student login page and a doubt-submission form, but no backend implementing their /login / /submit_doubt endpoints exists in this repo (see Known gaps).
Note on repo description: it mentions FastAPI, FAISS, and SentenceTransformers. None of those appear in the committed code —
main.pyuses onlygoogle-generativeaiplus the standard library. They are treated below as roadmap, not implemented features.
- CLI Q&A loop over Gemini 1.5 Flash with a focused system prompt (Gemini API-key setup, usage, troubleshooting, best practices)
- Last-5-exchanges context window injected into each prompt
- Persistent history in
conversation_history.json(timestamped user/bot pairs), loaded at startup and saved after every turn - Structured logging (
loggingmodule) for configuration, history, and generation errors - Graceful degradation: friendly fallback message on generation failure; clean
exithandling - Web UI fragments: styled student login form and doubt-submission form wired to
POST /loginandPOST /submit_doubt(backend not included)
| Layer | Technology |
|---|---|
| LLM | Google Gemini 1.5 Flash via google-generativeai |
| Language | Python 3.x (os, json, logging, datetime) |
| Frontend fragments | Plain HTML + vanilla JS fetch (doubt.html, login.html) |
| Persistence | Local conversation_history.json (created at runtime, git-ignored) |
| Ignored at runtime | __pycache__/, *.pyc, conversation_history.json patterns belong in .gitignore |
AI-Based-Doubt-Resolution-Bot-/
├── main.py # CLI bot: Gemini config, history load/save, prompt builder, REPL loop
├── doubt.html # HTML fragment: greeting + doubt form → POST /submit_doubt (expects {response})
├── login.html # Standalone page: student login form → POST /login; RIT branding header
├── .gitignore # Python / packaging / test ignores
├── LICENSE # MIT (© 2025 SHYAMFRANCIS)
└── conversation_history.json # Created at runtime (not committed)
Prerequisites: Python 3.8+, a Gemini API key (Google AI Studio).
git clone https://github.com/SHYAMFRANCIS/AI-Based-Doubt-Resolution-Bot-.git
cd AI-Based-Doubt-Resolution-Bot-
pip install google-generativeai
export GEMINI_API_KEY="your-key-here" # PowerShell: $env:GEMINI_API_KEY="your-key-here"
⚠️ Security: the committedmain.pycurrently hardcodes an API key as a module-levelapi_keystring. Rotate that key, delete it from the source, and read it from the environment instead:GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
python main.pyWelcome to the Gemini API Key Doubt Resolution Bot!
Ask your questions about Gemini API key setup, usage, or troubleshooting.
Type 'exit' to quit.
You: How do I create a Gemini API key?
Bot: ...
You: exit
Goodbye!
- Empty input is rejected with a prompt to enter a valid question.
- Each exchange is appended to
conversation_history.jsonwith an ISO timestamp.
| You ask | Bot context |
|---|---|
| "Where do I find my Gemini API key?" | System prompt + last 5 turns → concise, beginner-friendly setup steps |
| "Why do I get a 400/403 from the API?" | Troubleshooting guidance grounded in conversation history |
exit |
Saves history and quits |
Web fragments (frontend only):
<!-- doubt.html posts urlencoded doubt=... and renders JSON field `response` -->
fetch('/submit_doubt', { method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({ doubt }) })<!-- login.html -->
<form action="/login" method="POST"> ... username / email / password ... </form>| Setting | Location | Default |
|---|---|---|
| Model | initialize_model() in main.py |
gemini-1.5-flash |
| History file | HISTORY_FILE |
conversation_history.json |
| Context window | generate_response() |
last 5 exchanges |
| System prompt | generate_response() |
Gemini-API-key specialist, beginner-friendly |
| Log level | logging.basicConfig |
INFO |
doubt.html/login.htmlreferencePOST /submit_doubtandPOST /login, but no Flask/FastAPI server implements them —main.pyis CLI-only (input()loop).- No
requirements.txt; install is a singlepip install google-generativeai. - No FAISS index, SentenceTransformers embeddings, voice input, or multilingual support in code despite the repo description — candidates for future work.
- Fork and create a feature branch.
- Move the API key to
GEMINI_API_KEYenv (do not commit keys). - Add the missing web backend or
requirements.txtif in scope. - Open a pull request describing the change and how it was tested (
python main.pysmoke test).
MIT — see LICENSE. © 2025 SHYAMFRANCIS.