Spaces:
Sleeping
Sleeping
Update tool.py
Browse files
tool.py
CHANGED
|
@@ -41,11 +41,11 @@ class SimpleTool(Tool):
|
|
| 41 |
}
|
| 42 |
|
| 43 |
# Convert `value` to float if it's a string
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
# Check if the units are valid
|
| 51 |
if from_unit not in conversion_rates or to_unit not in conversion_rates[from_unit]:
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
# Convert `value` to float if it's a string
|
| 44 |
+
if isinstance(value, str):
|
| 45 |
+
try:
|
| 46 |
+
value = float(value)
|
| 47 |
+
except ValueError:
|
| 48 |
+
raise ValueError("Value must be a number")
|
| 49 |
|
| 50 |
# Check if the units are valid
|
| 51 |
if from_unit not in conversion_rates or to_unit not in conversion_rates[from_unit]:
|