Spaces:
Sleeping
Sleeping
File size: 772 Bytes
954a8ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from smolagents import Tool
from typing import Any, Optional
class SimpleTool(Tool):
name = "calculate_hydration"
description = "Calculates daily water intake based on body weight."
inputs = {"weight_kg":{"type":"number","description":"Body weight in kilograms"}}
output_type = "string"
def forward(self, weight_kg: float) -> str:
"""
Calculates daily water intake based on body weight.
Args:
weight_kg: Body weight in kilograms
"""
if weight_kg <= 0:
return "Please provide a valid weight"
water_ml = weight_kg * 33
water_oz = water_ml / 29.5735
return f"Daily water intake:\n{water_ml:.0f} ml\n{water_oz:.1f} oz\nApprox {water_ml/250:.1f} glasses (250ml each)" |