Documentation Index
Fetch the complete documentation index at: https://mintlify.com/holzerjm/civichacks-demo/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This step wraps the RAG pipeline in a polished Gradio-based chat interface. You’ll see that building a shareable web application takes minutes, not days. Duration: ~60 seconds to launch What you’ll get:- A browser-based chat interface with message history
- Track selector dropdown (switch between all four datasets)
- Dynamic header and example questions that update when you switch tracks
- Per-query cost comparison (local electricity vs. cloud API)
- Red Hat-themed styling with soft colors
Prerequisites
Complete Step 2: RAG with Civic Data first, then install Gradio:Running the app
Basic usage
http://localhost:7860 and should open automatically in your default browser.
Command-line options
| Option | Default | Description |
|---|---|---|
--port | 7860 | HTTP port for the web UI |
--share | off | Create a temporary public URL via Gradio’s tunneling service |
UI components
The web app includes these interactive elements:Header
Dynamic header that updates when you switch tracks, showing:- “CivicHacks AI Assistant” title
- Current track name (e.g., “🏙️ CityHack — Boston 311 Services”)
- Track description
- Hostname and start time (proves it’s running locally)
- Privacy note: “no cloud, no cost, no data leaving this machine”
Track selector
Dropdown menu to switch between:- 🌿 EcoHack — Boston Environment
- 🏙️ CityHack — Boston 311 Services
- 📚 EduHack — Boston Public Schools
- ⚖️ JusticeHack — MA Criminal Justice
Chat interface
Message-style chat with:- User/assistant bubbles
- Red Hat avatar for assistant responses
- Message history preserved during the session
- Each response includes timing and cost comparison
Example questions
Clickable example questions that auto-populate the input field. These update dynamically when the track changes: CityHack examples:- Which neighborhoods wait longest for city services?
- What equity gaps exist in 311 service delivery?
- How are non-English speakers underserved?
- Which neighborhoods face the worst environmental injustice?
- What are the biggest climate threats to Boston?
- How does tree canopy coverage affect neighborhood temperatures?
- What are the biggest achievement gaps by race?
- How does transportation affect student attendance?
- What barriers exist for English Language Learners?
- What racial disparities exist in pretrial detention?
- How effective are reentry programs?
- What patterns appear in Boston police stop data?
Footer
Shows the full open source stack and privacy information:- Stack: Ollama + LlamaIndex + Gradio
- Model: Llama 3.1 8B
- Host: [your hostname]
- Data Privacy: 100% local
- Cost: per-query estimate shown in each response
How it works
The app uses these key components:Global index cache
Built indices are cached in a
dict so switching tracks after the first load is instant:Query function
Appends user message to chat history, queries the cached index, appends AI response with timing and cost metadata:
Dynamic header and examples
Updates header HTML and example questions when the track selector changes:
Customizing the theme
The Gradio theme is set with:primary_hue to any Gradio color:
Customizing example questions
Edit theEXAMPLE_QUESTIONS dictionary in scripts/demo_step3_app.py:
Performance tips
First track load builds the index and may take 2-5 seconds. Subsequent loads of the same track are instant (cached). Switching between tracks after they’ve been loaded is also instant.
Deployment options
Local only (default)
The app runs entirely onlocalhost:7860. No data ever leaves the machine.
Temporary public URL
Troubleshooting
Browser doesn't open automatically
Browser doesn't open automatically
Navigate manually to
http://localhost:7860 in your browser.Port already in use
Port already in use
Kill the existing process or change the port:
App is unresponsive
App is unresponsive
Ensure at least 8 GB RAM is available. Llama 3.1 8B uses ~4-5 GB. Close other applications to free memory.
Track switching doesn't update header
Track switching doesn't update header
This is a known issue in Gradio 5.x. The fix is to ensure the
track_selector.change() event is properly wired: