File size: 731 Bytes
d136fb1
81c8a55
d136fb1
81c8a55
1f14419
 
 
 
 
 
 
 
81c8a55
 
d136fb1
81c8a55
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
from modal_app import app, square

def compute_square(x):
    """Compute the square of a number.

    Args:
        x (float | int): The number to square.

    Returns:
        float: The square of the input number.
    """
    with app.run():
        return square.remote(float(x))

# Create a standard Gradio interface
demo = gr.Interface(
    fn=compute_square,
    inputs=gr.Number(label="Enter a number"),
    outputs=gr.Number(label="Square of the number"),
    title="Compute Square using Modal",
    description="Enter a number to compute its square using a remote Modal function."
)

# Launch both the Gradio web interface and the MCP server
if __name__ == "__main__":
    demo.launch(mcp_server=True)