MoudClam commited on
Commit
2402cfc
·
verified ·
1 Parent(s): 8729876

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -11,16 +11,34 @@ from tools.visit_webpage import VisitWebpageTool
11
 
12
  from Gradio_UI import GradioUI
13
 
14
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
15
  @tool
16
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
17
- #Keep this format for the description / args / args description but feel free to modify the tool
18
- """A tool that does nothing yet
19
  Args:
20
- arg1: the first argument
21
- arg2: the second argument
 
22
  """
23
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
 
11
 
12
  from Gradio_UI import GradioUI
13
 
 
14
  @tool
15
+ def disk_free(path: str = "/") -> str:
16
+ """
17
+ Show total/used/free disk space for a given filesystem path.
18
  Args:
19
+ path: Filesystem path to inspect (e.g., '/', '/home/user').
20
+ Returns:
21
+ A human-friendly string with total/used/free sizes.
22
  """
23
+ try:
24
+ usage = shutil.disk_usage(path) # returns (total, used, free) in bytes
25
+ except Exception as e:
26
+ return f"Error reading disk usage for path='{path}': {e}"
27
+
28
+ def fmt_bytes(n: int) -> str:
29
+ # binary units (KiB, MiB, GiB...)
30
+ units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"]
31
+ x = float(n)
32
+ i = 0
33
+ while x >= 1024.0 and i < len(units) - 1:
34
+ x /= 1024.0
35
+ i += 1
36
+ return f"{x:.2f} {units[i]}"
37
+
38
+ total = fmt_bytes(usage.total)
39
+ used = fmt_bytes(usage.used)
40
+ free = fmt_bytes(usage.free)
41
+ return f"Disk usage for '{path}': total={total}, used={used}, free={free}"
42
 
43
  @tool
44
  def get_current_time_in_timezone(timezone: str) -> str: