import numpy as np from typing import Union import gradio as gr def add(a: float, b: float) -> float: """Add two numbers.""" try: return float(a) + float(b) except (ValueError, TypeError): raise ValueError("Both inputs must be valid numbers") add_interface = gr.Interface( fn=add, inputs=[gr.Number(label="A"), gr.Number(label="B")], outputs="number", title="Addition", description="Add two numbers.\n\n**Description:**\nThis tool takes two numbers as input and returns their sum.\n\n**Examples:**\n- Input: 2, 3 → Output: 5\n- Input: -1.5, 4.2 → Output: 2.7\n- Input: 0, 0 → Output: 0", examples=[[2, 3], [-1.5, 4.2], [0, 0]], )