CityPulse is an intelligent location-based discovery search that helps users explore what’s happening around them right now. It demonstrates how to create personalized, real-time local insights using Perplexity’s Sonar models.
CityPulse leverages two key Perplexity models:Sonar for Real-Time Data
Copy
Ask AI
# Get current local information with geographic contextresponse = client.chat.completions.create( model="sonar", messages=[{ "role": "user", "content": f"Find current events, restaurants, and alerts near {lat}, {lng}" }], response_format={"type": "json_schema", "json_schema": {"schema": LOCAL_INFO_SCHEMA}})
Sonar Reasoning for Personalized Insights
Copy
Ask AI
# Generate AI-powered location recommendationsresponse = client.chat.completions.create( model="sonar-reasoning", messages=[{ "role": "user", "content": f"Provide personalized insights for {location_name}: what to try, best times to visit, pro tips" }])
The app uses structured JSON schemas to ensure consistent data formatting and includes citation tracking for source verification.