aneesarom commited on
Commit
a6e7cd7
·
verified ·
1 Parent(s): 5cf5b56

Upload tool

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. tool.py +14 -11
app.py CHANGED
@@ -1,5 +1,5 @@
1
  from smolagents import launch_gradio_demo
2
- from tool import SimpleTool
3
 
4
- tool = SimpleTool()
5
  launch_gradio_demo(tool)
 
1
  from smolagents import launch_gradio_demo
2
+ from tool import DateTimeTool
3
 
4
+ tool = DateTimeTool()
5
  launch_gradio_demo(tool)
tool.py CHANGED
@@ -1,22 +1,25 @@
1
- from smolagents import Tool
2
  from typing import Any, Optional
 
 
3
 
4
- class SimpleTool(Tool):
 
 
 
5
  name = "get_today_datetime"
6
- description = "Get the current local date and time."
7
  inputs = {}
8
- output_type = "null"
9
 
10
  def forward(self):
11
  """
12
- Get the current local date and time.
13
 
14
  Returns:
15
- str: Current date and time in the format 'YYYY-MM-DD HH:MM:SS'.
16
-
17
- Example:
18
- >>> forward()
19
- '2025-08-29 15:42:18'
20
  """
21
  from datetime import datetime
22
- return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
 
 
 
 
 
1
  from typing import Any, Optional
2
+ from smolagents.tools import Tool
3
+ import datetime
4
 
5
+ class DateTimeTool(Tool):
6
+ """
7
+ A simple tool to get the current local date and time.
8
+ """
9
  name = "get_today_datetime"
10
+ description = "Get the current local date and time in the format 'YYYY-MM-DD HH:MM:SS'."
11
  inputs = {}
12
+ output_type = "string"
13
 
14
  def forward(self):
15
  """
16
+ Executes the tool.
17
 
18
  Returns:
19
+ str: Current date and time.
 
 
 
 
20
  """
21
  from datetime import datetime
22
+ return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
23
+
24
+ def __init__(self, *args, **kwargs):
25
+ self.is_initialized = False