Spaces:
Starting
Starting
from langchain_core.tools import tool | |
from sympy import sympify | |
import logging | |
logger = logging.getLogger(__name__) | |
async def calculator_tool(expression: str) -> str: | |
"""Evaluate a mathematical expression""" | |
try: | |
result = sympify(expression) | |
return str(result) | |
except Exception as e: | |
logger.error(f"Error evaluating expression '{expression}': {e}") | |
return f"Error: {str(e)}" |