Today was the big integration day. The goal was to build the complete loop: user types in the browser -> Flask catches the message -> sends it to an AI model -> receives the generated text -> renders the answer on the web page.
1. The 2GB Download Trap vs. Fast APIs
We looked at two ways to connect an AI model: running it locally on your laptop with PyTorch and TinyLlama, or calling a cloud-hosted model like Qwen2.5-7B via the Hugging Face Inference API. Almost everyone tried downloading the local model. Within ten minutes, laptops were freezing, laptop fans were screaming, and downloads were crashing over the office Wi-Fi.
I skipped that headache entirely. I wrote a clean Python function using the 'requests' library to call Hugging Face's hosted inference endpoint with an authorization token. No 2GB download, no memory crashes, and answers came back in under half a second.
2. Getting Praised by Mentor Rashmi
When Rashmi came over to inspect my screen, she was amazed. While others were still waiting on pip installs, my chatbot was already having full conversations. She stopped the class and pointed out that real software engineering is about picking the right tool for the job. Why load gigabytes of weights onto a basic laptop when a lightweight API call gives you better results in milliseconds?
3. Catching Errors Safely
To make the chatbot reliable, we wrapped the network calls in try-except blocks. If the internet drops or the API rate-limits, the bot doesn't crash the server—it just returns a friendly message: 'Sorry, I couldn't reach the server right now. Try again in a moment!'