kolkhi commited on
Commit
f98f944
·
verified ·
1 Parent(s): 5319972

Add custom tool to get sunrise sunset data

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -10,14 +10,20 @@ from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
- """A tool that does nothing yet
16
  Args:
17
- arg1: the first argument
18
- arg2: the second argument
19
  """
20
- return "What magic will you build ?"
 
 
 
 
 
 
21
 
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -58,7 +64,7 @@ with open("prompts.yaml", 'r') as stream:
58
 
59
  agent = CodeAgent(
60
  model=model,
61
- tools=[image_generation_tool, get_current_time_in_timezone, final_answer, web_search_tool, visit_web_tool], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,
64
  grammar=None,
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def sunrise_sunset_tool(lat:str, lng:str)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
+ """A tool that returns sunrise and sunset times for location specified by latitude and longitude
16
  Args:
17
+ lat: A string representing location latitude
18
+ long: A string representing location longitude
19
  """
20
+ try:
21
+ sunrise = "7:27:02 AM"
22
+ sunset = "5:05:55 PM"
23
+ return f"The sunrise time is {sunrise} and sunset time is {sunset}"
24
+ except Exception as e:
25
+ return f"Error fetching sunrise/sunset data for location lat={lat} long={lng}"
26
+
27
 
28
  @tool
29
  def get_current_time_in_timezone(timezone: str) -> str:
 
64
 
65
  agent = CodeAgent(
66
  model=model,
67
+ tools=[sunrise_sunset_tool, image_generation_tool, get_current_time_in_timezone, final_answer, web_search_tool, visit_web_tool], ## add your tools here (don't remove final answer)
68
  max_steps=6,
69
  verbosity_level=1,
70
  grammar=None,