-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (35 loc) · 1.24 KB
/
main.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Restaurant Name Generator app.
The user selects a cusine and gets a list of restaurant names that serve that cusine.
Also could generate a random menu items for that restaurant.
"""
import streamlit as st
from langchain_helper import generate_restaurant_name_and_items
st.title("Restaurant Name Generator")
st.sidebar.header("Cusine:")
cuisine = st.sidebar.selectbox("Pick up a cusine", ("Mexican", "American", "Chinese"))
restaurant_name = st.text_input("Enter a restaurant name")
if cuisine:
response = generate_restaurant_name_and_items(cuisine)
# Display restaurant name
if restaurant_name:
st.header(restaurant_name)
else:
st.header(response["restaurant_name"])
# Display menu items
menu_items = []
try:
print(response["food_items"])
menu_items_raw = response["food_items"]
menu_items_list = menu_items_raw.split(",")
menu_items = menu_items_list
# Truncate menu items to 3
if len(menu_items) > 3:
menu_items = menu_items[0:3]
except KeyError:
print("KeyError when trying to get menu items")
if len(menu_items) != 0:
# Display menu
st.write("Menu:")
for item in menu_items:
st.write("-", item)