dianamclean commited on
Commit
a6c08bf
·
verified ·
1 Parent(s): b67587c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -33,6 +33,30 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  # Below is my attempt to use the structure provided
37
  @tool
38
  def my_ai_joke (arg1:str, arg2:int)-> str: #it's import to specify the return type
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+
37
+
38
+ @tool
39
+ def get_things_todo(city: str) -> str:
40
+ """A tool that gets a lits of things to do by searching the internet in a city
41
+ Args:
42
+ city: Name of the city
43
+ """
44
+ try:
45
+ search_tool = DuckDuckGoSearchTool(max_results=5)
46
+ results = search_tool.forward(
47
+ f"Get a list of things to do in {city} for families "
48
+ )
49
+
50
+ if results:
51
+ top_result = results[0] # Assuming results is a list
52
+ return top_result
53
+ else:
54
+ return "No results found."
55
+ except requests.exceptions.RequestException as e:
56
+ return f"Error: Failed to connect to the search. Details: {str(e)}"
57
+ except Exception as e:
58
+ return f"Error: An unexpected error occurred. Details: {str(e)}"
59
+
60
  # Below is my attempt to use the structure provided
61
  @tool
62
  def my_ai_joke (arg1:str, arg2:int)-> str: #it's import to specify the return type