Chong-U Lim commited on
Commit
a0ecfdf
1 Parent(s): 440cea1

Gradio app

Browse files
Files changed (2) hide show
  1. .gitignore +3 -1
  2. main.py +41 -0
.gitignore CHANGED
@@ -1,3 +1,5 @@
1
  __pycache__
2
  .ipynb_checkpoints
3
- keys.py
 
 
 
1
  __pycache__
2
  .ipynb_checkpoints
3
+ keys.py
4
+
5
+ flagged/**
main.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ def generate_restaurant_name_and_items(cuisine: str) -> dict[str, str]:
5
+ return {
6
+ "restaurant_name": "Curry Delight",
7
+ "menu_items": "Butter Chicken, Naan, Paneer Tikka, Chole Bhature, Lassi, Gulab Jamun",
8
+ }
9
+
10
+
11
+ def update_outputs(cuisine: str) -> tuple[str, str]:
12
+ response = generate_restaurant_name_and_items(cuisine)
13
+ restaurant_name = response["restaurant_name"]
14
+ menu_items = response["menu_items"].split(",")
15
+
16
+ menu_items_formatted = ""
17
+ for item in menu_items:
18
+ menu_items_formatted += f"- {item.strip()}\n"
19
+
20
+ return f"## {restaurant_name}", menu_items_formatted
21
+
22
+
23
+ with gr.Blocks() as app:
24
+ gr.Markdown("# Restaurant Name Generator")
25
+ inp_cuisine = gr.Dropdown(
26
+ ["Indian", "Italian", "Mexican", "Arabic"],
27
+ label="Pick a cuisine",
28
+ )
29
+
30
+ out_restaurant_name = gr.Markdown()
31
+ out_menu_items = gr.Markdown()
32
+
33
+ inp_cuisine.change(
34
+ fn=update_outputs,
35
+ inputs=inp_cuisine,
36
+ outputs=[out_restaurant_name, out_menu_items],
37
+ )
38
+
39
+
40
+ if __name__ == "__main__":
41
+ app.launch()