Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,13 +22,13 @@ def my_custom_tool(arg1:str, arg2:int): str #it's import to specify the return t
|
|
| 22 |
Args:
|
| 23 |
arg1: the first argument
|
| 24 |
arg2: the second argument
|
| 25 |
-
|
| 26 |
return "What magic will you build ?"
|
| 27 |
|
| 28 |
@tool
|
| 29 |
def get_location_tool(ip: str): str
|
| 30 |
|
| 31 |
-
|
| 32 |
Args:
|
| 33 |
ip: A string representing a valid ip address (e.g., '192.168.10.1')
|
| 34 |
|
|
@@ -48,7 +48,7 @@ def get_location_tool(ip: str): str
|
|
| 48 |
longitude: A string representing valid longitude coordinates (e.g, '73.989308')
|
| 49 |
|
| 50 |
Returns: ip address, city, region, country, and geo coordinates
|
| 51 |
-
|
| 52 |
|
| 53 |
response = DbIpCity.get(ip, api_key='free')
|
| 54 |
return {
|
|
@@ -66,12 +66,13 @@ print(location)
|
|
| 66 |
|
| 67 |
@tool
|
| 68 |
def get_current_time_in_timezone(timezone: str): str
|
| 69 |
-
|
|
|
|
| 70 |
Args:
|
| 71 |
timezone: A string representing a valid timezone (e.g., 'America/New_York')
|
| 72 |
|
| 73 |
Returns: The current local time in the following format ("%Y-%m-%d %H:%M:%S")
|
| 74 |
-
|
| 75 |
try:
|
| 76 |
# Create timezone object
|
| 77 |
tz = pytz.timezone(timezone)
|
|
@@ -96,13 +97,14 @@ custom_role_conversions=None,
|
|
| 96 |
|
| 97 |
@tool
|
| 98 |
def get_weather_data(city: str):
|
| 99 |
-
|
|
|
|
| 100 |
Returns weather data for a given city.
|
| 101 |
Args:
|
| 102 |
city: The name of the city (e.g., New York, London, Tokyo)
|
| 103 |
Returns:
|
| 104 |
A dictionary containing weather data
|
| 105 |
-
|
| 106 |
# Get weather for multiple cities
|
| 107 |
cities = ["Tokyo", "New York", "London"]
|
| 108 |
data = {}
|
|
@@ -118,14 +120,14 @@ print(f"The warmest city is {warmest_city} with an average of {avg_temps[warmest
|
|
| 118 |
|
| 119 |
@tool
|
| 120 |
def hotel_recommendation_tool(city: str,price: str): str
|
| 121 |
-
|
| 122 |
Args:
|
| 123 |
city: A string representing a valid city (e.g., 'Dubai, Singapore')
|
| 124 |
Args:
|
| 125 |
price: A string representing a valid price for the hotel rooms (e.g., '$160/night, $100/day')
|
| 126 |
|
| 127 |
Returns: A hotel name in a particular city with its pricing, and rating information
|
| 128 |
-
|
| 129 |
|
| 130 |
if(price!="-"):
|
| 131 |
response=ur.request.urlopen('https://foursquare.com/explore?mode=url&near='+city+'&price='+price+'&q=Resturant')
|
|
@@ -237,12 +239,13 @@ def get():
|
|
| 237 |
|
| 238 |
@tool
|
| 239 |
CustomDuckDuckGoSearchTool(DuckDuckGoSearchTool: query): query
|
| 240 |
-
|
|
|
|
| 241 |
name = "web_search"
|
| 242 |
description = "Performs a web search for a query and returns a list of the top search results formatted as markdown with page titles and urls."
|
| 243 |
inputs = {"query": {"type": "string", "description": "The search query to perform."}}
|
| 244 |
output_type = "string"
|
| 245 |
-
|
| 246 |
|
| 247 |
tool = CustomDuckDuckGoSearchTool(
|
| 248 |
max_results=3,
|
|
|
|
| 22 |
Args:
|
| 23 |
arg1: the first argument
|
| 24 |
arg2: the second argument
|
| 25 |
+
"""
|
| 26 |
return "What magic will you build ?"
|
| 27 |
|
| 28 |
@tool
|
| 29 |
def get_location_tool(ip: str): str
|
| 30 |
|
| 31 |
+
"""This is a tool that gets the exact location of a user including city, region, country, latitude, and longitude.
|
| 32 |
Args:
|
| 33 |
ip: A string representing a valid ip address (e.g., '192.168.10.1')
|
| 34 |
|
|
|
|
| 48 |
longitude: A string representing valid longitude coordinates (e.g, '73.989308')
|
| 49 |
|
| 50 |
Returns: ip address, city, region, country, and geo coordinates
|
| 51 |
+
"""
|
| 52 |
|
| 53 |
response = DbIpCity.get(ip, api_key='free')
|
| 54 |
return {
|
|
|
|
| 66 |
|
| 67 |
@tool
|
| 68 |
def get_current_time_in_timezone(timezone: str): str
|
| 69 |
+
|
| 70 |
+
"""A tool that fetches the current local time in a specified timezone.
|
| 71 |
Args:
|
| 72 |
timezone: A string representing a valid timezone (e.g., 'America/New_York')
|
| 73 |
|
| 74 |
Returns: The current local time in the following format ("%Y-%m-%d %H:%M:%S")
|
| 75 |
+
"""
|
| 76 |
try:
|
| 77 |
# Create timezone object
|
| 78 |
tz = pytz.timezone(timezone)
|
|
|
|
| 97 |
|
| 98 |
@tool
|
| 99 |
def get_weather_data(city: str):
|
| 100 |
+
|
| 101 |
+
"""
|
| 102 |
Returns weather data for a given city.
|
| 103 |
Args:
|
| 104 |
city: The name of the city (e.g., New York, London, Tokyo)
|
| 105 |
Returns:
|
| 106 |
A dictionary containing weather data
|
| 107 |
+
"""
|
| 108 |
# Get weather for multiple cities
|
| 109 |
cities = ["Tokyo", "New York", "London"]
|
| 110 |
data = {}
|
|
|
|
| 120 |
|
| 121 |
@tool
|
| 122 |
def hotel_recommendation_tool(city: str,price: str): str
|
| 123 |
+
"""This is a hotel recommendation tool that web scrapes foursquare.com, and yelp.com for hotel ratings, user comments, and hotel information.
|
| 124 |
Args:
|
| 125 |
city: A string representing a valid city (e.g., 'Dubai, Singapore')
|
| 126 |
Args:
|
| 127 |
price: A string representing a valid price for the hotel rooms (e.g., '$160/night, $100/day')
|
| 128 |
|
| 129 |
Returns: A hotel name in a particular city with its pricing, and rating information
|
| 130 |
+
"""
|
| 131 |
|
| 132 |
if(price!="-"):
|
| 133 |
response=ur.request.urlopen('https://foursquare.com/explore?mode=url&near='+city+'&price='+price+'&q=Resturant')
|
|
|
|
| 239 |
|
| 240 |
@tool
|
| 241 |
CustomDuckDuckGoSearchTool(DuckDuckGoSearchTool: query): query
|
| 242 |
+
|
| 243 |
+
"""
|
| 244 |
name = "web_search"
|
| 245 |
description = "Performs a web search for a query and returns a list of the top search results formatted as markdown with page titles and urls."
|
| 246 |
inputs = {"query": {"type": "string", "description": "The search query to perform."}}
|
| 247 |
output_type = "string"
|
| 248 |
+
"""
|
| 249 |
|
| 250 |
tool = CustomDuckDuckGoSearchTool(
|
| 251 |
max_results=3,
|