File size: 749 Bytes
0cf23b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr


def greet(
    name: str,
    temperature: int,
    is_morning: bool,
) -> tuple[str, float]:
    """Greet the user with a message and the temperature in Celsius."""
    salutation = "Good morning" if is_morning else "Good evening"
    greeting = f"{salutation} {name}. It is {temperature} Fahrenheit today."
    celsius = round((temperature - 32) * 5 / 9, 2)
    return greeting, celsius


demo = gr.Interface(
    fn=greet,
    inputs=[
        gr.Text(label="What is your name?"),
        gr.Slider(0, 100, label="What is the temperature?"),
        gr.Checkbox(label="Is it morning?"),
    ],
    outputs=[gr.Text(label="Greeting"), gr.Number(label="Temperature in Celsius")],
)
if __name__ == "__main__":
    demo.launch()