Download tools_smolagent_maths.py from JPM34/final_assignment_agentic_course: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/JPM34/final_assignment_agentic_course/resolve/main/tools_smolagent_maths.py
- Command line
-
hf download hf://spaces/JPM34/final_assignment_agentic_course/tools_smolagent_maths.py
-
curl -L -o tools_smolagent_maths.py https://huggingface.co/spaces/JPM34/final_assignment_agentic_course/resolve/main/tools_smolagent_maths.py
1.33 kB
| import cmath | |
| from smolagents import tool | |
| def multiply(a: int, b: int) -> int: | |
| """Multiply two numbers. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a * b | |
| def add(a: int, b: int) -> int: | |
| """Add two numbers. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a + b | |
| def subtract(a: int, b: int) -> int: | |
| """Subtract two numbers. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a - b | |
| def divide(a: int, b: int) -> int: | |
| """Divide two numbers. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| if b == 0: | |
| raise ValueError("Cannot divide by zero.") | |
| return a / b | |
| def modulus(a: int, b: int) -> int: | |
| """Get the modulus of two numbers. | |
| Args: | |
| a: first int | |
| b: second int | |
| """ | |
| return a % b | |
| def power(a: float, b: float) -> float: | |
| """ | |
| Get the power of two numbers. | |
| Args: | |
| a (float): the first number | |
| b (float): the second number | |
| """ | |
| return a**b | |
| # @tool | |
| # def square_root(a: float) -> float | complex: | |
| # """ | |
| # Get the square root of a number. | |
| # Args: | |
| # a (float): the number to get the square root of | |
| # """ | |
| # print(a) | |
| # if a >= 0: | |
| # return a**0.5 | |
| # return cmath.sqrt(a) | |