File size: 690 Bytes
9b3b8c8
 
291349f
9b3b8c8
 
 
 
 
 
 
291349f
 
 
 
 
 
c6a39bf
 
291349f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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]],
)