[Bug]: Chatbot not work - #281
Merged
Merged
Conversation
- Load .env via python-dotenv so 'cp .env.example .env' works (was exiting at startup) - Default to a current Gemini model (gemini-2.5-flash); document GEMINI_MODEL - Centralize the backend URL (chatbotConfig.js/chatbotApi.js) and use it from home.js and review.js — fixes hardcoded 127.0.0.1 URLs and the relative /chat 404 - Add a Vite dev proxy and nginx proxy for /chat and /explain_mistake - Add the Flask chatbot service to Docker (Dockerfile.chatbot + docker-compose) - Harden templates/index.html: response.ok handling, textContent, no onkeypress - Bind Flask to 0.0.0.0 so containers / remote hosts can reach it Closes omroy07#266
|
@Techhackontime999 is attempting to deploy a commit to the Om Roy's projects Team on Vercel. A member of the Team first needs to authorize it. |
google-generativeai depends on grpcio, whose native DLL is blocked by Windows Application Control (WDAC) policies on some systems (verified: 'DLL load failed ... Application Control policy has blocked this file'). google-genai talks to Gemini over HTTPS (httpx) with no gRPC dependency, so the AI Tutor runs on those machines too. It is also the SDK Google recommends going forward and supports current models like gemini-3.5-flash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the AI Tutor chatbot not working (#266). Root causes were verified across the frontend, backend, and container setup:
.envwas never loaded —chatbot.pyreadGEMINI_API_KEYfrom the environment without callingload_dotenv(), so the documentedcp .env.example .envworkflow crashed at startup.gemini-1.5-pro, which Google discontinued in 2025. Every request 404'd, hidden by the genericexcept.home.jshardcodedhttp://127.0.0.1:5000(broke over HTTPS/Docker) andreview.jsused a relativefetch(\"/chat\")that only existed on the Flask-served page (404 on the static host).docker-compose.yml/Dockerfile shipped nginx static files only; no Flask service, no proxy for/chat.undefined—templates/index.htmlhad noresponse.okhandling and usedonkeypress/uncheckedinnerHTML.Changes
chatbot.pyload_dotenv(); default modelgemini-2.5-flash; bind0.0.0.0.env.exampleGEMINI_MODEL; update API-key URLchatbotConfig.js(new)chatbotApi.js(new)window.chatbotPosthelper used byhome.js+review.jshome.js,review.jshome.html,review.html,review_mistakes.htmlvite.config.js/chatand/explain_mistakenginx.conf(new),DockerfileDockerfile.chatbot(new),docker-compose.ymltemplates/index.htmlresponse.okhandling, safe rendering, keydown listenerVerification
node --checkpasses on all modified/new JS filespython -m py_compile chatbot.pypassespython chatbot.py+ open the site; optionalnpm run devproxy path addedCloses #266