File size: 1,168 Bytes
a0ecfdf
1ac2cc0
a0ecfdf
 
 
 
48687d1
a0ecfdf
 
 
 
 
 
48687d1
a0ecfdf
 
1ac2cc0
48687d1
 
 
e2a35fb
48687d1
d606846
48687d1
 
 
e2a35fb
48687d1
 
 
 
 
 
 
 
a0ecfdf
 
 
1ac2cc0
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
import gradio as gr
from langchain_helper import generate_restaurant_name_and_items


def update_outputs(cuisine: str) -> tuple[str, str]:
    response = generate_restaurant_name_and_items(cuisine)
    restaurant_name = response["restaurant_name"].strip()
    menu_items = response["menu_items"].split(",")

    menu_items_formatted = ""
    for item in menu_items:
        menu_items_formatted += f"- {item.strip()}\n"

    return f"# {restaurant_name}", menu_items_formatted


with gr.Blocks() as gradio_app:
    gr.Markdown("## Restaurant Name Generator")

    with gr.Row():
        with gr.Column(scale=1) as left:
            inp_cuisine = gr.Dropdown(
                ["Arabic", "French", "Indian", "Italian", "Mexican"],
                label="Pick a cuisine",
            )

        with gr.Column(variant="panel", scale=4) as right:
            out_restaurant_name = gr.Markdown()
            out_menu_items = gr.Markdown()

            inp_cuisine.change(
                fn=update_outputs,
                inputs=inp_cuisine,
                outputs=[out_restaurant_name, out_menu_items],
            )


if __name__ == "__main__":
    gradio_app.launch()