from HeGFlow.graph.tool_node import Tool_node
from typing import Union
from typing import Any

class Calculator(Tool_node):
    def __init__(self):
        super().__init__(
            name="Calculator",
            
        )

    async def _execute_tool(self, operation: str, num1: Union[int, float], num2: Union[int, float]) -> Union[int, float]:
        
        if operation == "add":
            return num1 + num2
        elif operation == "subtract":
            return num1 - num2
        elif operation == "multiply":
            return num1 * num2
        elif operation == "divide":
            if num2 == 0:
                raise ValueError("Division by zero is not allowed.")
            return num1 / num2
        else:
            raise ValueError(f"Unsupported operation: {operation}")

    