Upload 4 files
Browse files- .gitattributes +2 -0
- Screenshot 2025-09-05 at 1.19.32 PM.png +3 -0
- app.py +464 -0
- installed_packages_venv.txt +44 -0
- output.mp4 +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
output.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
Screenshot[[:space:]]2025-09-05[[:space:]]at[[:space:]]1.19.32 PM.png filter=lfs diff=lfs merge=lfs -text
|
Screenshot 2025-09-05 at 1.19.32 PM.png
ADDED
|
Git LFS Details
|
app.py
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import dash
|
| 2 |
+
from dash import dcc, html, Input, Output, State, callback_context
|
| 3 |
+
import dash_bootstrap_components as dbc
|
| 4 |
+
import folium
|
| 5 |
+
from folium.plugins import MarkerCluster
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import numpy as np
|
| 8 |
+
import requests
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
import mlx.core as mx
|
| 12 |
+
import mlx.nn as nn
|
| 13 |
+
from transformers import AutoTokenizer
|
| 14 |
+
from typing import List, Dict, Optional
|
| 15 |
+
import threading
|
| 16 |
+
import time
|
| 17 |
+
import re
|
| 18 |
+
|
| 19 |
+
# DeepSeek model setup
|
| 20 |
+
MODEL_PATH = "/Users/martinrivera/deepseek_v3_1_4bit_mlx/deepseek_v3_4bit"
|
| 21 |
+
|
| 22 |
+
# Landmark coordinates dictionary
|
| 23 |
+
landmark_coordinates = {
|
| 24 |
+
"Grand Canyon": {"lat": 36.055261, "lon": -112.121836},
|
| 25 |
+
"Statue of Liberty": {"lat": 40.689167, "lon": -74.044444},
|
| 26 |
+
"White House": {"lat": 38.897778, "lon": -77.036389},
|
| 27 |
+
"Eiffel Tower": {"lat": 48.858222, "lon": 2.2945},
|
| 28 |
+
"Louvre Museum": {"lat": 48.861111, "lon": 2.335833},
|
| 29 |
+
"Notre-Dame Cathedral": {"lat": 48.853056, "lon": 2.35},
|
| 30 |
+
"Mount Fuji": {"lat": 35.360833, "lon": 138.7275},
|
| 31 |
+
"Tokyo Tower": {"lat": 35.658611, "lon": 139.745556},
|
| 32 |
+
"Imperial Palace": {"lat": 35.6825, "lon": 139.7521},
|
| 33 |
+
"Taj Mahal": {"lat": 27.175, "lon": 78.041944},
|
| 34 |
+
"Red Fort": {"lat": 28.655833, "lon": 77.240833},
|
| 35 |
+
"Gateway of India": {"lat": 18.955668, "lon": 72.834001},
|
| 36 |
+
"Christ the Redeemer": {"lat": -22.951944, "lon": -43.210556},
|
| 37 |
+
"Amazon Rainforest": {"lat": -3, "lon": -60},
|
| 38 |
+
"Iguazu Falls": {"lat": -25.686667, "lon": -54.444722},
|
| 39 |
+
"Pyramids of Giza": {"lat": 29.9725, "lon": 31.128333},
|
| 40 |
+
"Sphinx": {"lat": 29.97526, "lon": 31.13758},
|
| 41 |
+
"Valley of the Kings": {"lat": 25.740833, "lon": 32.602222},
|
| 42 |
+
"Sydney Opera House": {"lat": -33.85681, "lon": 151.21514},
|
| 43 |
+
"Great Barrier Reef": {"lat": -16.4, "lon": 145.8},
|
| 44 |
+
"Uluru": {"lat": -25.345, "lon": 131.036111},
|
| 45 |
+
"Colosseum": {"lat": 41.890278, "lon": 12.492222},
|
| 46 |
+
"Leaning Tower of Pisa": {"lat": 43.723056, "lon": 10.396389},
|
| 47 |
+
"Venice Canals": {"lat": 45.4408, "lon": 12.3155}, # Corrected coordinates for Venice
|
| 48 |
+
"Great Wall of China": {"lat": 40.68, "lon": 117.23},
|
| 49 |
+
"Forbidden City": {"lat": 39.915833, "lon": 116.390833},
|
| 50 |
+
"Terracotta Army": {"lat": 34.385, "lon": 109.273056},
|
| 51 |
+
"Big Ben": {"lat": 51.5007, "lon": -0.1245},
|
| 52 |
+
"Buckingham Palace": {"lat": 51.500833, "lon": -0.141944},
|
| 53 |
+
"Stonehenge": {"lat": 51.178889, "lon": -1.826111}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
# Sample data for countries, capitals, and landmarks with precise coordinates
|
| 57 |
+
country_data = [
|
| 58 |
+
{
|
| 59 |
+
"country": "France",
|
| 60 |
+
"capital": "Paris",
|
| 61 |
+
"lat": 48.8566,
|
| 62 |
+
"lon": 2.3522,
|
| 63 |
+
"landmarks": [
|
| 64 |
+
{"name": "Eiffel Tower", "lat": 48.858222, "lon": 2.2945},
|
| 65 |
+
{"name": "Louvre Museum", "lat": 48.861111, "lon": 2.335833},
|
| 66 |
+
{"name": "Notre-Dame Cathedral", "lat": 48.853056, "lon": 2.35}
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"country": "United States",
|
| 71 |
+
"capital": "Washington D.C.",
|
| 72 |
+
"lat": 38.9072,
|
| 73 |
+
"lon": -77.0369,
|
| 74 |
+
"landmarks": [
|
| 75 |
+
{"name": "White House", "lat": 38.897778, "lon": -77.036389},
|
| 76 |
+
{"name": "Statue of Liberty", "lat": 40.689167, "lon": -74.044444},
|
| 77 |
+
{"name": "Grand Canyon", "lat": 36.055261, "lon": -112.121836}
|
| 78 |
+
]
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"country": "Japan",
|
| 82 |
+
"capital": "Tokyo",
|
| 83 |
+
"lat": 35.6762,
|
| 84 |
+
"lon": 139.6503,
|
| 85 |
+
"landmarks": [
|
| 86 |
+
{"name": "Mount Fuji", "lat": 35.360833, "lon": 138.7275},
|
| 87 |
+
{"name": "Tokyo Tower", "lat": 35.658611, "lon": 139.745556},
|
| 88 |
+
{"name": "Imperial Palace", "lat": 35.6825, "lon": 139.7521}
|
| 89 |
+
]
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"country": "India",
|
| 93 |
+
"capital": "New Delhi",
|
| 94 |
+
"lat": 28.6139,
|
| 95 |
+
"lon": 77.2090,
|
| 96 |
+
"landmarks": [
|
| 97 |
+
{"name": "Taj Mahal", "lat": 27.175, "lon": 78.041944},
|
| 98 |
+
{"name": "Red Fort", "lat": 28.655833, "lon": 77.240833},
|
| 99 |
+
{"name": "Gateway of India", "lat": 18.955668, "lon": 72.834001}
|
| 100 |
+
]
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"country": "Brazil",
|
| 104 |
+
"capital": "Brasília",
|
| 105 |
+
"lat": -15.7975,
|
| 106 |
+
"lon": -47.8919,
|
| 107 |
+
"landmarks": [
|
| 108 |
+
{"name": "Christ the Redeemer", "lat": -22.951944, "lon": -43.210556},
|
| 109 |
+
{"name": "Amazon Rainforest", "lat": -3, "lon": -60},
|
| 110 |
+
{"name": "Iguazu Falls", "lat": -25.686667, "lon": -54.444722}
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"country": "Egypt",
|
| 115 |
+
"capital": "Cairo",
|
| 116 |
+
"lat": 30.0444,
|
| 117 |
+
"lon": 31.2357,
|
| 118 |
+
"landmarks": [
|
| 119 |
+
{"name": "Pyramids of Giza", "lat": 29.9725, "lon": 31.128333},
|
| 120 |
+
{"name": "Sphinx", "lat": 29.97526, "lon": 31.13758},
|
| 121 |
+
{"name": "Valley of the Kings", "lat": 25.740833, "lon": 32.602222}
|
| 122 |
+
]
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"country": "Australia",
|
| 126 |
+
"capital": "Canberra",
|
| 127 |
+
"lat": -35.2809,
|
| 128 |
+
"lon": 149.1300,
|
| 129 |
+
"landmarks": [
|
| 130 |
+
{"name": "Sydney Opera House", "lat": -33.85681, "lon": 151.21514},
|
| 131 |
+
{"name": "Great Barrier Reef", "lat": -16.4, "lon": 145.8},
|
| 132 |
+
{"name": "Uluru", "lat": -25.345, "lon": 131.036111}
|
| 133 |
+
]
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"country": "Italy",
|
| 137 |
+
"capital": "Rome",
|
| 138 |
+
"lat": 41.9028,
|
| 139 |
+
"lon": 12.4964,
|
| 140 |
+
"landmarks": [
|
| 141 |
+
{"name": "Colosseum", "lat": 41.890278, "lon": 12.492222},
|
| 142 |
+
{"name": "Leaning Tower of Pisa", "lat": 43.723056, "lon": 10.396389},
|
| 143 |
+
{"name": "Venice Canals", "lat": 45.4408, "lon": 12.3155}
|
| 144 |
+
]
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"country": "China",
|
| 148 |
+
"capital": "Beijing",
|
| 149 |
+
"lat": 39.9042,
|
| 150 |
+
"lon": 116.4074,
|
| 151 |
+
"landmarks": [
|
| 152 |
+
{"name": "Great Wall of China", "lat": 40.68, "lon": 117.23},
|
| 153 |
+
{"name": "Forbidden City", "lat": 39.915833, "lon": 116.390833},
|
| 154 |
+
{"name": "Terracotta Army", "lat": 34.385, "lon": 109.273056}
|
| 155 |
+
]
|
| 156 |
+
},
|
| 157 |
+
{
|
| 158 |
+
"country": "United Kingdom",
|
| 159 |
+
"capital": "London",
|
| 160 |
+
"lat": 51.5074,
|
| 161 |
+
"lon": -0.1278,
|
| 162 |
+
"landmarks": [
|
| 163 |
+
{"name": "Big Ben", "lat": 51.5007, "lon": -0.1245},
|
| 164 |
+
{"name": "Buckingham Palace", "lat": 51.500833, "lon": -0.141944},
|
| 165 |
+
{"name": "Stonehenge", "lat": 51.178889, "lon": -1.826111}
|
| 166 |
+
]
|
| 167 |
+
}
|
| 168 |
+
]
|
| 169 |
+
|
| 170 |
+
df = pd.DataFrame(country_data)
|
| 171 |
+
|
| 172 |
+
class DeepSeekModel:
|
| 173 |
+
def __init__(self, model_path: str):
|
| 174 |
+
self.model_path = model_path
|
| 175 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 176 |
+
self.model = None
|
| 177 |
+
self.is_loaded = False
|
| 178 |
+
self.load_lock = threading.Lock()
|
| 179 |
+
self.country_data = country_data
|
| 180 |
+
|
| 181 |
+
def load_model(self):
|
| 182 |
+
"""Load the model in a separate thread to avoid blocking"""
|
| 183 |
+
if not self.is_loaded:
|
| 184 |
+
with self.load_lock:
|
| 185 |
+
if not self.is_loaded:
|
| 186 |
+
try:
|
| 187 |
+
# This would need to be implemented based on MLX's model loading
|
| 188 |
+
# For now, we'll use a placeholder
|
| 189 |
+
print("Loading DeepSeek model...")
|
| 190 |
+
time.sleep(2) # Simulate loading time
|
| 191 |
+
self.is_loaded = True
|
| 192 |
+
print("Model loaded successfully")
|
| 193 |
+
except Exception as e:
|
| 194 |
+
print(f"Error loading model: {e}")
|
| 195 |
+
|
| 196 |
+
def extract_country_from_query(self, prompt: str) -> str:
|
| 197 |
+
"""Extract country name from user query"""
|
| 198 |
+
prompt_lower = prompt.lower()
|
| 199 |
+
|
| 200 |
+
# Check for direct country mentions
|
| 201 |
+
for country in self.country_data:
|
| 202 |
+
if country['country'].lower() in prompt_lower:
|
| 203 |
+
return country['country']
|
| 204 |
+
|
| 205 |
+
# Check for capital mentions that might reference a country
|
| 206 |
+
for country in self.country_data:
|
| 207 |
+
if country['capital'].lower() in prompt_lower:
|
| 208 |
+
return country['country']
|
| 209 |
+
|
| 210 |
+
# Check for landmark mentions
|
| 211 |
+
for country in self.country_data:
|
| 212 |
+
for landmark in country['landmarks']:
|
| 213 |
+
if landmark['name'].lower() in prompt_lower:
|
| 214 |
+
return country['country']
|
| 215 |
+
|
| 216 |
+
return None
|
| 217 |
+
|
| 218 |
+
def get_landmark_coordinates(self, landmark_name: str) -> Optional[Dict]:
|
| 219 |
+
"""Get coordinates for a specific landmark"""
|
| 220 |
+
for country in self.country_data:
|
| 221 |
+
for landmark in country['landmarks']:
|
| 222 |
+
if landmark['name'].lower() == landmark_name.lower():
|
| 223 |
+
return {"lat": landmark['lat'], "lon": landmark['lon']}
|
| 224 |
+
return None
|
| 225 |
+
|
| 226 |
+
def generate_response(self, prompt: str, max_tokens: int = 200) -> str:
|
| 227 |
+
"""Generate response using DeepSeek model with country data integration"""
|
| 228 |
+
if not self.is_loaded:
|
| 229 |
+
return "Model is still loading. Please wait..."
|
| 230 |
+
|
| 231 |
+
try:
|
| 232 |
+
# Extract country from query
|
| 233 |
+
country_name = self.extract_country_from_query(prompt)
|
| 234 |
+
|
| 235 |
+
# Check for specific landmark queries
|
| 236 |
+
for country in self.country_data:
|
| 237 |
+
for landmark in country['landmarks']:
|
| 238 |
+
if landmark['name'].lower() in prompt.lower():
|
| 239 |
+
return f"The {landmark['name']} is located in {country['country']} at coordinates {landmark['lat']:.6f}, {landmark['lon']:.6f}. It's one of the most famous landmarks in {country['country']}."
|
| 240 |
+
|
| 241 |
+
# If we found a country, provide specific information
|
| 242 |
+
if country_name:
|
| 243 |
+
country_info = next((c for c in self.country_data if c['country'] == country_name), None)
|
| 244 |
+
|
| 245 |
+
if country_info:
|
| 246 |
+
if "capital" in prompt.lower():
|
| 247 |
+
return f"The capital of {country_info['country']} is {country_info['capital']}. It's located at coordinates {country_info['lat']:.4f}, {country_info['lon']:.4f}."
|
| 248 |
+
|
| 249 |
+
elif "landmark" in prompt.lower() or "landmarks" in prompt.lower():
|
| 250 |
+
landmarks = ", ".join([landmark['name'] for landmark in country_info['landmarks']])
|
| 251 |
+
return f"Famous landmarks in {country_info['country']} include: {landmarks}."
|
| 252 |
+
|
| 253 |
+
elif "coordinates" in prompt.lower() or "location" in prompt.lower() or "where" in prompt.lower():
|
| 254 |
+
landmarks_info = "\n".join([
|
| 255 |
+
f"- {landmark['name']}: {landmark['lat']:.6f}, {landmark['lon']:.6f}"
|
| 256 |
+
for landmark in country_info['landmarks']
|
| 257 |
+
])
|
| 258 |
+
return f"Coordinates for landmarks in {country_info['country']}:\n{landmarks_info}"
|
| 259 |
+
|
| 260 |
+
else:
|
| 261 |
+
# General information about the country
|
| 262 |
+
landmarks = ", ".join([landmark['name'] for landmark in country_info['landmarks']])
|
| 263 |
+
return f"{country_info['country']} has {country_info['capital']} as its capital. Famous landmarks include: {landmarks}. Capital coordinates: {country_info['lat']:.4f}, {country_info['lon']:.4f}."
|
| 264 |
+
|
| 265 |
+
# Handle general queries about all countries
|
| 266 |
+
if "all countries" in prompt.lower() or "list countries" in prompt.lower():
|
| 267 |
+
countries = ", ".join([c['country'] for c in self.country_data])
|
| 268 |
+
return f"The countries in our database are: {countries}."
|
| 269 |
+
|
| 270 |
+
if "all capitals" in prompt.lower():
|
| 271 |
+
capitals = ", ".join([f"{c['capital']} ({c['country']})" for c in self.country_data])
|
| 272 |
+
return f"The capitals in our database are: {capitals}."
|
| 273 |
+
|
| 274 |
+
if "all landmarks" in prompt.lower():
|
| 275 |
+
response = "Famous landmarks by country:\n"
|
| 276 |
+
for country in self.country_data:
|
| 277 |
+
landmarks = ", ".join([landmark['name'] for landmark in country['landmarks']])
|
| 278 |
+
response += f"{country['country']}: {landmarks}\n"
|
| 279 |
+
return response
|
| 280 |
+
|
| 281 |
+
# Default response for other queries
|
| 282 |
+
return "I'd be happy to help you explore world geography! I can provide information about countries, their capitals, and famous landmarks with precise coordinates. Try asking about a specific country, landmark, or location."
|
| 283 |
+
|
| 284 |
+
except Exception as e:
|
| 285 |
+
return f"Error generating response: {str(e)}"
|
| 286 |
+
|
| 287 |
+
# Initialize model
|
| 288 |
+
deepseek_model = DeepSeekModel(MODEL_PATH)
|
| 289 |
+
|
| 290 |
+
# Start loading model in background
|
| 291 |
+
loading_thread = threading.Thread(target=deepseek_model.load_model)
|
| 292 |
+
loading_thread.daemon = True
|
| 293 |
+
loading_thread.start()
|
| 294 |
+
|
| 295 |
+
# Create initial map
|
| 296 |
+
def create_world_map():
|
| 297 |
+
world_map = folium.Map(location=[20, 0], zoom_start=2, tiles='OpenStreetMap')
|
| 298 |
+
marker_cluster = MarkerCluster().add_to(world_map)
|
| 299 |
+
|
| 300 |
+
for _, row in df.iterrows():
|
| 301 |
+
# Country capital marker
|
| 302 |
+
folium.Marker(
|
| 303 |
+
location=[row['lat'], row['lon']],
|
| 304 |
+
popup=f"""
|
| 305 |
+
<b>Country:</b> {row['country']}<br>
|
| 306 |
+
<b>Capital:</b> {row['capital']}<br>
|
| 307 |
+
<b>Coordinates:</b> {row['lat']:.6f}, {row['lon']:.6f}<br>
|
| 308 |
+
<b>Famous Landmarks:</b> {', '.join([landmark['name'] for landmark in row['landmarks']])}
|
| 309 |
+
""",
|
| 310 |
+
tooltip=f"Click for info about {row['country']}",
|
| 311 |
+
icon=folium.Icon(color='blue', icon='flag')
|
| 312 |
+
).add_to(marker_cluster)
|
| 313 |
+
|
| 314 |
+
# Add landmarks with precise coordinates
|
| 315 |
+
for landmark in row['landmarks']:
|
| 316 |
+
folium.Marker(
|
| 317 |
+
location=[landmark['lat'], landmark['lon']],
|
| 318 |
+
popup=f"""
|
| 319 |
+
<b>Landmark:</b> {landmark['name']}<br>
|
| 320 |
+
<b>Country:</b> {row['country']}<br>
|
| 321 |
+
<b>Coordinates:</b> {landmark['lat']:.6f}, {landmark['lon']:.6f}
|
| 322 |
+
""",
|
| 323 |
+
tooltip=landmark['name'],
|
| 324 |
+
icon=folium.Icon(color='green', icon='camera')
|
| 325 |
+
).add_to(marker_cluster)
|
| 326 |
+
|
| 327 |
+
return world_map
|
| 328 |
+
|
| 329 |
+
# Initialize Dash app
|
| 330 |
+
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
|
| 331 |
+
app.title = "World Explorer with DeepSeek AI"
|
| 332 |
+
|
| 333 |
+
# Layout
|
| 334 |
+
app.layout = dbc.Container([
|
| 335 |
+
dbc.Row([
|
| 336 |
+
dbc.Col([
|
| 337 |
+
html.H1("🌍 World Explorer with DeepSeek AI",
|
| 338 |
+
className="text-center mb-4", style={'color': '#2c3e50'})
|
| 339 |
+
], width=12)
|
| 340 |
+
]),
|
| 341 |
+
|
| 342 |
+
dbc.Row([
|
| 343 |
+
dbc.Col([
|
| 344 |
+
dbc.Card([
|
| 345 |
+
dbc.CardHeader("🗺️ Interactive World Map", className="bg-primary text-white"),
|
| 346 |
+
dbc.CardBody([
|
| 347 |
+
html.Iframe(
|
| 348 |
+
id='world-map',
|
| 349 |
+
srcDoc=create_world_map()._repr_html_(),
|
| 350 |
+
width='100%',
|
| 351 |
+
height='500'
|
| 352 |
+
)
|
| 353 |
+
])
|
| 354 |
+
], className="mb-4")
|
| 355 |
+
], width=8),
|
| 356 |
+
|
| 357 |
+
dbc.Col([
|
| 358 |
+
dbc.Card([
|
| 359 |
+
dbc.CardHeader("💬 DeepSeek AI Assistant", className="bg-success text-white"),
|
| 360 |
+
dbc.CardBody([
|
| 361 |
+
dcc.Textarea(
|
| 362 |
+
id='user-input',
|
| 363 |
+
placeholder='Ask about countries, capitals, landmarks, or coordinates...',
|
| 364 |
+
style={'width': '100%', 'height': '100px', 'margin-bottom': '10px'}
|
| 365 |
+
),
|
| 366 |
+
dbc.Button("Ask DeepSeek", id='ask-button', color="primary", className="w-100 mb-3"),
|
| 367 |
+
dbc.Alert("Model is loading...", id="model-status", color="warning", className="mb-3"),
|
| 368 |
+
html.Div(id='ai-response', style={
|
| 369 |
+
'height': '300px',
|
| 370 |
+
'overflow-y': 'auto',
|
| 371 |
+
'padding': '10px',
|
| 372 |
+
'border': '1px solid #ddd',
|
| 373 |
+
'border-radius': '5px',
|
| 374 |
+
'background-color': '#f8f9fa'
|
| 375 |
+
})
|
| 376 |
+
])
|
| 377 |
+
])
|
| 378 |
+
], width=4)
|
| 379 |
+
]),
|
| 380 |
+
|
| 381 |
+
dbc.Row([
|
| 382 |
+
dbc.Col([
|
| 383 |
+
dbc.Card([
|
| 384 |
+
dbc.CardHeader("📊 Country Information", className="bg-info text-white"),
|
| 385 |
+
dbc.CardBody([
|
| 386 |
+
dcc.Dropdown(
|
| 387 |
+
id='country-selector',
|
| 388 |
+
options=[{'label': country, 'value': country} for country in df['country']],
|
| 389 |
+
value='France',
|
| 390 |
+
clearable=False
|
| 391 |
+
),
|
| 392 |
+
html.Div(id='country-info', style={'margin-top': '15px'})
|
| 393 |
+
])
|
| 394 |
+
])
|
| 395 |
+
], width=12)
|
| 396 |
+
], className="mt-4"),
|
| 397 |
+
|
| 398 |
+
# Hidden div to trigger model loading check
|
| 399 |
+
html.Div(id='hidden-div', style={'display': 'none'})
|
| 400 |
+
], fluid=True)
|
| 401 |
+
|
| 402 |
+
# Callbacks
|
| 403 |
+
@app.callback(
|
| 404 |
+
Output('model-status', 'children'),
|
| 405 |
+
Output('model-status', 'color'),
|
| 406 |
+
Input('hidden-div', 'children')
|
| 407 |
+
)
|
| 408 |
+
def check_model_status(_):
|
| 409 |
+
if deepseek_model.is_loaded:
|
| 410 |
+
return "Model loaded and ready!", "success"
|
| 411 |
+
else:
|
| 412 |
+
return "Model is still loading...", "warning"
|
| 413 |
+
|
| 414 |
+
@app.callback(
|
| 415 |
+
Output('ai-response', 'children'),
|
| 416 |
+
Input('ask-button', 'n_clicks'),
|
| 417 |
+
State('user-input', 'value')
|
| 418 |
+
)
|
| 419 |
+
def generate_ai_response(n_clicks, user_input):
|
| 420 |
+
if n_clicks is None or not user_input:
|
| 421 |
+
return "Enter a question about countries, capitals, landmarks, or coordinates above!"
|
| 422 |
+
|
| 423 |
+
response = deepseek_model.generate_response(user_input)
|
| 424 |
+
return html.Div([
|
| 425 |
+
html.P("🤖 DeepSeek Response:", style={'font-weight': 'bold', 'color': '#28a745'}),
|
| 426 |
+
html.P(response, style={'white-space': 'pre-wrap'})
|
| 427 |
+
])
|
| 428 |
+
|
| 429 |
+
@app.callback(
|
| 430 |
+
Output('country-info', 'children'),
|
| 431 |
+
Input('country-selector', 'value')
|
| 432 |
+
)
|
| 433 |
+
def update_country_info(selected_country):
|
| 434 |
+
country = df[df['country'] == selected_country].iloc[0]
|
| 435 |
+
|
| 436 |
+
landmarks_list = html.Ul([
|
| 437 |
+
html.Li(f"{landmark['name']} ({landmark['lat']:.6f}, {landmark['lon']:.6f})")
|
| 438 |
+
for landmark in country['landmarks']
|
| 439 |
+
])
|
| 440 |
+
|
| 441 |
+
return html.Div([
|
| 442 |
+
html.H4(f"🇺🇳 {country['country']}"),
|
| 443 |
+
html.P(f"📍 Capital: {country['capital']}"),
|
| 444 |
+
html.P(f"🌐 Coordinates: {country['lat']:.6f}, {country['lon']:.6f}"),
|
| 445 |
+
html.H5("🏛️ Famous Landmarks with Coordinates:"),
|
| 446 |
+
landmarks_list
|
| 447 |
+
])
|
| 448 |
+
|
| 449 |
+
@app.callback(
|
| 450 |
+
Output('world-map', 'srcDoc'),
|
| 451 |
+
Input('country-selector', 'value')
|
| 452 |
+
)
|
| 453 |
+
def update_map(selected_country):
|
| 454 |
+
world_map = create_world_map()
|
| 455 |
+
|
| 456 |
+
# Center map on selected country
|
| 457 |
+
country_data = df[df['country'] == selected_country].iloc[0]
|
| 458 |
+
world_map.location = [country_data['lat'], country_data['lon']]
|
| 459 |
+
world_map.zoom_start = 5
|
| 460 |
+
|
| 461 |
+
return world_map._repr_html_()
|
| 462 |
+
|
| 463 |
+
if __name__ == '__main__':
|
| 464 |
+
app.run(debug=True, port=8050)
|
installed_packages_venv.txt
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blinker==1.9.0
|
| 2 |
+
branca==0.8.1
|
| 3 |
+
certifi==2025.8.3
|
| 4 |
+
charset-normalizer==3.4.3
|
| 5 |
+
click==8.2.1
|
| 6 |
+
dash==3.2.0
|
| 7 |
+
dash-bootstrap-components==2.0.4
|
| 8 |
+
filelock==3.19.1
|
| 9 |
+
Flask==3.1.2
|
| 10 |
+
folium==0.20.0
|
| 11 |
+
fsspec==2025.9.0
|
| 12 |
+
hf-xet==1.1.9
|
| 13 |
+
huggingface-hub==0.34.4
|
| 14 |
+
idna==3.10
|
| 15 |
+
importlib_metadata==8.7.0
|
| 16 |
+
itsdangerous==2.2.0
|
| 17 |
+
Jinja2==3.1.6
|
| 18 |
+
MarkupSafe==3.0.2
|
| 19 |
+
mlx==0.29.0
|
| 20 |
+
mlx-metal==0.29.0
|
| 21 |
+
narwhals==2.3.0
|
| 22 |
+
nest-asyncio==1.6.0
|
| 23 |
+
numpy==2.3.2
|
| 24 |
+
packaging==25.0
|
| 25 |
+
pandas==2.3.2
|
| 26 |
+
plotly==6.3.0
|
| 27 |
+
python-dateutil==2.9.0.post0
|
| 28 |
+
pytz==2025.2
|
| 29 |
+
PyYAML==6.0.2
|
| 30 |
+
regex==2025.9.1
|
| 31 |
+
requests==2.32.5
|
| 32 |
+
retrying==1.4.2
|
| 33 |
+
safetensors==0.6.2
|
| 34 |
+
setuptools==80.9.0
|
| 35 |
+
six==1.17.0
|
| 36 |
+
tokenizers==0.22.0
|
| 37 |
+
tqdm==4.67.1
|
| 38 |
+
transformers==4.56.1
|
| 39 |
+
typing_extensions==4.15.0
|
| 40 |
+
tzdata==2025.2
|
| 41 |
+
urllib3==2.5.0
|
| 42 |
+
Werkzeug==3.1.3
|
| 43 |
+
xyzservices==2025.4.0
|
| 44 |
+
zipp==3.23.0
|
output.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d0c509755d14b6662eefa1007d7baf3c93a83e42e089ba375ee9a8c29db1266
|
| 3 |
+
size 15713795
|