mahichr commited on
Commit
be8b59f
·
verified ·
1 Parent(s): 7e3b23e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -21,6 +21,23 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
21
  """
22
  return "What magic will you build ?"
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  # Example function decorator for weather (alternative to class-based tool)
25
  @tool
26
  def get_weather_simple(city: str) -> str:
@@ -90,7 +107,7 @@ with open("prompts.yaml", 'r') as stream:
90
 
91
  agent = CodeAgent(
92
  model=model,
93
- tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone, weather_tool, get_weather_simple], ## add your tools here (don't remove final answer)
94
  max_steps=6,
95
  verbosity_level=1,
96
  grammar=None,
 
21
  """
22
  return "What magic will you build ?"
23
 
24
+ @tool
25
+ def sprinkler_control(weather_condition: str) -> str:
26
+ """A simple sprinkler control tool that decides whether to turn on sprinklers based on weather condition.
27
+ Args:
28
+ weather_condition: Weather condition as a string - either "Rainy" or "Not Rainy"
29
+ """
30
+ # Normalize the input to handle variations
31
+ condition = weather_condition.strip().lower()
32
+
33
+ if condition == "rainy" or condition == "rain" or "rainy" in condition:
34
+ return "Don't turn on Sprinkler"
35
+ elif condition == "not rainy" or condition == "no rain" or "not rainy" in condition or condition == "clear" or condition == "sunny":
36
+ return "Turn on Sprinkler"
37
+ else:
38
+ return f"Invalid weather condition '{weather_condition}'. Please use 'Rainy' or 'Not Rainy'"
39
+
40
+
41
  # Example function decorator for weather (alternative to class-based tool)
42
  @tool
43
  def get_weather_simple(city: str) -> str:
 
107
 
108
  agent = CodeAgent(
109
  model=model,
110
+ tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone, weather_tool, get_weather_simple, sprinkler_control], ## add your tools here (don't remove final answer)
111
  max_steps=6,
112
  verbosity_level=1,
113
  grammar=None,