gathemin commited on
Commit
0cf23b0
·
verified ·
1 Parent(s): dfb8670

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ def greet(
5
+ name: str,
6
+ temperature: int,
7
+ is_morning: bool,
8
+ ) -> tuple[str, float]:
9
+ """Greet the user with a message and the temperature in Celsius."""
10
+ salutation = "Good morning" if is_morning else "Good evening"
11
+ greeting = f"{salutation} {name}. It is {temperature} Fahrenheit today."
12
+ celsius = round((temperature - 32) * 5 / 9, 2)
13
+ return greeting, celsius
14
+
15
+
16
+ demo = gr.Interface(
17
+ fn=greet,
18
+ inputs=[
19
+ gr.Text(label="What is your name?"),
20
+ gr.Slider(0, 100, label="What is the temperature?"),
21
+ gr.Checkbox(label="Is it morning?"),
22
+ ],
23
+ outputs=[gr.Text(label="Greeting"), gr.Number(label="Temperature in Celsius")],
24
+ )
25
+ if __name__ == "__main__":
26
+ demo.launch()