Chong-U Lim
commited on
Commit
•
48687d1
1
Parent(s):
390058b
Fix formatting
Browse files- app.py +20 -16
- langchain_helper.py +5 -2
app.py
CHANGED
@@ -4,31 +4,35 @@ from langchain_helper import generate_restaurant_name_and_items
|
|
4 |
|
5 |
def update_outputs(cuisine: str) -> tuple[str, str]:
|
6 |
response = generate_restaurant_name_and_items(cuisine)
|
7 |
-
restaurant_name = response["restaurant_name"]
|
8 |
menu_items = response["menu_items"].split(",")
|
9 |
|
10 |
menu_items_formatted = ""
|
11 |
for item in menu_items:
|
12 |
menu_items_formatted += f"- {item.strip()}\n"
|
13 |
|
14 |
-
return f"
|
15 |
|
16 |
|
17 |
with gr.Blocks() as gradio_app:
|
18 |
-
gr.Markdown("
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
|
34 |
if __name__ == "__main__":
|
|
|
4 |
|
5 |
def update_outputs(cuisine: str) -> tuple[str, str]:
|
6 |
response = generate_restaurant_name_and_items(cuisine)
|
7 |
+
restaurant_name = response["restaurant_name"].strip()
|
8 |
menu_items = response["menu_items"].split(",")
|
9 |
|
10 |
menu_items_formatted = ""
|
11 |
for item in menu_items:
|
12 |
menu_items_formatted += f"- {item.strip()}\n"
|
13 |
|
14 |
+
return f"# {restaurant_name}", menu_items_formatted
|
15 |
|
16 |
|
17 |
with gr.Blocks() as gradio_app:
|
18 |
+
gr.Markdown("## Restaurant Name Generator")
|
19 |
+
|
20 |
+
with gr.Row():
|
21 |
+
with gr.Column() as left:
|
22 |
+
inp_cuisine = gr.Dropdown(
|
23 |
+
["Indian", "Italian", "Mexican", "Arabic"],
|
24 |
+
label="Pick a cuisine",
|
25 |
+
)
|
26 |
+
|
27 |
+
with gr.Column(variant="panel") as right:
|
28 |
+
out_restaurant_name = gr.Markdown()
|
29 |
+
out_menu_items = gr.Markdown()
|
30 |
+
|
31 |
+
inp_cuisine.change(
|
32 |
+
fn=update_outputs,
|
33 |
+
inputs=inp_cuisine,
|
34 |
+
outputs=[out_restaurant_name, out_menu_items],
|
35 |
+
)
|
36 |
|
37 |
|
38 |
if __name__ == "__main__":
|
langchain_helper.py
CHANGED
@@ -22,7 +22,7 @@ name_chain = LLMChain(
|
|
22 |
|
23 |
prompt_template_items = PromptTemplate(
|
24 |
input_variables=["restaurant_name"],
|
25 |
-
template="Suggest some menu items for {restaurant_name}. Return the menu items as a comma separated string with no additional preamble.",
|
26 |
)
|
27 |
|
28 |
food_items_chain = LLMChain(
|
@@ -39,7 +39,10 @@ chain = SequentialChain(
|
|
39 |
|
40 |
|
41 |
def generate_restaurant_name_and_items(cuisine: str) -> dict[str, str]:
|
42 |
-
|
|
|
|
|
|
|
43 |
# return {
|
44 |
# "restaurant_name": "Curry Delight",
|
45 |
# "menu_items": "Butter Chicken, Naan, Paneer Tikka, Chole Bhature, Lassi, Gulab Jamun",
|
|
|
22 |
|
23 |
prompt_template_items = PromptTemplate(
|
24 |
input_variables=["restaurant_name"],
|
25 |
+
template="Suggest some menu items for {restaurant_name}. Return the menu items as a single, comma separated string with no additional preamble.",
|
26 |
)
|
27 |
|
28 |
food_items_chain = LLMChain(
|
|
|
39 |
|
40 |
|
41 |
def generate_restaurant_name_and_items(cuisine: str) -> dict[str, str]:
|
42 |
+
result = chain({"cuisine": cuisine})
|
43 |
+
print(result)
|
44 |
+
return result
|
45 |
+
|
46 |
# return {
|
47 |
# "restaurant_name": "Curry Delight",
|
48 |
# "menu_items": "Butter Chicken, Naan, Paneer Tikka, Chole Bhature, Lassi, Gulab Jamun",
|