Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import datetime
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
|
|
@@ -10,25 +11,36 @@ from Gradio_UI import GradioUI
|
|
| 10 |
|
| 11 |
|
| 12 |
@tool
|
| 13 |
-
def GetElectricityCutInfo(
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
"""
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
+
import pandas as pd
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
from tools.visit_webpage import VisitWebpageTool
|
| 9 |
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
@tool
|
| 14 |
+
def GetElectricityCutInfo(locationName: str) -> str:
|
| 15 |
+
"""A tool that searches for electricity cut information by City or District from an Excel file.
|
| 16 |
Args:
|
| 17 |
+
locationName: The name of the City or District to search for (e.g., 'Beşiktaş' or 'İzmir').
|
| 18 |
"""
|
| 19 |
+
try:
|
| 20 |
+
# Excel dosyasını oku (Dosya adının 'kesintiler.xlsx' olduğunu varsayıyorum)
|
| 21 |
+
df = pd.read_excel("kesintiler.xlsx")
|
| 22 |
+
|
| 23 |
+
# Karşılaştırma kolaylığı için tüm tabloyu ve aranan kelimeyi küçük harfe çevirelim
|
| 24 |
+
search_term = locationName.lower().strip()
|
| 25 |
+
|
| 26 |
+
# Hem 'İl' hem de 'İlçe' sütununda arama yapalım
|
| 27 |
+
# Not: Sütun isimlerinin Excel'de 'İl', 'İlçe', 'Kesinti', 'Açıklama' olduğundan emin ol.
|
| 28 |
+
result = df[
|
| 29 |
+
(df['İl'].astype(str).str.lower() == search_term) |
|
| 30 |
+
(df['İlçe'].astype(str).str.lower() == search_term)
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
if not result.empty:
|
| 34 |
+
responses = []
|
| 35 |
+
for _, row in result.iterrows():
|
| 36 |
+
info = f"📍 {row['İl']} - {row['İlçe']}: Kesinti {row['Kesinti']}. Bilgi: {row['Açıklama']}"
|
| 37 |
+
responses.append(info)
|
| 38 |
+
return "\n".join(responses)
|
| 39 |
+
else:
|
| 40 |
+
return f"'{locationName}' için sistemde bir kesinti kaydı bulunamadı."
|
| 41 |
+
|
| 42 |
+
except Exception as e:
|
| 43 |
+
return f"Veri okunurken hata oluştu: {str(e)}"
|
| 44 |
|
| 45 |
@tool
|
| 46 |
def get_current_time_in_timezone(timezone: str) -> str:
|