Spaces:
Sleeping
Sleeping
File size: 10,705 Bytes
16a929f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | # Web UI Guide
## Overview
The AI Personas Web UI provides a beautiful, interactive interface for conversing with urban planning stakeholder personas. The interface features:
- **Visual persona cards** with avatars and descriptions
- **Chat-style interface** for natural conversations
- **Conversation history** tracking within each session
- **Quick suggestion buttons** for common questions
- **Real-time responses** from Claude-powered personas
## Layout
```
βββββββββββββββββββββββββββββββββββ¬βββββββββββββββββ
β π¬ Conversation β π₯ Personas β
β βββββββββββββββββββββββββββββ β ββββββββββββ β
β β Selected: Sarah Chen β β β π± Sarah β β
β βββββββββββββββββββββββββββββ β ββββββββββββ β
β β ββββββββββββ β
β βββββββββββββββββββββββββββββ β β πͺ Marcusβ β
β β Your question: [____] Sendβ β ββββββββββββ β
β βββββββββββββββββββββββββββββ β ... β
β β β
β π‘ Quick Suggestions β β
β [Suggestion 1] [Suggestion 2] β β
β β β
β π Conversation History β β
β βββββββββββββββββββββββββββββ β β
β β π You: What about... β β β
β β π± Sarah: I think that... β β β
β βββββββββββββββββββββββββββββ β β
βββββββββββββββββββββββββββββββββββ΄βββββββββββββββββ
```
## The 6 Personas
Each persona has a unique visual identity:
1. **π± Sarah Chen** - Urban Planner
- Progressive, sustainability-focused
- Green theme
2. **πͺ Marcus Thompson** - Business Owner
- Pragmatic, economy-focused
- Orange theme
3. **π Dr. Elena Rodriguez** - Transportation Engineer
- Data-driven, safety-first
- Blue theme
4. **π‘ James O'Brien** - Long-time Resident
- Traditional, community-focused
- Brown theme
5. **β Priya Patel** - Housing Advocate
- Activist, equity-focused
- Pink theme
6. **π’ David Kim** - Real Estate Developer
- Market-driven, growth-oriented
- Gray theme
## Getting Started
### 1. Launch the Web App
**Option A: Using the startup script**
```bash
# On macOS/Linux:
./run_web_app.sh
# On Windows:
run_web_app.bat
```
**Option B: Direct command**
```bash
streamlit run web_app.py
```
### 2. Access the Interface
The app will automatically open in your default browser at:
```
http://localhost:8501
```
If it doesn't open automatically, manually navigate to that URL.
### 3. Select a Persona
- Look at the right panel showing 6 persona cards
- Click on any persona to select them
- The selected persona will be highlighted
- Your conversation history will be cleared when switching personas
### 4. Start Asking Questions
**Quick Start Options:**
- Click one of the suggested questions below the input box
- Type your own question in the text field
- Press Enter or click "Send"
**Example Questions:**
- "What do you think about the bike lane proposal?"
- "Should we allow food trucks downtown?"
- "What's the biggest challenge facing our community?"
- "How can we make housing more affordable?"
### 5. View Responses
- Responses appear in the conversation history
- Your questions are shown in blue boxes
- Persona responses are shown in gray boxes
- Scroll to see the full conversation
### 6. Continue the Conversation
- Ask follow-up questions
- The persona maintains context from previous messages in the session
- Switch personas to get different perspectives on the same topic
## Features
### Conversation History
Each session with a persona maintains full conversation history:
- All your questions are saved
- All responses are preserved
- Switch between personas to compare perspectives
- Clear conversation button to start fresh
### Quick Suggestions
Pre-written questions to help you get started:
- "What's the most important issue facing downtown?"
- "Should we allow food trucks in the plaza?"
- "How can we make the city more sustainable?"
- "What do you think about the affordable housing crisis?"
### Context Awareness
All responses consider:
- The downtown district environmental context
- Recent events and upcoming decisions
- The persona's values, background, and expertise
- Their communication style and typical concerns
## Tips for Effective Use
### 1. Start Broad, Then Go Specific
```
Good progression:
1. "What are your priorities for downtown?"
2. "How do you feel about new development?"
3. "What about the 500-unit condo proposal on 5th St?"
```
### 2. Compare Perspectives
Ask the same question to multiple personas:
1. Ask Sarah Chen (planner) about bike lanes
2. Switch to Marcus Thompson (business owner)
3. Ask the same question
4. See how their values shape different responses
### 3. Use Realistic Scenarios
```
Weak: "What do you think?"
Strong: "The city is considering a $50M bond for affordable
housing. It would add 200 units but increase property
taxes by $150/year. What's your position?"
```
### 4. Ask Follow-up Questions
```
Initial: "Should we add more bike lanes?"
Follow-up: "What about concerns from business owners?"
Follow-up: "How would you address parking issues?"
```
### 5. Explore Trade-offs
```
Good questions:
- "How would you balance economic growth with affordability?"
- "What's more important: parking or bike infrastructure?"
- "How do we develop without displacing residents?"
```
## Use Cases
### 1. Planning Proposal Testing
**Before a public meeting:**
- Present your proposal to all 6 personas
- Identify likely concerns and objections
- Prepare responses to different stakeholder viewpoints
- Refine your communication strategy
### 2. Community Engagement Prep
**Before stakeholder outreach:**
- Understand different value systems
- Learn characteristic language patterns
- Identify potential allies and opponents
- Develop inclusive framing
### 3. Scenario Exploration
**Test different approaches:**
- Ask about Option A vs. Option B
- See which approach gets broader support
- Understand trade-offs from multiple perspectives
### 4. Training & Education
**For planning students/professionals:**
- Learn to think from diverse perspectives
- Understand stakeholder motivations
- Practice responsive communication
- Build empathy across different viewpoints
### 5. Policy Analysis
**Evaluate proposed policies:**
- Get immediate feedback from different angles
- Identify unintended consequences
- Understand equity implications
- Find opportunities for compromise
## Technical Details
### Performance
- First query may take 3-5 seconds (model initialization)
- Subsequent queries: 2-4 seconds each
- Conversation history is stored in browser session
- No data is saved between sessions (privacy-preserving)
### Browser Compatibility
Tested and working on:
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
### Port Configuration
Default port: `8501`
To use a different port:
```bash
streamlit run web_app.py --server.port 8502
```
### Customization
The web app reads from:
- `data/personas/*.json` - Persona definitions
- `data/contexts/*.json` - Environmental contexts
- `.env` - API configuration
Any changes to these files will be reflected after refreshing the browser.
## Troubleshooting
### App won't start
**Check Python version:**
```bash
python --version # Should be 3.11+
```
**Reinstall dependencies:**
```bash
pip install -r requirements.txt
```
### "No personas loaded" error
**Check persona files exist:**
```bash
ls data/personas/
```
Should show 6 JSON files. If not, verify git repository is complete.
### API errors
**Verify API key:**
```bash
cat .env | grep ANTHROPIC_API_KEY
```
Should show your API key. If missing, add it to `.env`.
### Slow responses
**Check model configuration:**
In `.env`, you're using:
```
LLM_MODEL=claude-3-haiku-20240307
```
This is the fastest model. For better quality (but slower), you could upgrade to Sonnet or Opus.
### Persona not responding
**Check browser console:**
- Right-click β Inspect β Console tab
- Look for error messages
- Common issue: API rate limits
**Refresh the page:**
- Clears session state
- Reinitializes connections
### Clear stuck session
**Browser refresh:** Press F5 or Ctrl+R
**Clear cache:**
```bash
streamlit cache clear
```
## Keyboard Shortcuts
While in the text input field:
- **Enter**: Send message
- **Shift+Enter**: New line (in the future, for multi-line input)
- **Escape**: Clear input field
## Privacy & Data
### What's Stored
**In browser session (temporary):**
- Selected persona
- Conversation history
- Current question
**Not stored:**
- No conversation logs saved to disk
- No personal data collected
- No tracking or analytics
**Cleared when:**
- Switching personas
- Clicking "Clear Conversation"
- Closing browser tab
- Refreshing page
### API Usage
- Questions are sent to Anthropic Claude API
- Responses are generated by the LLM
- Conversation data follows Anthropic's privacy policy
- No training on your queries (as per Anthropic policy)
## Advanced Features (Coming Soon)
Planned enhancements:
- Export conversation to PDF/Markdown
- Share conversation links
- Multi-persona comparison view
- Voice input/output
- Mobile responsive design improvements
- Dark mode
- Custom persona builder
## Support
If you encounter issues:
1. Check this guide first
2. Review main README.md
3. Check GitHub issues
4. Verify all dependencies installed
5. Ensure API key is configured
## Quick Command Reference
```bash
# Start app
streamlit run web_app.py
# Start on different port
streamlit run web_app.py --server.port 8502
# Clear cache
streamlit cache clear
# View Streamlit config
streamlit config show
# Run in headless mode (no browser)
streamlit run web_app.py --server.headless true
```
---
**Enjoy exploring diverse urban planning perspectives! ποΈ**
|