counting / maths /arithmetic /subtract.py
spagestic's picture
feat: simplify descriptions and examples in Gradio interfaces for arithmetic and calculus tools
db31576
raw
history blame contribute delete
477 Bytes
import numpy as np
from typing import Union
import gradio as gr
def subtract(a: float, b: float) -> float:
"""Subtract b from a."""
try:
return float(a) - float(b)
except (ValueError, TypeError):
raise ValueError("Both inputs must be valid numbers")
subtract_interface = gr.Interface(
fn=subtract,
inputs=[gr.Number(label="A"), gr.Number(label="B")],
outputs="number",
title="Subtraction",
description="Subtract two numbers"
)