Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,22 +10,19 @@ recipe_id_map = {}
|
|
| 10 |
|
| 11 |
client=InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
|
| 12 |
|
| 13 |
-
data = ""
|
| 14 |
# # Search recipes
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
print(data)
|
| 28 |
-
return data
|
| 29 |
|
| 30 |
|
| 31 |
# if "results" not in data or not data["results"]:
|
|
@@ -90,7 +87,7 @@ def search_recipes(ingredient, cuisine, dietary):
|
|
| 90 |
# else:
|
| 91 |
# return "You can ask about calories, protein, carbs, fat, substitutes, or scaling tips."
|
| 92 |
|
| 93 |
-
def respond(message, history):
|
| 94 |
|
| 95 |
context = search_recipes(ingredient, cuisine, diet)
|
| 96 |
messages = [
|
|
@@ -143,7 +140,7 @@ with gr.Blocks() as demo:
|
|
| 143 |
# )
|
| 144 |
|
| 145 |
# with gr.Tab("Ask BiteBot"):
|
| 146 |
-
chatbot = gr.ChatInterface(fn=respond,
|
| 147 |
gr.Markdown("💬 Ask about calories, macros, scaling, or substitutions. (Run a recipe search first!)")
|
| 148 |
|
| 149 |
demo.launch()
|
|
|
|
| 10 |
|
| 11 |
client=InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
|
| 12 |
|
|
|
|
| 13 |
# # Search recipes
|
| 14 |
+
|
| 15 |
+
global recipe_id_map
|
| 16 |
+
url = "https://api.spoonacular.com/recipes/complexSearch"
|
| 17 |
+
params = {
|
| 18 |
+
# "query": ingredient,
|
| 19 |
+
# "cuisine": cuisine,
|
| 20 |
+
# "diet": dietary,
|
| 21 |
+
"number": 3,
|
| 22 |
+
"apiKey": SPOONACULAR_API_KEY
|
| 23 |
+
}
|
| 24 |
+
res = requests.get(url, params=params)
|
| 25 |
+
data = res.json()
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
# if "results" not in data or not data["results"]:
|
|
|
|
| 87 |
# else:
|
| 88 |
# return "You can ask about calories, protein, carbs, fat, substitutes, or scaling tips."
|
| 89 |
|
| 90 |
+
def respond(message, history, ingredient, cuisine, diet):
|
| 91 |
|
| 92 |
context = search_recipes(ingredient, cuisine, diet)
|
| 93 |
messages = [
|
|
|
|
| 140 |
# )
|
| 141 |
|
| 142 |
# with gr.Tab("Ask BiteBot"):
|
| 143 |
+
chatbot = gr.ChatInterface(fn=respond, additional_inputs = [ingredient, cuisine, diet], type="messages")
|
| 144 |
gr.Markdown("💬 Ask about calories, macros, scaling, or substitutions. (Run a recipe search first!)")
|
| 145 |
|
| 146 |
demo.launch()
|