Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 17 |
-
|
| 18 |
-
|
| 19 |
Args:
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
"""
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|