How to Build a Responsible AI Chatbot Using Open Technologies 7 Sections35 Lessons5 QuizzesLifetime
Why a task queue?
LLM responses may take seconds or longer. If the web server waits while doing all the work itself, many users can make it unresponsive.
Celery acts as a job coordinator:
- Flask accepts the question quickly.
- Celery places it in a work queue.
- A worker handles retrieval and generation.
- The browser asks, ‘Is it ready yet?’ every 1.5 seconds.
This pattern improves responsiveness, although a larger production system might use streaming or other real-time delivery methods instead of polling.

Retrieval plus generation
The central RAG loop is:

The repository searches the Climate Academy collection and, if available, an optional encyclopedia collection. It merges results, sorts them by vector distance, applies a threshold.
