Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import requests
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
@@ -34,6 +36,40 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
+
from typing import List, Dict, Any, Optional
|
8 |
+
from duckduckgo_search import DDGS
|
9 |
|
10 |
from Gradio_UI import GradioUI
|
11 |
|
|
|
36 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
37 |
|
38 |
|
39 |
+
# Simple Germany bounding box
|
40 |
+
GERMANY_BBOX = (5.8663, 47.2701, 15.0419, 55.0581)
|
41 |
+
|
42 |
+
@tool
|
43 |
+
def DuckDuckGoSearchTool(query: str, city: Optional[str] = None, limit: int = 10) -> List[Dict[str, Any]]:
|
44 |
+
"""A tool that searches DuckDuckGo Maps for cafes in Germany.
|
45 |
+
Args:
|
46 |
+
query: A string to refine the cafe search (e.g., 'vegan', 'wifi').
|
47 |
+
city: Optional German city name (e.g., 'Berlin', 'Munich').
|
48 |
+
limit: Maximum number of cafes to return.
|
49 |
+
"""
|
50 |
+
try:
|
51 |
+
maps_query = f"cafe {query}".strip()
|
52 |
+
results = []
|
53 |
+
|
54 |
+
with DDGS() as ddgs:
|
55 |
+
for item in ddgs.maps(maps_query, region="de-de", bbox=GERMANY_BBOX, max_results=limit):
|
56 |
+
results.append({
|
57 |
+
"name": item.get("title"),
|
58 |
+
"address": item.get("address"),
|
59 |
+
"website": item.get("url"),
|
60 |
+
"phone": item.get("phone"),
|
61 |
+
"rating": item.get("rating"),
|
62 |
+
"lat": (item.get("coordinates") or {}).get("latitude"),
|
63 |
+
"lon": (item.get("coordinates") or {}).get("longitude"),
|
64 |
+
})
|
65 |
+
|
66 |
+
return results
|
67 |
+
|
68 |
+
except Exception as e:
|
69 |
+
return [{"error": f"Failed to fetch cafes: {str(e)}"}]
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
final_answer = FinalAnswerTool()
|
74 |
|
75 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|