Spaces:
Sleeping
Sleeping
Fix get_wildfires to use NASA EONET and update UI with Glassmorphism
Browse files
app.py
CHANGED
|
@@ -34,21 +34,20 @@ def get_earthquakes(start_date: str, end_date: str, min_magnitude: float):
|
|
| 34 |
|
| 35 |
def get_wildfires(limit: int = 5):
|
| 36 |
"""
|
| 37 |
-
Dünya genelindeki son aktif orman yangınlarını (
|
| 38 |
"""
|
| 39 |
try:
|
| 40 |
-
url = "https://
|
| 41 |
res = requests.get(url, timeout=10)
|
| 42 |
data = res.json()
|
| 43 |
-
|
| 44 |
results = []
|
| 45 |
-
for
|
| 46 |
-
|
| 47 |
results.append({
|
| 48 |
-
"
|
| 49 |
-
"
|
| 50 |
-
"
|
| 51 |
-
"description": props.get('htmldescription')
|
| 52 |
})
|
| 53 |
return {"count": len(results), "wildfires": results}
|
| 54 |
except Exception as e:
|
|
@@ -80,7 +79,7 @@ tools = [
|
|
| 80 |
"type": "function",
|
| 81 |
"function": {
|
| 82 |
"name": "get_wildfires",
|
| 83 |
-
"description": "Güncel aktif orman yangınlarını
|
| 84 |
"parameters": {
|
| 85 |
"type": "object",
|
| 86 |
"properties": {
|
|
@@ -234,24 +233,39 @@ def chat_interface(user_input, history):
|
|
| 234 |
# ==========================================
|
| 235 |
# 4. Gradio UI
|
| 236 |
# ==========================================
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
gr.Examples(
|
| 251 |
examples=[
|
| 252 |
-
"
|
| 253 |
"Şu anki aktif büyük orman yangınları hangileri? 3 tanesini getir.",
|
| 254 |
-
"Son 7 günde 6.0'dan büyük deprem oldu mu? Ayrıca şu an aktif orman yangını var mı?"
|
| 255 |
],
|
| 256 |
inputs=msg
|
| 257 |
)
|
|
|
|
| 34 |
|
| 35 |
def get_wildfires(limit: int = 5):
|
| 36 |
"""
|
| 37 |
+
Dünya genelindeki son aktif orman yangınlarını (NASA EONET üzerinden) getirir.
|
| 38 |
"""
|
| 39 |
try:
|
| 40 |
+
url = "https://eonet.gsfc.nasa.gov/api/v3/events?category=wildfires&status=open"
|
| 41 |
res = requests.get(url, timeout=10)
|
| 42 |
data = res.json()
|
| 43 |
+
events = data.get('events', [])[:limit]
|
| 44 |
results = []
|
| 45 |
+
for e in events:
|
| 46 |
+
geom = e.get('geometry', [{}])[0]
|
| 47 |
results.append({
|
| 48 |
+
"title": e.get('title'),
|
| 49 |
+
"date": geom.get('date'),
|
| 50 |
+
"coordinates": geom.get('coordinates')
|
|
|
|
| 51 |
})
|
| 52 |
return {"count": len(results), "wildfires": results}
|
| 53 |
except Exception as e:
|
|
|
|
| 79 |
"type": "function",
|
| 80 |
"function": {
|
| 81 |
"name": "get_wildfires",
|
| 82 |
+
"description": "Güncel aktif orman yangınlarını NASA EONET üzerinden getirir.",
|
| 83 |
"parameters": {
|
| 84 |
"type": "object",
|
| 85 |
"properties": {
|
|
|
|
| 233 |
# ==========================================
|
| 234 |
# 4. Gradio UI
|
| 235 |
# ==========================================
|
| 236 |
+
css = """
|
| 237 |
+
body {
|
| 238 |
+
background: linear-gradient(135deg, #121212, #000000);
|
| 239 |
+
}
|
| 240 |
+
#chatbot {
|
| 241 |
+
background: rgba(255, 255, 255, 0.04) !important;
|
| 242 |
+
backdrop-filter: blur(12px) !important;
|
| 243 |
+
border-radius: 24px !important;
|
| 244 |
+
border: 0.5px solid rgba(255, 255, 255, 0.1) !important;
|
| 245 |
+
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37) !important;
|
| 246 |
+
}
|
| 247 |
+
.message {
|
| 248 |
+
border-radius: 16px !important;
|
| 249 |
+
padding: 12px 18px !important;
|
| 250 |
+
}
|
| 251 |
+
"""
|
| 252 |
+
|
| 253 |
+
with gr.Blocks(theme=gr.themes.Base(), css=css) as demo:
|
| 254 |
+
gr.Markdown("<h1 style='text-align: center; font-weight: 300; color: #fff;'>🌍 Agentic Disaster Tracker</h1>")
|
| 255 |
+
gr.Markdown("<p style='text-align: center; color: #aaa;'>Bu uygulama <b>Tool Calling</b> teknolojisini kullanarak, dünya genelindeki deprem ve orman yangınlarını takip eder.<br>Hugging Face <b>ZeroGPU</b> altyapısı ve <b>Qwen2.5-7B-Instruct</b> modeli kullanılarak geliştirilmiştir.</p>")
|
| 256 |
|
| 257 |
+
with gr.Row():
|
| 258 |
+
chatbot = gr.Chatbot(elem_id="chatbot", height=600, label="Afet Takip Asistanı", show_label=False)
|
| 259 |
+
|
| 260 |
+
with gr.Row():
|
| 261 |
+
msg = gr.Textbox(placeholder="Örn: 2026-07-25 ile 2026-07-30 arasındaki yangınlar...", label="Mesajınız", lines=2, show_label=False)
|
| 262 |
+
submit_btn = gr.Button("Gönder", variant="primary", scale=0)
|
| 263 |
|
| 264 |
gr.Examples(
|
| 265 |
examples=[
|
| 266 |
+
"2026-07-25 ile 2026-07-30 tarihleri arasındaki 5.5 üzeri depremleri listele.",
|
| 267 |
"Şu anki aktif büyük orman yangınları hangileri? 3 tanesini getir.",
|
| 268 |
+
"Son 7 günde (2026-07-23 ile 2026-07-30) 6.0'dan büyük deprem oldu mu? Ayrıca şu an aktif orman yangını var mı?"
|
| 269 |
],
|
| 270 |
inputs=msg
|
| 271 |
)
|