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 Bring Your Own Data (BYOD) experience in a Gradio web interface with drag-and-drop file upload. You get the same BYOD functionality as Step 4, but in a polished browser interface. Duration: ~2 minutes to launch What you’ll get:- Drag-and-drop file upload or select from
userdata/directory - Support for loading single or multiple files at once
- File analysis metadata displayed in the UI
- AI summary shown as the first chat message
- Interactive Q&A chat with cost comparison
Prerequisites
Complete Step 4: Bring Your Own Data first. All dependencies should already be installed.Running the app
Basic usage
http://localhost:8861 and should open automatically in your default browser.
This uses port 8861 (different from Step 3’s 7860) so you can run both apps simultaneously.
Command-line options
| Option | Default | Description |
|---|---|---|
--port | 8861 | HTTP port for the web UI |
--model | llama3.1 | Ollama model to use |
--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 files are loaded, showing:- “CivicHacks BYOD AI Assistant” title
- Loaded file names
- Hostname and start time
- Privacy note: “no cloud, no cost, no data leaving this machine”
File loading section
Two tabs for loading files: Upload Files tab:- Drag-and-drop area for uploading
.txt,.pdf,.csv,.docxfiles - Supports multiple files
- “Load & Analyze” button
- Checkbox list of files in
userdata/directory - “Load Selected” button — load checked files
- “Load ALL” button — load every file into a single index
- ”↻ Refresh” button — rescan the directory for new files
File analysis display
Markdown display showing metadata for each loaded file:- File name (bold)
- Type (Plain text, PDF document, CSV spreadsheet, Word document)
- Size (KB or MB)
- Modified date
- Content: number of chunks and word count
Chat interface
Message-style chat with:- First message: AI summary of the loaded files
- User/assistant bubbles
- Red Hat avatar for assistant responses
- Cost comparison metadata on each response
Question input
- Text field with placeholder: “Ask anything about your loaded data…”
- “Ask” button (also supports Enter key)
Footer
Shows the full open source stack and privacy information:- Stack: Ollama + LlamaIndex + Gradio
- Model: [model name]
- Host: [your hostname]
- Data Privacy: 100% local
- Cost: per-query estimate shown in each response
How it works
The app uses these key components:File discovery and validation
find_userdata_files()scans theuserdata/directory for supported file typesvalidate_uploaded_file()validates file path, extension, and size (returns error tuple instead of exiting)analyze_file_metadata()returns markdown string with file metadata for display
Load and index files
The Uses
load_and_index_files() function:gr.Progress() for visual feedback during loading.Query BYOD data
The
query_byod_data() function queries the index and appends the response with cost metadata to chat history:Workflow examples
Upload a single file
Click Load & Analyze
Watch the progress indicator as it:
- Loads the file
- Builds the vector index
- Generates an AI summary
Review the summary
The AI summary appears as the first chat message, covering:
- What the document is about
- Key data points or findings
- Three suggested questions
Load multiple files from userdata/
Click Load Selected or Load ALL
- Load Selected: Loads only checked files
- Load ALL: Loads every file in the directory
Progress indicators
The app shows real-time progress during loading:Error handling
The app gracefully handles errors:| Error | Behavior |
|---|---|
| Unsupported file type | Shows error message, doesn’t load the file |
| Empty file | Shows error message, doesn’t load the file |
| PDF with no text | Shows warning, skips the file |
| File read error | Shows error message with details, skips the file |
| No files selected | Shows prompt: “No files selected. Check the boxes…” |
| Query before loading | Shows message: “Please load a file first…” |
Errors are shown in the File Analysis section (markdown display) and don’t crash the app.
Session management
Each browser session maintains its own state:- Index: Each session builds its own vector index
- Loaded files: Each session tracks its own loaded files
- Chat history: Each session has its own message history
- Multiple users can use the app simultaneously with different data
- Refreshing the browser resets the session (clears index and chat)
- Opening a new tab creates a new independent session
Customizing the theme
The Gradio theme is set with:primary_hue to customize the color scheme:
Deployment options
Local only (default)
The app runs entirely onlocalhost:8861. 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:8861 in your browser.Port already in use
Port already in use
Kill the existing process or change the port:
File upload doesn't work
File upload doesn't work
Ensure the file is one of the supported types:
.txt, .pdf, .csv, .docxCheck the File Analysis section for specific error messages.userdata/ files don't appear
userdata/ files don't appear
Click ”↻ Refresh” to rescan the directory.Ensure files have supported extensions and are in the
userdata/ directory (not a subdirectory).Progress indicator stuck
Progress indicator stuck
This may indicate:
- Very large file (>10 MB) — wait longer
- PDF with images — text extraction is slow
- Insufficient RAM — close other applications
AI summary is generic
AI summary is generic
The file may not have extracted meaningful text. Check the File Analysis section for word count.For PDFs, ensure they’re text-based (not scanned images).
Comparison: Step 4 vs Step 5
| Feature | Step 4 (Terminal) | Step 5 (Web App) |
|---|---|---|
| Interface | Command-line REPL | Browser-based chat |
| File loading | CLI argument or prompt | Drag-and-drop or directory |
| Multiple files | --all flag | Checkboxes or “Load ALL” |
| File discovery | Auto-discovery | Auto-discovery + refresh |
| Progress feedback | Terminal output | Progress bar |
| Session persistence | Single session | Multiple concurrent sessions |
| Sharing | Screen share only | Public URL via --share |
| Best for | Quick analysis, demos | Collaboration, presentations |
Next steps
You’ve completed all 5 tutorial steps! Now you can:Deploy your app
Learn how to deploy your app to Hugging Face Spaces, Streamlit Cloud, or your own server.
Change the AI model
Try different models like phi3:mini for speed or deepseek-r1:7b for reasoning.
Customize the UI
Change themes, colors, and layout to match your style.
View on GitHub
Star the repo, open issues, and share your projects.