from langchain.tools import tool @tool def calculate_discount(price: float, discount_percent: float) -> str: """Calculate the final price after a percentage discount.""" if price < 0: return "Price must be greater than or equal to 0." if discount_percent < 0 or discount_percent > 100: return "Discount percent must be between 0 and 100." final_price = price * (1 - discount_percent / 100) return f"Final price: ${final_price:.2f}" print(calculate_discount.name) print(calculate_discount.description) print(calculate_discount.invoke({"price": 120, "discount_percent": 25}))