BlackDragon13x commited on
Commit
82687d6
·
verified ·
1 Parent(s): f8e4a71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -4,7 +4,6 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
@@ -33,6 +32,23 @@ 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
  @tool
37
  def get_current_weather(city: str) -> str:
38
  """Fetches the current weather for a given city.
@@ -74,7 +90,7 @@ with open("prompts.yaml", 'r') as stream:
74
 
75
  agent = CodeAgent(
76
  model=model,
77
- tools=[final_answer, get_current_time_in_timezone, get_current_weather], ## add your tools here (don't remove final answer)
78
  max_steps=6,
79
  verbosity_level=1,
80
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from Gradio_UI import GradioUI
8
 
9
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
32
  except Exception as e:
33
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
34
 
35
+
36
+ @tool
37
+ def get_random_cat_picture() -> str:
38
+ """Fetches a random cat picture URL.
39
+
40
+ Returns:
41
+ A URL to a random cat picture.
42
+ """
43
+ api_url = "https://api.thecatapi.com/v1/images/search"
44
+
45
+ try:
46
+ response = requests.get(api_url)
47
+ data = response.json()
48
+ return data[0]["url"] # Extract the image URL
49
+ except Exception as e:
50
+ return f"Error fetching cat image: {str(e)}"
51
+
52
  @tool
53
  def get_current_weather(city: str) -> str:
54
  """Fetches the current weather for a given city.
 
90
 
91
  agent = CodeAgent(
92
  model=model,
93
+ tools=[final_answer, get_current_time_in_timezone, get_current_weather, get_random_cat_picture], ## add your tools here (don't remove final answer)
94
  max_steps=6,
95
  verbosity_level=1,
96
  grammar=None,