jtyler379 commited on
Commit
e596c2c
·
verified ·
1 Parent(s): 7d06702

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -25
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
3
  import datetime
4
  import requests
@@ -10,30 +9,14 @@ 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:
14
- """A tool that calculates days until Christmas
15
-
16
  Args:
17
- arg1: date in format 'YYYY-MM-DD'
18
- arg2: year for Christmas (usually same as input date year)
19
  """
20
- try:
21
- # Parse the date from arg1
22
- date_parts = [int(x) for x in arg1.split("-")]
23
- year, month, day = date_parts
24
-
25
- # Calculate days until Christmas
26
- next_xmas_year = arg2
27
- if month == 12 and day > 25:
28
- next_xmas_year = year + 1
29
-
30
- d1 = datetime.datetime(next_xmas_year, 12, 25)
31
- d2 = datetime.datetime(year, month, day)
32
- number_of_days = abs((d2 - d1).days)
33
-
34
- return f"There are {number_of_days} days until Christmas"
35
- except Exception as e:
36
- return f"Error calculating days: {str(e)}"
37
 
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -72,14 +55,14 @@ with open("prompts.yaml", 'r') as stream:
72
 
73
  agent = CodeAgent(
74
  model=model,
75
- tools=[final_answer, my_custom_tool, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
76
  max_steps=6,
77
  verbosity_level=1,
78
  grammar=None,
79
  planning_interval=None,
80
  name=None,
81
  description=None,
82
- prompt_templates=None
83
  )
84
 
85
 
 
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
+ #Keep this format for the description / args / args description but feel free to modify the tool
14
+ """A tool that does nothing yet
15
  Args:
16
+ arg1: the first argument
17
+ arg2: the second argument
18
  """
19
+ return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
55
 
56
  agent = CodeAgent(
57
  model=model,
58
+ tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
62
  planning_interval=None,
63
  name=None,
64
  description=None,
65
+ prompt_templates=prompt_templates
66
  )
67
 
68