Spaces:
Sleeping
Sleeping
preferred ingredient
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ def get_top_chunks(query):
|
|
16 |
top_indices = torch.topk(similarities, k=5).indices.tolist()
|
17 |
return [cleaned_chunks[i] for i in top_indices]
|
18 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
19 |
-
def respond(message, history, cuisine, dietary_restrictions, allergies):
|
20 |
response = ""
|
21 |
top_chunks = get_top_chunks(message)
|
22 |
context = "\n".join(top_chunks)
|
@@ -24,7 +24,7 @@ def respond(message, history, cuisine, dietary_restrictions, allergies):
|
|
24 |
messages = [
|
25 |
{
|
26 |
"role": "system",
|
27 |
-
"content": f"You are a friendly recipe chatbot named BiteBot that responds to the user with any recipe from this: {context}. Find a recipe that is {cuisine} cuisine. They have the dietary restrictions,{dietary_restrictions} and are allergic to {allergies}. For example, you can say Based on your preference for something sweet and given the recipes you provided, let me suggest a recipe that might be of interest to you. Do you want to try Elizabeth's Sweet Potato Casserole? Return the title to the user and ask if this is the recipe they want. If they say yes return the ingredients to the user and ask them if they want the instructions to this recipe (give them the instructions next if they say yes to this). If they say no ask if they want another recipe. Only pull recipes from the file provided."
|
28 |
}
|
29 |
]
|
30 |
if history:
|
@@ -63,10 +63,11 @@ with gr.Blocks(theme=theme) as chatbot:
|
|
63 |
show_label=False,
|
64 |
show_share_button = False,
|
65 |
show_download_button = False)
|
66 |
-
gr.Markdown("### 👋 Welcome to
|
67 |
cuisine=gr.Textbox(label="cuisine")
|
68 |
dietary_restrictions=gr.Dropdown(["Gluten-Free","Dairy-Free","Vegan","Vegetarian","Keto","Kosher","No Soy","No Seafood","No Pork","No Beef"], label="dietary restrictions", multiselect=True,info="you can select multiple!")
|
69 |
allergies=gr.Textbox(label="allergies")
|
|
|
70 |
gr.ChatInterface(
|
71 |
fn=respond,
|
72 |
type="messages", additional_inputs=[cuisine,dietary_restrictions,allergies]
|
|
|
16 |
top_indices = torch.topk(similarities, k=5).indices.tolist()
|
17 |
return [cleaned_chunks[i] for i in top_indices]
|
18 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
19 |
+
def respond(message, history, cuisine, dietary_restrictions, allergies, preferred_ingredient):
|
20 |
response = ""
|
21 |
top_chunks = get_top_chunks(message)
|
22 |
context = "\n".join(top_chunks)
|
|
|
24 |
messages = [
|
25 |
{
|
26 |
"role": "system",
|
27 |
+
"content": f"You are a friendly recipe chatbot named BiteBot that responds to the user with any recipe from this: {context}. Find a recipe that is {cuisine} cuisine. They have the dietary restrictions,{dietary_restrictions} and are allergic to {allergies}. Also, make sure the recipe includes the preferred ingredient {preferred_ingredient}.For example, you can say Based on your preference for something sweet and given the recipes you provided, let me suggest a recipe that might be of interest to you. Do you want to try Elizabeth's Sweet Potato Casserole? Return the title to the user and ask if this is the recipe they want. If they say yes return the ingredients to the user and ask them if they want the instructions to this recipe (give them the instructions next if they say yes to this). If they say no ask if they want another recipe. Only pull recipes from the file provided."
|
28 |
}
|
29 |
]
|
30 |
if history:
|
|
|
63 |
show_label=False,
|
64 |
show_share_button = False,
|
65 |
show_download_button = False)
|
66 |
+
gr.Markdown("### 👋 Welcome to BiteBot!\nTell me your preferred **cuisine**, any **dietary restrictions**, and **allergies**, and I’ll help you figure out what to cook. You can ask questions like:\n- _“What should I make tonight?”_\n- _“Give me something vegan and Indian.”_\n- _“I’m allergic to nuts—what can I eat?”_")
|
67 |
cuisine=gr.Textbox(label="cuisine")
|
68 |
dietary_restrictions=gr.Dropdown(["Gluten-Free","Dairy-Free","Vegan","Vegetarian","Keto","Kosher","No Soy","No Seafood","No Pork","No Beef"], label="dietary restrictions", multiselect=True,info="you can select multiple!")
|
69 |
allergies=gr.Textbox(label="allergies")
|
70 |
+
preferred_ingredient=gr.Textbox(label="preferred ingredient")
|
71 |
gr.ChatInterface(
|
72 |
fn=respond,
|
73 |
type="messages", additional_inputs=[cuisine,dietary_restrictions,allergies]
|