Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,7 +102,7 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 102 |
# Return the list of most relevant chunks
|
| 103 |
return top_chunks
|
| 104 |
|
| 105 |
-
def respond(message,
|
| 106 |
response = ""
|
| 107 |
best_recipes_chunk = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 108 |
print(best_recipes_chunk)
|
|
@@ -118,6 +118,7 @@ def respond(message, selected_options, history):
|
|
| 118 |
"You are a helpful recipe assistant. You are only allowed to use the recipes listed below."
|
| 119 |
f"Available Recipes:\n\n{str_recipes_chunk}\n\n(Use ONLY these to answer)"
|
| 120 |
"You must NOT invent or guess any new recipes or ingredients. "
|
|
|
|
| 121 |
"Don't format the recipe as it is in the available recipes. Format your response like this:"
|
| 122 |
"Here is a recipe that matches your needs: [recipe name]. It is [cuisine] cuisine. You can enjoy it for [time of day]. Its main ingredients are [core ingredients]. It fits a [dietary restriction] diet. This dish is [description]. To prepare it: [steps]"
|
| 123 |
"Switch up the format a bit to make sure the responses are varied. Make sure you use proper grammar and don't have random capitals."
|
|
@@ -202,12 +203,17 @@ with gr.Blocks(theme = chat_theme) as demo:
|
|
| 202 |
choices=["Breakfast", "Lunch", "Dinner", "Snack"],
|
| 203 |
label="Time of day"
|
| 204 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
send_btn = gr.Button("Send")
|
| 207 |
history_state = gr.State([])
|
| 208 |
send_btn.click(
|
| 209 |
fn=respond,
|
| 210 |
-
|
| 211 |
outputs=[chatbot]
|
| 212 |
)
|
| 213 |
|
|
|
|
| 102 |
# Return the list of most relevant chunks
|
| 103 |
return top_chunks
|
| 104 |
|
| 105 |
+
def respond(message, history, checkboxes, checkboxes2, checkboxes3):
|
| 106 |
response = ""
|
| 107 |
best_recipes_chunk = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 108 |
print(best_recipes_chunk)
|
|
|
|
| 118 |
"You are a helpful recipe assistant. You are only allowed to use the recipes listed below."
|
| 119 |
f"Available Recipes:\n\n{str_recipes_chunk}\n\n(Use ONLY these to answer)"
|
| 120 |
"You must NOT invent or guess any new recipes or ingredients. "
|
| 121 |
+
f"The user might also provide the following information, please include their input into your response: Type of Cuisine: {checkboxes}, Time of day of the meal: {checkboxes2}, Dietary Restriction {checkboxes3"
|
| 122 |
"Don't format the recipe as it is in the available recipes. Format your response like this:"
|
| 123 |
"Here is a recipe that matches your needs: [recipe name]. It is [cuisine] cuisine. You can enjoy it for [time of day]. Its main ingredients are [core ingredients]. It fits a [dietary restriction] diet. This dish is [description]. To prepare it: [steps]"
|
| 124 |
"Switch up the format a bit to make sure the responses are varied. Make sure you use proper grammar and don't have random capitals."
|
|
|
|
| 203 |
choices=["Breakfast", "Lunch", "Dinner", "Snack"],
|
| 204 |
label="Time of day"
|
| 205 |
)
|
| 206 |
+
with gr.Row():
|
| 207 |
+
# msg = gr.Textbox(placeholder="Ask about an item (e.g., banana peel)", label="Your Question")
|
| 208 |
+
checkboxes3 = gr.CheckboxGroup(
|
| 209 |
+
choices=["Vegetarian", "Vegan", "Dairy Free", "Gluten Free", "Nut Free"],
|
| 210 |
+
label="Dietary Restriction"
|
| 211 |
|
| 212 |
send_btn = gr.Button("Send")
|
| 213 |
history_state = gr.State([])
|
| 214 |
send_btn.click(
|
| 215 |
fn=respond,
|
| 216 |
+
additional_inputs=[checkboxes, checkboxes2, checkboxes3],
|
| 217 |
outputs=[chatbot]
|
| 218 |
)
|
| 219 |
|