Spaces:
Sleeping
Sleeping
Evan Lesmez
commited on
Commit
·
1230938
1
Parent(s):
191b7f5
Improve consistency of recipe query prompt
Browse filesReduce temperature to 0.1 seems to yield ingredients that are more
compatible with each other.
Add few-shot examples in prompt of what format of query output to generate.
Add the vegan recipe search tool to test with directly in notebook to
save dev time.
Add some more evaluations of conversation.
- _proc/00_engineer_prompt.ipynb +141 -61
- _proc/01_app.ipynb +132 -16
- _proc/02_vegan_recipe_tools.ipynb +87 -102
- _proc/_docs/app.html +150 -28
- _proc/_docs/engineer_prompt.html +116 -116
- _proc/_docs/index.html +2 -8
- _proc/_docs/ingredient_vision.html +9 -15
- _proc/_docs/search.json +0 -0
- _proc/_docs/sitemap.xml +8 -4
- _proc/_docs/vegan_recipe_tools.html +0 -0
- _proc/sidebar.yml +1 -2
- lv_recipe_chatbot/engineer_prompt.py +13 -13
- nbs/00_engineer_prompt.ipynb +143 -73
_proc/00_engineer_prompt.ipynb
CHANGED
@@ -20,6 +20,17 @@
|
|
20 |
"<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->"
|
21 |
]
|
22 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
{
|
24 |
"cell_type": "markdown",
|
25 |
"metadata": {},
|
@@ -79,69 +90,13 @@
|
|
79 |
"name": "stdout",
|
80 |
"output_type": "stream",
|
81 |
"text": [
|
82 |
-
"\n"
|
83 |
-
"\n",
|
84 |
-
"> Entering new ConversationChain chain...\n",
|
85 |
-
"Prompt after formatting:\n",
|
86 |
-
"System: The following is a conversation between a human and a friendly AI chef. \n",
|
87 |
-
"The AI is compassionate to animals.\n",
|
88 |
-
"The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs.\n",
|
89 |
-
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
90 |
-
"\n",
|
91 |
-
"Let's think step by step.\n",
|
92 |
-
"If the human messages are unrelated to vegan recipes, remind them of your purpose to recipes.\n",
|
93 |
-
"Only generate keyword queries as other tools should be used to fetch full recipes.\n",
|
94 |
-
"AI: What ingredients do you wish to cook with?\n",
|
95 |
-
"Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\n",
|
96 |
-
"AI: Do you have any allergies I should be aware of?\n",
|
97 |
-
"Human: Allergies: \n",
|
98 |
-
"AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\n",
|
99 |
-
"Human: Generate a vegan recipe keyword query that is aligned with the user's allergies and contains at least a few of the ingredients provided (if any).\n",
|
100 |
-
"Draw some inspiration from the user's preferences delimited below if any are specified.\n",
|
101 |
-
"\n",
|
102 |
-
"###\n",
|
103 |
-
"Preferences: The preparation time should be less than 30 minutes. I really love Thai food!\n",
|
104 |
-
"###\n",
|
105 |
-
"AI: Based on your preferences, allergies, and ingredients, a concise vegan recipe keyword query could be: \"vegan Thai tofu sandwich with pickles, olives, tomatoes, lettuce, bell peppers, and carrots\". This should help you find a suitable recipe using recipe APIs or other recipe platforms.\n",
|
106 |
-
"Human: Recommend a different recipe please.\n",
|
107 |
-
"\n",
|
108 |
-
"> Finished chain.\n",
|
109 |
-
"\n",
|
110 |
-
"\n",
|
111 |
-
"> Entering new ConversationChain chain...\n",
|
112 |
-
"Prompt after formatting:\n",
|
113 |
-
"System: The following is a conversation between a human and a friendly AI chef. \n",
|
114 |
-
"The AI is compassionate to animals.\n",
|
115 |
-
"The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs.\n",
|
116 |
-
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
117 |
-
"\n",
|
118 |
-
"Let's think step by step.\n",
|
119 |
-
"If the human messages are unrelated to vegan recipes, remind them of your purpose to recipes.\n",
|
120 |
-
"Only generate keyword queries as other tools should be used to fetch full recipes.\n",
|
121 |
-
"AI: What ingredients do you wish to cook with?\n",
|
122 |
-
"Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\n",
|
123 |
-
"AI: Do you have any allergies I should be aware of?\n",
|
124 |
-
"Human: Allergies: \n",
|
125 |
-
"AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\n",
|
126 |
-
"Human: Generate a vegan recipe keyword query that is aligned with the user's allergies and contains at least a few of the ingredients provided (if any).\n",
|
127 |
-
"Draw some inspiration from the user's preferences delimited below if any are specified.\n",
|
128 |
-
"\n",
|
129 |
-
"###\n",
|
130 |
-
"Preferences: The preparation time should be less than 30 minutes. I really love Thai food!\n",
|
131 |
-
"###\n",
|
132 |
-
"AI: Based on your preferences, allergies, and ingredients, a concise vegan recipe keyword query could be: \"vegan Thai tofu sandwich with pickles, olives, tomatoes, lettuce, bell peppers, and carrots\". This should help you find a suitable recipe using recipe APIs or other recipe platforms.\n",
|
133 |
-
"Human: Recommend a different recipe please.\n",
|
134 |
-
"AI: Certainly! How about a vegan Thai peanut tofu stir-fry? It's a delicious and easy-to-make dish that incorporates some of the ingredients you mentioned. Here's a concise vegan recipe keyword query for it: \"vegan Thai peanut tofu stir-fry with tofu, bell peppers, carrots, and peanuts\". This should give you some great recipe options to explore!\n",
|
135 |
-
"Human: Aactually how about italian instead?\n",
|
136 |
-
"\n",
|
137 |
-
"> Finished chain.\n",
|
138 |
-
"Of course! If you prefer an Italian-inspired vegan recipe, how about a vegan Caprese salad with marinated tofu? It's a refreshing and flavorful dish that combines tomatoes, tofu, and basil. Here's a concise vegan recipe keyword query for it: \"vegan Caprese salad with marinated tofu, tomatoes, and basil\". This should help you find some delicious Italian vegan recipes to try out!\n"
|
139 |
]
|
140 |
}
|
141 |
],
|
142 |
"source": [
|
143 |
"#| eval: false\n",
|
144 |
-
"chat = PromptLayerChatOpenAI(temperature=1, pl_tags=[\"langchain\"], return_pl_id=True)\n",
|
145 |
"memory = ConversationBufferMemory(return_messages=True)\n",
|
146 |
"chat_msgs = INIT_PROMPT.format_prompt(\n",
|
147 |
" ingredients=\"tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\",\n",
|
@@ -162,11 +117,136 @@
|
|
162 |
"conversation = ConversationChain(\n",
|
163 |
" llm=chat, verbose=True, memory=memory, prompt=open_prompt\n",
|
164 |
")\n",
|
165 |
-
"
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
"print(result)"
|
169 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
],
|
172 |
"metadata": {
|
|
|
20 |
"<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->"
|
21 |
]
|
22 |
},
|
23 |
+
{
|
24 |
+
"cell_type": "code",
|
25 |
+
"execution_count": null,
|
26 |
+
"metadata": {
|
27 |
+
"language": "python"
|
28 |
+
},
|
29 |
+
"outputs": [],
|
30 |
+
"source": [
|
31 |
+
"from lv_recipe_chatbot.vegan_recipe_tools import vegan_recipe_edamam_search"
|
32 |
+
]
|
33 |
+
},
|
34 |
{
|
35 |
"cell_type": "markdown",
|
36 |
"metadata": {},
|
|
|
90 |
"name": "stdout",
|
91 |
"output_type": "stream",
|
92 |
"text": [
|
93 |
+
"content='Vegan Thai tofu, bell peppers, carrots' additional_kwargs={} example=False\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
]
|
95 |
}
|
96 |
],
|
97 |
"source": [
|
98 |
"#| eval: false\n",
|
99 |
+
"chat = PromptLayerChatOpenAI(temperature=0.1, pl_tags=[\"langchain\"], return_pl_id=True)\n",
|
100 |
"memory = ConversationBufferMemory(return_messages=True)\n",
|
101 |
"chat_msgs = INIT_PROMPT.format_prompt(\n",
|
102 |
" ingredients=\"tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\",\n",
|
|
|
117 |
"conversation = ConversationChain(\n",
|
118 |
" llm=chat, verbose=True, memory=memory, prompt=open_prompt\n",
|
119 |
")\n",
|
120 |
+
"print(results.generations[0][0].message)"
|
121 |
+
]
|
122 |
+
},
|
123 |
+
{
|
124 |
+
"cell_type": "code",
|
125 |
+
"execution_count": null,
|
126 |
+
"metadata": {
|
127 |
+
"language": "python"
|
128 |
+
},
|
129 |
+
"outputs": [
|
130 |
+
{
|
131 |
+
"data": {
|
132 |
+
"text/plain": [
|
133 |
+
"'Vegan Thai tofu, bell peppers, carrots'"
|
134 |
+
]
|
135 |
+
},
|
136 |
+
"execution_count": null,
|
137 |
+
"metadata": {},
|
138 |
+
"output_type": "execute_result"
|
139 |
+
}
|
140 |
+
],
|
141 |
+
"source": [
|
142 |
+
"#| eval: false\n",
|
143 |
+
"results.generations[0][0].message.content"
|
144 |
+
]
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"cell_type": "markdown",
|
148 |
+
"metadata": {},
|
149 |
+
"source": [
|
150 |
+
"### Test with vegan recipe search tool"
|
151 |
+
]
|
152 |
+
},
|
153 |
+
{
|
154 |
+
"cell_type": "code",
|
155 |
+
"execution_count": null,
|
156 |
+
"metadata": {
|
157 |
+
"language": "python"
|
158 |
+
},
|
159 |
+
"outputs": [
|
160 |
+
{
|
161 |
+
"data": {
|
162 |
+
"text/plain": [
|
163 |
+
"\"[{'label': 'Vegan Panang Curry with Tofu', 'url': 'https://pipingpotcurry.com/vegetarian-panang-curry-tofu', 'ingredientLines': ['1 tbsp Oil', '4 tbsp Panang Curry Paste', '2 cans Coconut Milk', '14 oz Tofu Firm', '1 cup Pineapple cut in medium pieces (optional)', '1 lb Mixed vegetables cut in medium pieces (carrots, broccoli, mushrooms, bell peppers)', '10 leaves Thai Basil', '1 tbsp Lemon juice', '1 tsp Sugar', '1 tsp Salt or to taste'], 'totalTime': 0.0}, {'label': 'Vegan Rainbow Thai Peanut Noodle Bake', 'url': 'https://tastykitchen.com/recipes/special-dietary-needs/vegan-rainbow-thai-peanut-noodle-bake/', 'ingredientLines': ['2 packages (8 Oz. Size) Tofu Shirataki Fettuccine Noodles', '½ Tablespoons Peanut Oil', '1 teaspoon Garlic, Minced', '1 teaspoon Fresh Ginger, Minced', '½ cups Carrot, Thinly Sliced', '¼ Red Bell Pepper, Thinly Sliced', '¼ Yellow Bell Pepper, Thinly Sliced', '½ cups Snow Peas, Halved', '1 cup Red Cabbage, Chopped', '3 Tablespoons Natural, Creamy Peanut Butter', '¾ cups Light Coconut Milk', '1 Tablespoon Plus 2 Teaspoons Reduced-sodium Soy Sauce', '1 Tablespoon Red Thai Curry Paste', '½ Tablespoons Coconut Sugar', '1 Small Lime, Juiced', 'Cilantro For Garnish', 'Diced Peanuts, For Garnish (optional)'], 'totalTime': 60.0}, {'label': 'Vegan Pad Thai recipes', 'url': 'http://www.godairyfree.org/recipes/vegan-pad-thai', 'ingredientLines': ['2 garlic cloves, peeled', '1 teaspoon grated fresh ginger', '¼ cup water', '3 tablespoons low-sodium tamari (wheat-free / gluten-free, if needed)', '2 tablespoons maple syrup', '1 tablespoon rice vinegar', '1 tablespoon tahini', '1 tablespoon lime juice', '1 teaspoon tamarind paste', '1 teaspoon sriracha', '2 teaspoons non-GMO cornstarch', '6 ounces extra-firm tofu', '6 to 8 ounces brown rice noodles', '1 medium carrot, peeled and julienned', '1 red bell pepper, seeded and sliced', '½ red onion, sliced', '3 cups chopped broccoli florets', '1 cup shredded cabbage', '2 cups chopped spinach', '1 cup fresh mung bean sprouts', '4 to 6 green onions, chopped', '3 to 5 garlic cloves, minced', '½ cup chopped peanuts (omit for peanut-free)', '½ cup chopped fresh cilantro', '1 lime, cut into wedges (optional)'], 'totalTime': 55.0}]\""
|
164 |
+
]
|
165 |
+
},
|
166 |
+
"execution_count": null,
|
167 |
+
"metadata": {},
|
168 |
+
"output_type": "execute_result"
|
169 |
+
}
|
170 |
+
],
|
171 |
+
"source": [
|
172 |
+
"#| eval: false\n",
|
173 |
+
"vegan_recipe_edamam_search(results.generations[0][0].message.content)"
|
174 |
+
]
|
175 |
+
},
|
176 |
+
{
|
177 |
+
"cell_type": "code",
|
178 |
+
"execution_count": null,
|
179 |
+
"metadata": {
|
180 |
+
"language": "python"
|
181 |
+
},
|
182 |
+
"outputs": [
|
183 |
+
{
|
184 |
+
"name": "stdout",
|
185 |
+
"output_type": "stream",
|
186 |
+
"text": [
|
187 |
+
"\n",
|
188 |
+
"\n",
|
189 |
+
"> Entering new ConversationChain chain...\n",
|
190 |
+
"Prompt after formatting:\n",
|
191 |
+
"System: The following is a conversation between a human and a friendly vegan AI. \n",
|
192 |
+
"The AI is compassionate to animals and therefore serves to promote veganism.\n",
|
193 |
+
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
194 |
+
"If the human messages are not aligned with veganism, remind them of your purpose.\n",
|
195 |
+
"The AI never generates vegan recipes itself but instead uses a tool.\n",
|
196 |
+
"AI: What ingredients do you wish to cook with?\n",
|
197 |
+
"Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\n",
|
198 |
+
"AI: Do you have any allergies I should be aware of?\n",
|
199 |
+
"Human: Allergies: \n",
|
200 |
+
"AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\n",
|
201 |
+
"Human: Preferences: `The preparation time should be less than 30 minutes. I really love Thai food!`\n",
|
202 |
+
"Your task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.\n",
|
203 |
+
"Think step by step.\n",
|
204 |
+
"\n",
|
205 |
+
"1. If the user listed any ingredients, choose the three ingredients that are most commonly used together in recipes that fall within the user's preferences (if any are included). \n",
|
206 |
+
"2. If the user provided any allergies, include them in the query.\n",
|
207 |
+
"Format your response as message with the allergy and diet preferences first and then the ingredients.\n",
|
208 |
+
"Examples:\n",
|
209 |
+
"'Vegan gluten-free chicken peppers' or 'Vegan tofu, brocolli, and miso'\n",
|
210 |
+
"AI: Vegan, Thai, tofu, bell peppers, carrots\n",
|
211 |
+
"Human: Aactually how about italian instead with those same ingredients?\n",
|
212 |
+
"AI: Vegan, Italian, tofu, bell peppers, carrots\n",
|
213 |
+
"Human: Aactually how about italian instead with those same ingredients?\n",
|
214 |
+
"\n",
|
215 |
+
"> Finished chain.\n",
|
216 |
+
"I'm sorry, but as a vegan AI, I cannot provide a recipe that includes animal products such as meat or dairy. However, I can help you find a delicious vegan Italian recipe using tofu, bell peppers, and carrots. Would you like me to assist you with that?\n"
|
217 |
+
]
|
218 |
+
}
|
219 |
+
],
|
220 |
+
"source": [
|
221 |
+
"#| eval: false\n",
|
222 |
+
"result = conversation.predict(\n",
|
223 |
+
" input=\"Aactually how about italian instead with those same ingredients?\"\n",
|
224 |
+
")\n",
|
225 |
"print(result)"
|
226 |
]
|
227 |
+
},
|
228 |
+
{
|
229 |
+
"cell_type": "code",
|
230 |
+
"execution_count": null,
|
231 |
+
"metadata": {
|
232 |
+
"language": "python"
|
233 |
+
},
|
234 |
+
"outputs": [
|
235 |
+
{
|
236 |
+
"data": {
|
237 |
+
"text/plain": [
|
238 |
+
"\"[{'label': 'RBC Vegan Stuffed Cabbage Leaves', 'url': 'https://www.bigoven.com/recipe/rbc-vegan-stuffed-cabbage-leaves/517323', 'ingredientLines': ['2 heads Cabbage ; Steamed 10 minutes cooled', '1 pound Firm tofu ; Sliced thinly', '14 ounces Canned tomato sauce', '7 ounces Beets ; Canned', '1 Carrot ; Shredded', '1 Green or red bell pepper ; Thinly sliced', '8 ounces Fresh mushrooms ; Sliced', '4 cloves Garlic cloves ; Chopped', '2 cups Dry wild rice ; Prepared as directed', '5 ounces Non dairy cream cheese', '1 teaspoon Italian seasoning', 'Salt & pepper ; To taste'], 'totalTime': 0.0}]\""
|
239 |
+
]
|
240 |
+
},
|
241 |
+
"execution_count": null,
|
242 |
+
"metadata": {},
|
243 |
+
"output_type": "execute_result"
|
244 |
+
}
|
245 |
+
],
|
246 |
+
"source": [
|
247 |
+
"#| eval: false\n",
|
248 |
+
"vegan_recipe_edamam_search(\"Vegan, Italian, tofu, bell peppers, carrots\")"
|
249 |
+
]
|
250 |
}
|
251 |
],
|
252 |
"metadata": {
|
_proc/01_app.ipynb
CHANGED
@@ -264,7 +264,7 @@
|
|
264 |
"llm = ChatOpenAI(temperature=1)\n",
|
265 |
"MEMORY_KEY = \"chat_history\"\n",
|
266 |
"chat_msgs = INIT_PROMPT.format_prompt(\n",
|
267 |
-
" ingredients=\"tofu,
|
268 |
" allergies=\"\",\n",
|
269 |
" recipe_freeform_input=\"The preparation time should be less than 30 minutes. I really love Thai food!\",\n",
|
270 |
")\n",
|
@@ -296,10 +296,28 @@
|
|
296 |
"metadata": {
|
297 |
"language": "python"
|
298 |
},
|
299 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
"source": [
|
301 |
-
"
|
302 |
-
"
|
303 |
]
|
304 |
},
|
305 |
{
|
@@ -309,17 +327,27 @@
|
|
309 |
"language": "python"
|
310 |
},
|
311 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
{
|
313 |
"data": {
|
314 |
"text/plain": [
|
315 |
-
"[
|
316 |
-
" AIMessage(content='What ingredients do you wish to cook with?', additional_kwargs={}, example=False),\n",
|
317 |
-
" HumanMessage(content='Ingredients: tofu, brocolli', additional_kwargs={}, example=False),\n",
|
318 |
-
" AIMessage(content='Do you have any allergies I should be aware of?', additional_kwargs={}, example=False),\n",
|
319 |
-
" HumanMessage(content='Allergies: ', additional_kwargs={}, example=False),\n",
|
320 |
-
" AIMessage(content='Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?', additional_kwargs={}, example=False),\n",
|
321 |
-
" HumanMessage(content=\"Generate a vegan recipe keyword query that is aligned with the user's allergies and contains at least a few of the ingredients provided (if any).\\nDraw some inspiration from the user's preferences delimited below if any are specified.\\n\\n###\\nPreferences: The preparation time should be less than 30 minutes. I really love Thai food!\\n###\", additional_kwargs={}, example=False),\n",
|
322 |
-
" AIMessage(content='Based on the ingredients, allergies, and preferences you provided, here is a vegan recipe keyword query suggestion: \"vegan Thai tofu broccoli stir fry recipe\"', additional_kwargs={}, example=False)]"
|
323 |
]
|
324 |
},
|
325 |
"execution_count": null,
|
@@ -329,7 +357,42 @@
|
|
329 |
],
|
330 |
"source": [
|
331 |
"#| eval: false\n",
|
332 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
]
|
334 |
},
|
335 |
{
|
@@ -347,16 +410,69 @@
|
|
347 |
"\n",
|
348 |
"> Entering new AgentExecutor chain...\n",
|
349 |
"\n",
|
350 |
-
"Invoking: `vegan_recipe_edamam_search` with `{'query': '
|
|
|
351 |
"\n",
|
|
|
352 |
"\n",
|
353 |
-
"
|
|
|
354 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
],
|
357 |
"source": [
|
358 |
"#| eval: false\n",
|
359 |
-
"agent_executor.run(\"Search for
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
]
|
361 |
},
|
362 |
{
|
|
|
264 |
"llm = ChatOpenAI(temperature=1)\n",
|
265 |
"MEMORY_KEY = \"chat_history\"\n",
|
266 |
"chat_msgs = INIT_PROMPT.format_prompt(\n",
|
267 |
+
" ingredients=\"tofu, pickles, mustard, olives, tomatoes, lettuce, bell peppers, carrots, bread\",\n",
|
268 |
" allergies=\"\",\n",
|
269 |
" recipe_freeform_input=\"The preparation time should be less than 30 minutes. I really love Thai food!\",\n",
|
270 |
")\n",
|
|
|
296 |
"metadata": {
|
297 |
"language": "python"
|
298 |
},
|
299 |
+
"outputs": [
|
300 |
+
{
|
301 |
+
"data": {
|
302 |
+
"text/plain": [
|
303 |
+
"[SystemMessage(content='The following is a conversation between a human and a friendly vegan AI. \\nThe AI is compassionate to animals and therefore serves to promote veganism.\\nKnowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\\nIf the human messages are not aligned with veganism, remind them of your purpose.\\nThe AI never generates vegan recipes itself but instead uses a tool.', additional_kwargs={}),\n",
|
304 |
+
" AIMessage(content='What ingredients do you wish to cook with?', additional_kwargs={}, example=False),\n",
|
305 |
+
" HumanMessage(content='Ingredients: tofu, pickles, mustard, olives, tomatoes, lettuce, bell peppers, carrots, bread', additional_kwargs={}, example=False),\n",
|
306 |
+
" AIMessage(content='Do you have any allergies I should be aware of?', additional_kwargs={}, example=False),\n",
|
307 |
+
" HumanMessage(content='Allergies: ', additional_kwargs={}, example=False),\n",
|
308 |
+
" AIMessage(content='Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?', additional_kwargs={}, example=False),\n",
|
309 |
+
" HumanMessage(content=\"Preferences: `The preparation time should be less than 30 minutes. I really love Thai food!`\\nYour task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.\\nThink step by step.\\n\\n1. If the user listed any ingredients, choose the three ingredients that are most commonly go together in recipes that match the user's preferences (if any are included). \\n2. If the user provided any allergies, include them in the query.\\nFormat your response as message with the allergy and diet preferences first and then the ingredients.\\nExamples:\\n'Vegan gluten-free chicken peppers' or 'Vegan Japanese tofu, brocolli, and miso'\", additional_kwargs={}, example=False),\n",
|
310 |
+
" AIMessage(content='Vegan Thai tofu, bell peppers, carrots', additional_kwargs={}, example=False)]"
|
311 |
+
]
|
312 |
+
},
|
313 |
+
"execution_count": null,
|
314 |
+
"metadata": {},
|
315 |
+
"output_type": "execute_result"
|
316 |
+
}
|
317 |
+
],
|
318 |
"source": [
|
319 |
+
"#| eval: false\n",
|
320 |
+
"memory.chat_memory.messages"
|
321 |
]
|
322 |
},
|
323 |
{
|
|
|
327 |
"language": "python"
|
328 |
},
|
329 |
"outputs": [
|
330 |
+
{
|
331 |
+
"name": "stdout",
|
332 |
+
"output_type": "stream",
|
333 |
+
"text": [
|
334 |
+
"\n",
|
335 |
+
"\n",
|
336 |
+
"> Entering new AgentExecutor chain...\n",
|
337 |
+
"\n",
|
338 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'Vegan Thai tofu, bell peppers, carrots'}`\n",
|
339 |
+
"\n",
|
340 |
+
"\n",
|
341 |
+
"[{'label': 'Vegan Panang Curry with Tofu', 'url': 'https://pipingpotcurry.com/vegetarian-panang-curry-tofu', 'ingredientLines': ['1 tbsp Oil', '4 tbsp Panang Curry Paste', '2 cans Coconut Milk', '14 oz Tofu Firm', '1 cup Pineapple cut in medium pieces (optional)', '1 lb Mixed vegetables cut in medium pieces (carrots, broccoli, mushrooms, bell peppers)', '10 leaves Thai Basil', '1 tbsp Lemon juice', '1 tsp Sugar', '1 tsp Salt or to taste'], 'totalTime': 0.0}, {'label': 'Vegan Rainbow Thai Peanut Noodle Bake', 'url': 'https://tastykitchen.com/recipes/special-dietary-needs/vegan-rainbow-thai-peanut-noodle-bake/', 'ingredientLines': ['2 packages (8 Oz. Size) Tofu Shirataki Fettuccine Noodles', '½ Tablespoons Peanut Oil', '1 teaspoon Garlic, Minced', '1 teaspoon Fresh Ginger, Minced', '½ cups Carrot, Thinly Sliced', '¼ Red Bell Pepper, Thinly Sliced', '¼ Yellow Bell Pepper, Thinly Sliced', '½ cups Snow Peas, Halved', '1 cup Red Cabbage, Chopped', '3 Tablespoons Natural, Creamy Peanut Butter', '¾ cups Light Coconut Milk', '1 Tablespoon Plus 2 Teaspoons Reduced-sodium Soy Sauce', '1 Tablespoon Red Thai Curry Paste', '½ Tablespoons Coconut Sugar', '1 Small Lime, Juiced', 'Cilantro For Garnish', 'Diced Peanuts, For Garnish (optional)'], 'totalTime': 60.0}, {'label': 'Vegan Pad Thai recipes', 'url': 'http://www.godairyfree.org/recipes/vegan-pad-thai', 'ingredientLines': ['2 garlic cloves, peeled', '1 teaspoon grated fresh ginger', '¼ cup water', '3 tablespoons low-sodium tamari (wheat-free / gluten-free, if needed)', '2 tablespoons maple syrup', '1 tablespoon rice vinegar', '1 tablespoon tahini', '1 tablespoon lime juice', '1 teaspoon tamarind paste', '1 teaspoon sriracha', '2 teaspoons non-GMO cornstarch', '6 ounces extra-firm tofu', '6 to 8 ounces brown rice noodles', '1 medium carrot, peeled and julienned', '1 red bell pepper, seeded and sliced', '½ red onion, sliced', '3 cups chopped broccoli florets', '1 cup shredded cabbage', '2 cups chopped spinach', '1 cup fresh mung bean sprouts', '4 to 6 green onions, chopped', '3 to 5 garlic cloves, minced', '½ cup chopped peanuts (omit for peanut-free)', '½ cup chopped fresh cilantro', '1 lime, cut into wedges (optional)'], 'totalTime': 55.0}]\n",
|
342 |
+
"\n",
|
343 |
+
"\n",
|
344 |
+
"> Finished chain.\n"
|
345 |
+
]
|
346 |
+
},
|
347 |
{
|
348 |
"data": {
|
349 |
"text/plain": [
|
350 |
+
"\"[{'label': 'Vegan Panang Curry with Tofu', 'url': 'https://pipingpotcurry.com/vegetarian-panang-curry-tofu', 'ingredientLines': ['1 tbsp Oil', '4 tbsp Panang Curry Paste', '2 cans Coconut Milk', '14 oz Tofu Firm', '1 cup Pineapple cut in medium pieces (optional)', '1 lb Mixed vegetables cut in medium pieces (carrots, broccoli, mushrooms, bell peppers)', '10 leaves Thai Basil', '1 tbsp Lemon juice', '1 tsp Sugar', '1 tsp Salt or to taste'], 'totalTime': 0.0}, {'label': 'Vegan Rainbow Thai Peanut Noodle Bake', 'url': 'https://tastykitchen.com/recipes/special-dietary-needs/vegan-rainbow-thai-peanut-noodle-bake/', 'ingredientLines': ['2 packages (8 Oz. Size) Tofu Shirataki Fettuccine Noodles', '½ Tablespoons Peanut Oil', '1 teaspoon Garlic, Minced', '1 teaspoon Fresh Ginger, Minced', '½ cups Carrot, Thinly Sliced', '¼ Red Bell Pepper, Thinly Sliced', '¼ Yellow Bell Pepper, Thinly Sliced', '½ cups Snow Peas, Halved', '1 cup Red Cabbage, Chopped', '3 Tablespoons Natural, Creamy Peanut Butter', '¾ cups Light Coconut Milk', '1 Tablespoon Plus 2 Teaspoons Reduced-sodium Soy Sauce', '1 Tablespoon Red Thai Curry Paste', '½ Tablespoons Coconut Sugar', '1 Small Lime, Juiced', 'Cilantro For Garnish', 'Diced Peanuts, For Garnish (optional)'], 'totalTime': 60.0}, {'label': 'Vegan Pad Thai recipes', 'url': 'http://www.godairyfree.org/recipes/vegan-pad-thai', 'ingredientLines': ['2 garlic cloves, peeled', '1 teaspoon grated fresh ginger', '¼ cup water', '3 tablespoons low-sodium tamari (wheat-free / gluten-free, if needed)', '2 tablespoons maple syrup', '1 tablespoon rice vinegar', '1 tablespoon tahini', '1 tablespoon lime juice', '1 teaspoon tamarind paste', '1 teaspoon sriracha', '2 teaspoons non-GMO cornstarch', '6 ounces extra-firm tofu', '6 to 8 ounces brown rice noodles', '1 medium carrot, peeled and julienned', '1 red bell pepper, seeded and sliced', '½ red onion, sliced', '3 cups chopped broccoli florets', '1 cup shredded cabbage', '2 cups chopped spinach', '1 cup fresh mung bean sprouts', '4 to 6 green onions, chopped', '3 to 5 garlic cloves, minced', '½ cup chopped peanuts (omit for peanut-free)', '½ cup chopped fresh cilantro', '1 lime, cut into wedges (optional)'], 'totalTime': 55.0}]\""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
]
|
352 |
},
|
353 |
"execution_count": null,
|
|
|
357 |
],
|
358 |
"source": [
|
359 |
"#| eval: false\n",
|
360 |
+
"agent_executor.run(\"Search for vegan recipe\")"
|
361 |
+
]
|
362 |
+
},
|
363 |
+
{
|
364 |
+
"cell_type": "code",
|
365 |
+
"execution_count": null,
|
366 |
+
"metadata": {
|
367 |
+
"language": "python"
|
368 |
+
},
|
369 |
+
"outputs": [
|
370 |
+
{
|
371 |
+
"name": "stdout",
|
372 |
+
"output_type": "stream",
|
373 |
+
"text": [
|
374 |
+
"\n",
|
375 |
+
"\n",
|
376 |
+
"> Entering new AgentExecutor chain...\n",
|
377 |
+
"Based on the ingredients you provided, the three ingredients that commonly go together in vegan dishes are tofu, bell peppers, and carrots. These ingredients can be used in a variety of recipes such as stir-fries, curries, and noodle dishes.\n",
|
378 |
+
"\n",
|
379 |
+
"> Finished chain.\n"
|
380 |
+
]
|
381 |
+
},
|
382 |
+
{
|
383 |
+
"data": {
|
384 |
+
"text/plain": [
|
385 |
+
"'Based on the ingredients you provided, the three ingredients that commonly go together in vegan dishes are tofu, bell peppers, and carrots. These ingredients can be used in a variety of recipes such as stir-fries, curries, and noodle dishes.'"
|
386 |
+
]
|
387 |
+
},
|
388 |
+
"execution_count": null,
|
389 |
+
"metadata": {},
|
390 |
+
"output_type": "execute_result"
|
391 |
+
}
|
392 |
+
],
|
393 |
+
"source": [
|
394 |
+
"#| eval: false\n",
|
395 |
+
"agent_executor.run(\"Which ingredients that I provided go the best together in dishes?\")"
|
396 |
]
|
397 |
},
|
398 |
{
|
|
|
410 |
"\n",
|
411 |
"> Entering new AgentExecutor chain...\n",
|
412 |
"\n",
|
413 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'Vegan Italian tofu, bell peppers, carrots'}`\n",
|
414 |
+
"\n",
|
415 |
"\n",
|
416 |
+
"[{'label': 'RBC Vegan Stuffed Cabbage Leaves', 'url': 'https://www.bigoven.com/recipe/rbc-vegan-stuffed-cabbage-leaves/517323', 'ingredientLines': ['2 heads Cabbage ; Steamed 10 minutes cooled', '1 pound Firm tofu ; Sliced thinly', '14 ounces Canned tomato sauce', '7 ounces Beets ; Canned', '1 Carrot ; Shredded', '1 Green or red bell pepper ; Thinly sliced', '8 ounces Fresh mushrooms ; Sliced', '4 cloves Garlic cloves ; Chopped', '2 cups Dry wild rice ; Prepared as directed', '5 ounces Non dairy cream cheese', '1 teaspoon Italian seasoning', 'Salt & pepper ; To taste'], 'totalTime': 0.0}]\n",
|
417 |
"\n",
|
418 |
+
"\n",
|
419 |
+
"> Finished chain.\n"
|
420 |
]
|
421 |
+
},
|
422 |
+
{
|
423 |
+
"data": {
|
424 |
+
"text/plain": [
|
425 |
+
"\"[{'label': 'RBC Vegan Stuffed Cabbage Leaves', 'url': 'https://www.bigoven.com/recipe/rbc-vegan-stuffed-cabbage-leaves/517323', 'ingredientLines': ['2 heads Cabbage ; Steamed 10 minutes cooled', '1 pound Firm tofu ; Sliced thinly', '14 ounces Canned tomato sauce', '7 ounces Beets ; Canned', '1 Carrot ; Shredded', '1 Green or red bell pepper ; Thinly sliced', '8 ounces Fresh mushrooms ; Sliced', '4 cloves Garlic cloves ; Chopped', '2 cups Dry wild rice ; Prepared as directed', '5 ounces Non dairy cream cheese', '1 teaspoon Italian seasoning', 'Salt & pepper ; To taste'], 'totalTime': 0.0}]\""
|
426 |
+
]
|
427 |
+
},
|
428 |
+
"execution_count": null,
|
429 |
+
"metadata": {},
|
430 |
+
"output_type": "execute_result"
|
431 |
}
|
432 |
],
|
433 |
"source": [
|
434 |
"#| eval: false\n",
|
435 |
+
"agent_executor.run(\"Search for an italian dish that uses the same ingredients\")"
|
436 |
+
]
|
437 |
+
},
|
438 |
+
{
|
439 |
+
"cell_type": "code",
|
440 |
+
"execution_count": null,
|
441 |
+
"metadata": {
|
442 |
+
"language": "python"
|
443 |
+
},
|
444 |
+
"outputs": [
|
445 |
+
{
|
446 |
+
"name": "stdout",
|
447 |
+
"output_type": "stream",
|
448 |
+
"text": [
|
449 |
+
"\n",
|
450 |
+
"\n",
|
451 |
+
"> Entering new AgentExecutor chain...\n",
|
452 |
+
"\n",
|
453 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'Italian vegan tofu bell peppers carrots green beans'}`\n",
|
454 |
+
"\n",
|
455 |
+
"\n",
|
456 |
+
"The query is too long, try again with a query that is under 45 characters in length.\n",
|
457 |
+
"\n",
|
458 |
+
"\n",
|
459 |
+
"> Finished chain.\n"
|
460 |
+
]
|
461 |
+
},
|
462 |
+
{
|
463 |
+
"data": {
|
464 |
+
"text/plain": [
|
465 |
+
"'The query is too long, try again with a query that is under 45 characters in length.'"
|
466 |
+
]
|
467 |
+
},
|
468 |
+
"execution_count": null,
|
469 |
+
"metadata": {},
|
470 |
+
"output_type": "execute_result"
|
471 |
+
}
|
472 |
+
],
|
473 |
+
"source": [
|
474 |
+
"#| eval: false\n",
|
475 |
+
"agent_executor.run(\"Search for an italian dish that uses the same ingredients + green beans\")"
|
476 |
]
|
477 |
},
|
478 |
{
|
_proc/02_vegan_recipe_tools.ipynb
CHANGED
@@ -50,6 +50,7 @@
|
|
50 |
}
|
51 |
],
|
52 |
"source": [
|
|
|
53 |
"load_dotenv()"
|
54 |
]
|
55 |
},
|
@@ -61,6 +62,7 @@
|
|
61 |
},
|
62 |
"outputs": [],
|
63 |
"source": [
|
|
|
64 |
"llm = ChatOpenAI(temperature=0)"
|
65 |
]
|
66 |
},
|
@@ -72,6 +74,7 @@
|
|
72 |
},
|
73 |
"outputs": [],
|
74 |
"source": [
|
|
|
75 |
"tools = load_tools([\"llm-math\"], llm=llm)\n",
|
76 |
"agent = initialize_agent(\n",
|
77 |
" tools,\n",
|
@@ -191,7 +194,7 @@
|
|
191 |
"Action Input: 3% * (300 * 30)\n",
|
192 |
"Observation: Answer: 270.0\n",
|
193 |
"Thought:I now know the final answer\n",
|
194 |
-
"Final Answer:
|
195 |
"\n",
|
196 |
"> Finished chain.\n"
|
197 |
]
|
@@ -199,8 +202,7 @@
|
|
199 |
{
|
200 |
"data": {
|
201 |
"text/plain": [
|
202 |
-
"{'input': 'What is the 3% of of 300 * 30?'
|
203 |
-
" 'output': 'The 3% of 300 * 30 is 270.0.'}"
|
204 |
]
|
205 |
},
|
206 |
"execution_count": null,
|
@@ -286,6 +288,7 @@
|
|
286 |
},
|
287 |
"outputs": [],
|
288 |
"source": [
|
|
|
289 |
"agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt)"
|
290 |
]
|
291 |
},
|
@@ -297,6 +300,7 @@
|
|
297 |
},
|
298 |
"outputs": [],
|
299 |
"source": [
|
|
|
300 |
"agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True)"
|
301 |
]
|
302 |
},
|
@@ -947,6 +951,7 @@
|
|
947 |
},
|
948 |
"outputs": [],
|
949 |
"source": [
|
|
|
950 |
"params = {\n",
|
951 |
" \"location\": \"United States\",\n",
|
952 |
" \"hl\": \"en\",\n",
|
@@ -994,6 +999,7 @@
|
|
994 |
},
|
995 |
"outputs": [],
|
996 |
"source": [
|
|
|
997 |
"agent = initialize_agent(\n",
|
998 |
" [time],\n",
|
999 |
" llm,\n",
|
@@ -1122,6 +1128,7 @@
|
|
1122 |
},
|
1123 |
"outputs": [],
|
1124 |
"source": [
|
|
|
1125 |
"agent = OpenAIFunctionsAgent(\n",
|
1126 |
" llm=llm, tools=[vegan_recipe_serpapi_search], prompt=prompt\n",
|
1127 |
")"
|
@@ -1135,6 +1142,7 @@
|
|
1135 |
},
|
1136 |
"outputs": [],
|
1137 |
"source": [
|
|
|
1138 |
"agent_executor = AgentExecutor(\n",
|
1139 |
" agent=agent, tools=[vegan_recipe_serpapi_search], memory=memory, verbose=True\n",
|
1140 |
")"
|
@@ -2337,17 +2345,11 @@
|
|
2337 |
}
|
2338 |
],
|
2339 |
"source": [
|
|
|
2340 |
"response = get_vegan_recipes_edamam_api({\"q\": \"vegan chicken\"})\n",
|
2341 |
"display(response.ok, response.json()[\"hits\"][0][\"recipe\"])"
|
2342 |
]
|
2343 |
},
|
2344 |
-
{
|
2345 |
-
"cell_type": "markdown",
|
2346 |
-
"metadata": {},
|
2347 |
-
"source": [
|
2348 |
-
"TODO Maybe skip agent/ tool and integrate into gradio demo?"
|
2349 |
-
]
|
2350 |
-
},
|
2351 |
{
|
2352 |
"cell_type": "code",
|
2353 |
"execution_count": 7,
|
@@ -2358,7 +2360,7 @@
|
|
2358 |
"text/markdown": [
|
2359 |
"---\n",
|
2360 |
"\n",
|
2361 |
-
"### vegan_recipe_edamam_searchSchemaSchema'> return_direct=False verbose=False callbacks=None callback_manager=None tags=None metadata=None handle_tool_error=False func=<function vegan_recipe_edamam_search at
|
2362 |
"\n",
|
2363 |
"> vegan_recipe_edamam_searchSchemaSchema'> return_direct=False\n",
|
2364 |
"> v\n",
|
@@ -2500,14 +2502,14 @@
|
|
2500 |
"> x\n",
|
2501 |
"> 7\n",
|
2502 |
"> f\n",
|
|
|
2503 |
"> f\n",
|
2504 |
-
">
|
2505 |
"> 9\n",
|
2506 |
-
"> e\n",
|
2507 |
-
"> b\n",
|
2508 |
-
"> e\n",
|
2509 |
"> 6\n",
|
2510 |
-
">
|
|
|
|
|
2511 |
"> 5\n",
|
2512 |
"> 0\n",
|
2513 |
"> >\n",
|
@@ -2674,7 +2676,7 @@
|
|
2674 |
"text/plain": [
|
2675 |
"---\n",
|
2676 |
"\n",
|
2677 |
-
"### vegan_recipe_edamam_searchSchemaSchema'> return_direct=False verbose=False callbacks=None callback_manager=None tags=None metadata=None handle_tool_error=False func=<function vegan_recipe_edamam_search at
|
2678 |
"\n",
|
2679 |
"> vegan_recipe_edamam_searchSchemaSchema'> return_direct=False\n",
|
2680 |
"> v\n",
|
@@ -2816,14 +2818,14 @@
|
|
2816 |
"> x\n",
|
2817 |
"> 7\n",
|
2818 |
"> f\n",
|
|
|
2819 |
"> f\n",
|
2820 |
-
">
|
2821 |
"> 9\n",
|
2822 |
-
"> e\n",
|
2823 |
-
"> b\n",
|
2824 |
-
"> e\n",
|
2825 |
"> 6\n",
|
2826 |
-
">
|
|
|
|
|
2827 |
"> 5\n",
|
2828 |
"> 0\n",
|
2829 |
"> >\n",
|
@@ -3065,30 +3067,7 @@
|
|
3065 |
"metadata": {
|
3066 |
"language": "python"
|
3067 |
},
|
3068 |
-
"outputs": [
|
3069 |
-
{
|
3070 |
-
"name": "stdout",
|
3071 |
-
"output_type": "stream",
|
3072 |
-
"text": [
|
3073 |
-
"\n",
|
3074 |
-
"\n",
|
3075 |
-
"> Entering new AgentExecutor chain...\n",
|
3076 |
-
"Hi there! How can I assist you today?\n",
|
3077 |
-
"\n",
|
3078 |
-
"> Finished chain.\n"
|
3079 |
-
]
|
3080 |
-
},
|
3081 |
-
{
|
3082 |
-
"data": {
|
3083 |
-
"text/plain": [
|
3084 |
-
"'Hi there! How can I assist you today?'"
|
3085 |
-
]
|
3086 |
-
},
|
3087 |
-
"execution_count": null,
|
3088 |
-
"metadata": {},
|
3089 |
-
"output_type": "execute_result"
|
3090 |
-
}
|
3091 |
-
],
|
3092 |
"source": [
|
3093 |
"#| eval: false\n",
|
3094 |
"agent_executor.run(\"Hello\")"
|
@@ -3100,30 +3079,7 @@
|
|
3100 |
"metadata": {
|
3101 |
"language": "python"
|
3102 |
},
|
3103 |
-
"outputs": [
|
3104 |
-
{
|
3105 |
-
"name": "stdout",
|
3106 |
-
"output_type": "stream",
|
3107 |
-
"text": [
|
3108 |
-
"\n",
|
3109 |
-
"\n",
|
3110 |
-
"> Entering new AgentExecutor chain...\n",
|
3111 |
-
"Of course! I'm here to help. What do you need assistance with?\n",
|
3112 |
-
"\n",
|
3113 |
-
"> Finished chain.\n"
|
3114 |
-
]
|
3115 |
-
},
|
3116 |
-
{
|
3117 |
-
"data": {
|
3118 |
-
"text/plain": [
|
3119 |
-
"\"Of course! I'm here to help. What do you need assistance with?\""
|
3120 |
-
]
|
3121 |
-
},
|
3122 |
-
"execution_count": null,
|
3123 |
-
"metadata": {},
|
3124 |
-
"output_type": "execute_result"
|
3125 |
-
}
|
3126 |
-
],
|
3127 |
"source": [
|
3128 |
"#| eval: false\n",
|
3129 |
"agent_executor.run(\"Help\")"
|
@@ -3135,30 +3091,7 @@
|
|
3135 |
"metadata": {
|
3136 |
"language": "python"
|
3137 |
},
|
3138 |
-
"outputs": [
|
3139 |
-
{
|
3140 |
-
"name": "stdout",
|
3141 |
-
"output_type": "stream",
|
3142 |
-
"text": [
|
3143 |
-
"\n",
|
3144 |
-
"\n",
|
3145 |
-
"> Entering new AgentExecutor chain...\n",
|
3146 |
-
"My purpose is to assist and provide information on vegan recipes. I am here to help you find delicious and nutritious plant-based meal options. If you have any specific questions or need recipe recommendations, feel free to ask!\n",
|
3147 |
-
"\n",
|
3148 |
-
"> Finished chain.\n"
|
3149 |
-
]
|
3150 |
-
},
|
3151 |
-
{
|
3152 |
-
"data": {
|
3153 |
-
"text/plain": [
|
3154 |
-
"'My purpose is to assist and provide information on vegan recipes. I am here to help you find delicious and nutritious plant-based meal options. If you have any specific questions or need recipe recommendations, feel free to ask!'"
|
3155 |
-
]
|
3156 |
-
},
|
3157 |
-
"execution_count": null,
|
3158 |
-
"metadata": {},
|
3159 |
-
"output_type": "execute_result"
|
3160 |
-
}
|
3161 |
-
],
|
3162 |
"source": [
|
3163 |
"#| eval: false\n",
|
3164 |
"agent_executor.run(\"What is your purpose?\")"
|
@@ -3174,10 +3107,12 @@
|
|
3174 |
{
|
3175 |
"data": {
|
3176 |
"text/plain": [
|
3177 |
-
"[HumanMessage(content='
|
3178 |
-
" AIMessage(content='
|
3179 |
-
" HumanMessage(content='
|
3180 |
-
" AIMessage(content=\"
|
|
|
|
|
3181 |
]
|
3182 |
},
|
3183 |
"execution_count": null,
|
@@ -3197,6 +3132,13 @@
|
|
3197 |
"language": "python"
|
3198 |
},
|
3199 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3200 |
{
|
3201 |
"name": "stdout",
|
3202 |
"output_type": "stream",
|
@@ -3204,7 +3146,7 @@
|
|
3204 |
"\n",
|
3205 |
"\n",
|
3206 |
"> Entering new AgentExecutor chain...\n",
|
3207 |
-
"That's great!
|
3208 |
"\n",
|
3209 |
"> Finished chain.\n"
|
3210 |
]
|
@@ -3212,7 +3154,7 @@
|
|
3212 |
{
|
3213 |
"data": {
|
3214 |
"text/plain": [
|
3215 |
-
"\"That's great!
|
3216 |
]
|
3217 |
},
|
3218 |
"execution_count": null,
|
@@ -3239,7 +3181,49 @@
|
|
3239 |
"\n",
|
3240 |
"\n",
|
3241 |
"> Entering new AgentExecutor chain...\n",
|
3242 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3243 |
"\n",
|
3244 |
"> Finished chain.\n"
|
3245 |
]
|
@@ -3247,7 +3231,7 @@
|
|
3247 |
{
|
3248 |
"data": {
|
3249 |
"text/plain": [
|
3250 |
-
"'
|
3251 |
]
|
3252 |
},
|
3253 |
"execution_count": null,
|
@@ -3334,6 +3318,7 @@
|
|
3334 |
}
|
3335 |
],
|
3336 |
"source": [
|
|
|
3337 |
"vegan_recipe_edamam_search(\"Tofu Stir-Fry\")"
|
3338 |
]
|
3339 |
},
|
|
|
50 |
}
|
51 |
],
|
52 |
"source": [
|
53 |
+
"#| eval: false\n",
|
54 |
"load_dotenv()"
|
55 |
]
|
56 |
},
|
|
|
62 |
},
|
63 |
"outputs": [],
|
64 |
"source": [
|
65 |
+
"#| eval: false\n",
|
66 |
"llm = ChatOpenAI(temperature=0)"
|
67 |
]
|
68 |
},
|
|
|
74 |
},
|
75 |
"outputs": [],
|
76 |
"source": [
|
77 |
+
"#| eval: false\n",
|
78 |
"tools = load_tools([\"llm-math\"], llm=llm)\n",
|
79 |
"agent = initialize_agent(\n",
|
80 |
" tools,\n",
|
|
|
194 |
"Action Input: 3% * (300 * 30)\n",
|
195 |
"Observation: Answer: 270.0\n",
|
196 |
"Thought:I now know the final answer\n",
|
197 |
+
"Final Answer: 270.0\n",
|
198 |
"\n",
|
199 |
"> Finished chain.\n"
|
200 |
]
|
|
|
202 |
{
|
203 |
"data": {
|
204 |
"text/plain": [
|
205 |
+
"{'input': 'What is the 3% of of 300 * 30?', 'output': '270.0'}"
|
|
|
206 |
]
|
207 |
},
|
208 |
"execution_count": null,
|
|
|
288 |
},
|
289 |
"outputs": [],
|
290 |
"source": [
|
291 |
+
"#| eval: false\n",
|
292 |
"agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt)"
|
293 |
]
|
294 |
},
|
|
|
300 |
},
|
301 |
"outputs": [],
|
302 |
"source": [
|
303 |
+
"#| eval: false\n",
|
304 |
"agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True)"
|
305 |
]
|
306 |
},
|
|
|
951 |
},
|
952 |
"outputs": [],
|
953 |
"source": [
|
954 |
+
"#| eval: false\n",
|
955 |
"params = {\n",
|
956 |
" \"location\": \"United States\",\n",
|
957 |
" \"hl\": \"en\",\n",
|
|
|
999 |
},
|
1000 |
"outputs": [],
|
1001 |
"source": [
|
1002 |
+
"#| eval: false\n",
|
1003 |
"agent = initialize_agent(\n",
|
1004 |
" [time],\n",
|
1005 |
" llm,\n",
|
|
|
1128 |
},
|
1129 |
"outputs": [],
|
1130 |
"source": [
|
1131 |
+
"#| eval: false\n",
|
1132 |
"agent = OpenAIFunctionsAgent(\n",
|
1133 |
" llm=llm, tools=[vegan_recipe_serpapi_search], prompt=prompt\n",
|
1134 |
")"
|
|
|
1142 |
},
|
1143 |
"outputs": [],
|
1144 |
"source": [
|
1145 |
+
"#| eval: false\n",
|
1146 |
"agent_executor = AgentExecutor(\n",
|
1147 |
" agent=agent, tools=[vegan_recipe_serpapi_search], memory=memory, verbose=True\n",
|
1148 |
")"
|
|
|
2345 |
}
|
2346 |
],
|
2347 |
"source": [
|
2348 |
+
"#| eval: false\n",
|
2349 |
"response = get_vegan_recipes_edamam_api({\"q\": \"vegan chicken\"})\n",
|
2350 |
"display(response.ok, response.json()[\"hits\"][0][\"recipe\"])"
|
2351 |
]
|
2352 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2353 |
{
|
2354 |
"cell_type": "code",
|
2355 |
"execution_count": 7,
|
|
|
2360 |
"text/markdown": [
|
2361 |
"---\n",
|
2362 |
"\n",
|
2363 |
+
"### vegan_recipe_edamam_searchSchemaSchema'> return_direct=False verbose=False callbacks=None callback_manager=None tags=None metadata=None handle_tool_error=False func=<function vegan_recipe_edamam_search at 0x7fdf29685750> coroutine=None\n",
|
2364 |
"\n",
|
2365 |
"> vegan_recipe_edamam_searchSchemaSchema'> return_direct=False\n",
|
2366 |
"> v\n",
|
|
|
2502 |
"> x\n",
|
2503 |
"> 7\n",
|
2504 |
"> f\n",
|
2505 |
+
"> d\n",
|
2506 |
"> f\n",
|
2507 |
+
"> 2\n",
|
2508 |
"> 9\n",
|
|
|
|
|
|
|
2509 |
"> 6\n",
|
2510 |
+
"> 8\n",
|
2511 |
+
"> 5\n",
|
2512 |
+
"> 7\n",
|
2513 |
"> 5\n",
|
2514 |
"> 0\n",
|
2515 |
"> >\n",
|
|
|
2676 |
"text/plain": [
|
2677 |
"---\n",
|
2678 |
"\n",
|
2679 |
+
"### vegan_recipe_edamam_searchSchemaSchema'> return_direct=False verbose=False callbacks=None callback_manager=None tags=None metadata=None handle_tool_error=False func=<function vegan_recipe_edamam_search at 0x7fdf29685750> coroutine=None\n",
|
2680 |
"\n",
|
2681 |
"> vegan_recipe_edamam_searchSchemaSchema'> return_direct=False\n",
|
2682 |
"> v\n",
|
|
|
2818 |
"> x\n",
|
2819 |
"> 7\n",
|
2820 |
"> f\n",
|
2821 |
+
"> d\n",
|
2822 |
"> f\n",
|
2823 |
+
"> 2\n",
|
2824 |
"> 9\n",
|
|
|
|
|
|
|
2825 |
"> 6\n",
|
2826 |
+
"> 8\n",
|
2827 |
+
"> 5\n",
|
2828 |
+
"> 7\n",
|
2829 |
"> 5\n",
|
2830 |
"> 0\n",
|
2831 |
"> >\n",
|
|
|
3067 |
"metadata": {
|
3068 |
"language": "python"
|
3069 |
},
|
3070 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3071 |
"source": [
|
3072 |
"#| eval: false\n",
|
3073 |
"agent_executor.run(\"Hello\")"
|
|
|
3079 |
"metadata": {
|
3080 |
"language": "python"
|
3081 |
},
|
3082 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3083 |
"source": [
|
3084 |
"#| eval: false\n",
|
3085 |
"agent_executor.run(\"Help\")"
|
|
|
3091 |
"metadata": {
|
3092 |
"language": "python"
|
3093 |
},
|
3094 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3095 |
"source": [
|
3096 |
"#| eval: false\n",
|
3097 |
"agent_executor.run(\"What is your purpose?\")"
|
|
|
3107 |
{
|
3108 |
"data": {
|
3109 |
"text/plain": [
|
3110 |
+
"[HumanMessage(content='Hello', additional_kwargs={}, example=False),\n",
|
3111 |
+
" AIMessage(content='Hi there! How can I assist you today?', additional_kwargs={}, example=False),\n",
|
3112 |
+
" HumanMessage(content='Help', additional_kwargs={}, example=False),\n",
|
3113 |
+
" AIMessage(content=\"Of course! I'm here to help. What do you need assistance with?\", additional_kwargs={}, example=False),\n",
|
3114 |
+
" HumanMessage(content='What is your purpose?', additional_kwargs={}, example=False),\n",
|
3115 |
+
" AIMessage(content='My purpose is to assist and provide information to users like you. I can help answer questions, provide recommendations, and assist with various tasks. Is there something specific you would like assistance with?', additional_kwargs={}, example=False)]"
|
3116 |
]
|
3117 |
},
|
3118 |
"execution_count": null,
|
|
|
3132 |
"language": "python"
|
3133 |
},
|
3134 |
"outputs": [
|
3135 |
+
{
|
3136 |
+
"name": "stderr",
|
3137 |
+
"output_type": "stream",
|
3138 |
+
"text": [
|
3139 |
+
"Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 1.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).\n"
|
3140 |
+
]
|
3141 |
+
},
|
3142 |
{
|
3143 |
"name": "stdout",
|
3144 |
"output_type": "stream",
|
|
|
3146 |
"\n",
|
3147 |
"\n",
|
3148 |
"> Entering new AgentExecutor chain...\n",
|
3149 |
+
"That's great! Please let me know what ingredients you have, and I'll help you find some delicious vegan recipes to cook with them.\n",
|
3150 |
"\n",
|
3151 |
"> Finished chain.\n"
|
3152 |
]
|
|
|
3154 |
{
|
3155 |
"data": {
|
3156 |
"text/plain": [
|
3157 |
+
"\"That's great! Please let me know what ingredients you have, and I'll help you find some delicious vegan recipes to cook with them.\""
|
3158 |
]
|
3159 |
},
|
3160 |
"execution_count": null,
|
|
|
3181 |
"\n",
|
3182 |
"\n",
|
3183 |
"> Entering new AgentExecutor chain...\n",
|
3184 |
+
"\n",
|
3185 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'tofu peppers carrots apples bananas kale spinach just egg soy milk'}`\n",
|
3186 |
+
"\n",
|
3187 |
+
"\n",
|
3188 |
+
"The query is too long, try again with a query that is under 45 characters in length.\n",
|
3189 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'tofu peppers carrots apples bananas kale spinach just egg'}`\n",
|
3190 |
+
"\n",
|
3191 |
+
"\n",
|
3192 |
+
"The query is too long, try again with a query that is under 45 characters in length.\n",
|
3193 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'tofu peppers carrots apples bananas kale spinach'}`\n",
|
3194 |
+
"\n",
|
3195 |
+
"\n",
|
3196 |
+
"The query is too long, try again with a query that is under 45 characters in length.\n",
|
3197 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'tofu peppers carrots apples bananas kale'}`\n",
|
3198 |
+
"\n",
|
3199 |
+
"\n",
|
3200 |
+
"No recipes found for query vegan tofu peppers carrots apples bananas kale.\n",
|
3201 |
+
"This usually occurs when there are too many keywords or ingredients that are not commonly found together in recipes.\n",
|
3202 |
+
"I recommend trying again with `vegan tofu peppers carrots apples bananas.`\n",
|
3203 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'vegan tofu peppers carrots apples bananas'}`\n",
|
3204 |
+
"\n",
|
3205 |
+
"\n",
|
3206 |
+
"No recipes found for query vegan tofu peppers carrots apples bananas.\n",
|
3207 |
+
"This usually occurs when there are too many keywords or ingredients that are not commonly found together in recipes.\n",
|
3208 |
+
"I recommend trying again with `vegan tofu peppers carrots apples.`\n",
|
3209 |
+
"Invoking: `vegan_recipe_edamam_search` with `{'query': 'vegan tofu peppers carrots apples'}`\n",
|
3210 |
+
"\n",
|
3211 |
+
"\n",
|
3212 |
+
"[{'label': 'Peanut Tofu Stir Fry (Vegan + GF)', 'url': 'http://www.rhiansrecipes.com/2015/12/21/peanut-tofu-stir-fry-vegan-gf/', 'ingredientLines': ['* 2 tablespoon oil (coconut, vegetable or rapeseed), for frying', '* 400 g (14oz) hard, firm tofu', '* 1 red onion, finely sliced', '* 1 carrot, peeled and finely sliced', '* 200 g (7oz) french bean, trimmed and cut in 1/2', '* 1 sweet red pepper, finely sliced', 'for the marinade', '* 2 tablespoon peanut butter', '* 2 tablespoon sweet chilli sauce (you can substitute with chilli and', \"sugar if you don't have thi)\", '* 3 tablespoon soy sauce', '* 2 tablespoon vinegar (rice or apple cider)'], 'totalTime': 0.0}, {'label': 'Vegan Wasabi Slaw', 'url': 'http://kblog.lunchboxbunch.com/2011/07/vegan-wasabi-slaw.html', 'ingredientLines': ['2+ Tbsp wasabi powder', '2 Tbsp grape seed oil', '16 ounces silken tofu', '2-3 Tbsp apple cider vinegar', '1 1/2 Tbsp maple syrup', '2 Tbsp tamari', '1/4 tsp pepper', '2 tsp garlic powder', \"1 Tbsp dried parsley flaves (opt'l)\", \"sea salt (opt'l to taste)\", '1 bad (12 ounces) Brocco Slaw', '1-2 cups shredded carrots', \"1 green apple, shredded (opt'l)\", \"1/2 cup hemp or sunflower seeds (opt'l)\"], 'totalTime': 0.0}, {'label': 'Spicy Salad with Tahini Dressing', 'url': 'http://nimailarson.com/spicy-salad-with-tahini-dressing/', 'ingredientLines': ['2 handfuls of Arugula', '7 Oz Firm Tofu (half a block)', '1/2 Cucumber', '1/4 White Onion', '4 Radishes', '1/4 Cup Sunflower Seeds', '1/4 Cup Nutritional Yeast', '3 Tablespoons Soy Sauce', '1/4 Cup Water', '2 Tablespoons Tahini', '1 Tablespoon Olive Oil', '1 Tablespoon Apple Cider Vinegar', '1 Clove of Garlic', 'Salt, Black Pepper, Turmeric', 'Optional fun toppings: Daiya Vegan Cheese, Avocado, Sprouts, Shredded Carrot or Beetroot'], 'totalTime': 0.0}]I found some delicious vegan recipes for you to try with the ingredients you have:\n",
|
3213 |
+
"\n",
|
3214 |
+
"1. [Peanut Tofu Stir Fry (Vegan + GF)](http://www.rhiansrecipes.com/2015/12/21/peanut-tofu-stir-fry-vegan-gf/)\n",
|
3215 |
+
" - Ingredients: oil, tofu, red onion, carrot, french bean, sweet red pepper, peanut butter, sweet chilli sauce, soy sauce, vinegar\n",
|
3216 |
+
" - Total Time: Not specified\n",
|
3217 |
+
"\n",
|
3218 |
+
"2. [Vegan Wasabi Slaw](http://kblog.lunchboxbunch.com/2011/07/vegan-wasabi-slaw.html)\n",
|
3219 |
+
" - Ingredients: wasabi powder, grape seed oil, silken tofu, apple cider vinegar, maple syrup, tamari, pepper, garlic powder, dried parsley flakes, sea salt, Brocco Slaw, shredded carrots, green apple, hemp or sunflower seeds\n",
|
3220 |
+
" - Total Time: Not specified\n",
|
3221 |
+
"\n",
|
3222 |
+
"3. [Spicy Salad with Tahini Dressing](http://nimailarson.com/spicy-salad-with-tahini-dressing/)\n",
|
3223 |
+
" - Ingredients: arugula, firm tofu, cucumber, white onion, radishes, sunflower seeds, nutritional yeast, soy sauce, water, tahini, olive oil, apple cider vinegar, garlic, salt, black pepper, turmeric\n",
|
3224 |
+
" - Total Time: Not specified\n",
|
3225 |
+
"\n",
|
3226 |
+
"Feel free to click on the recipe links for more details and instructions. Enjoy your cooking!\n",
|
3227 |
"\n",
|
3228 |
"> Finished chain.\n"
|
3229 |
]
|
|
|
3231 |
{
|
3232 |
"data": {
|
3233 |
"text/plain": [
|
3234 |
+
"'I found some delicious vegan recipes for you to try with the ingredients you have:\\n\\n1. [Peanut Tofu Stir Fry (Vegan + GF)](http://www.rhiansrecipes.com/2015/12/21/peanut-tofu-stir-fry-vegan-gf/)\\n - Ingredients: oil, tofu, red onion, carrot, french bean, sweet red pepper, peanut butter, sweet chilli sauce, soy sauce, vinegar\\n - Total Time: Not specified\\n\\n2. [Vegan Wasabi Slaw](http://kblog.lunchboxbunch.com/2011/07/vegan-wasabi-slaw.html)\\n - Ingredients: wasabi powder, grape seed oil, silken tofu, apple cider vinegar, maple syrup, tamari, pepper, garlic powder, dried parsley flakes, sea salt, Brocco Slaw, shredded carrots, green apple, hemp or sunflower seeds\\n - Total Time: Not specified\\n\\n3. [Spicy Salad with Tahini Dressing](http://nimailarson.com/spicy-salad-with-tahini-dressing/)\\n - Ingredients: arugula, firm tofu, cucumber, white onion, radishes, sunflower seeds, nutritional yeast, soy sauce, water, tahini, olive oil, apple cider vinegar, garlic, salt, black pepper, turmeric\\n - Total Time: Not specified\\n\\nFeel free to click on the recipe links for more details and instructions. Enjoy your cooking!'"
|
3235 |
]
|
3236 |
},
|
3237 |
"execution_count": null,
|
|
|
3318 |
}
|
3319 |
],
|
3320 |
"source": [
|
3321 |
+
"#| eval: false\n",
|
3322 |
"vegan_recipe_edamam_search(\"Tofu Stir-Fry\")"
|
3323 |
]
|
3324 |
},
|
_proc/_docs/app.html
CHANGED
@@ -161,8 +161,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
161 |
</li>
|
162 |
<li class="sidebar-item">
|
163 |
<div class="sidebar-item-container">
|
164 |
-
<a href="./
|
165 |
-
<span class="menu-text">
|
166 |
</div>
|
167 |
</li>
|
168 |
<li class="sidebar-item">
|
@@ -170,12 +170,6 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
170 |
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link">
|
171 |
<span class="menu-text">ingredient_vision</span></a>
|
172 |
</div>
|
173 |
-
</li>
|
174 |
-
<li class="sidebar-item">
|
175 |
-
<div class="sidebar-item-container">
|
176 |
-
<a href="./edamam_api.html" class="sidebar-item-text sidebar-link">
|
177 |
-
<span class="menu-text">edamam_api</span></a>
|
178 |
-
</div>
|
179 |
</li>
|
180 |
</ul>
|
181 |
</div>
|
@@ -187,8 +181,14 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
187 |
<h2 id="toc-title">On this page</h2>
|
188 |
|
189 |
<ul>
|
190 |
-
<li><a href="#
|
|
|
|
|
|
|
|
|
|
|
191 |
<li><a href="#create_demo" id="toc-create_demo" class="nav-link" data-scroll-target="#create_demo">create_demo</a></li>
|
|
|
192 |
</ul>
|
193 |
<div class="toc-actions"><div><i class="bi bi-git"></i></div><div class="action-links"><p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
|
194 |
</div>
|
@@ -218,40 +218,161 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
218 |
</header>
|
219 |
|
220 |
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
<hr>
|
222 |
-
<
|
223 |
-
<
|
224 |
-
<h3 class="anchored" data-anchor-id="conversationbot">ConversationBot</h3>
|
225 |
<blockquote class="blockquote">
|
226 |
-
<pre><code>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
</blockquote>
|
228 |
-
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
<div class="cell">
|
230 |
-
<div class="sourceCode cell-code" id="
|
231 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>SAMPLE_IMG_DIR</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
232 |
<div class="cell-output cell-output-display">
|
233 |
-
<pre><code>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
</div>
|
235 |
</div>
|
236 |
<div class="cell">
|
237 |
-
<div class="sourceCode cell-code" id="
|
|
|
|
|
238 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
<div class="cell">
|
240 |
-
<div class="sourceCode cell-code" id="
|
241 |
-
<span id="
|
242 |
<div class="cell-output cell-output-display">
|
243 |
-
<pre><code>
|
244 |
</div>
|
245 |
</div>
|
246 |
<div class="cell">
|
247 |
-
<div class="sourceCode cell-code" id="
|
248 |
<div class="cell-output cell-output-stdout">
|
249 |
<pre><code>CPU times: user 6.19 s, sys: 1.47 s, total: 7.66 s
|
250 |
Wall time: 4.68 s</code></pre>
|
251 |
</div>
|
252 |
</div>
|
253 |
<div class="cell">
|
254 |
-
<div class="sourceCode cell-code" id="
|
255 |
<div class="cell-output cell-output-stdout">
|
256 |
<pre><code>I uploaded an image that may contain vegan ingredients.
|
257 |
The description of the image is: `a refrigerator with food inside`.
|
@@ -268,7 +389,7 @@ Wall time: 5.95 s</code></pre>
|
|
268 |
</div>
|
269 |
</div>
|
270 |
<hr>
|
271 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/app.py#
|
272 |
</section>
|
273 |
<section id="create_demo" class="level3">
|
274 |
<h3 class="anchored" data-anchor-id="create_demo">create_demo</h3>
|
@@ -276,10 +397,10 @@ Wall time: 5.95 s</code></pre>
|
|
276 |
<pre><code> create_demo (bot=<class '__main__.ConversationBot'>)</code></pre>
|
277 |
</blockquote>
|
278 |
<div class="cell">
|
279 |
-
<div class="sourceCode cell-code" id="
|
280 |
-
<span id="
|
281 |
-
<span id="
|
282 |
-
<span id="
|
283 |
<div class="cell-output cell-output-stdout">
|
284 |
<pre><code>Closing server running on port: 7860
|
285 |
Running on local URL: http://127.0.0.1:7860
|
@@ -295,6 +416,7 @@ To create a public link, set `share=True` in `launch()`.</code></pre>
|
|
295 |
</div>
|
296 |
|
297 |
|
|
|
298 |
</section>
|
299 |
|
300 |
</main> <!-- /main -->
|
|
|
161 |
</li>
|
162 |
<li class="sidebar-item">
|
163 |
<div class="sidebar-item-container">
|
164 |
+
<a href="./vegan_recipe_tools.html" class="sidebar-item-text sidebar-link">
|
165 |
+
<span class="menu-text">vegan_recipe_tools</span></a>
|
166 |
</div>
|
167 |
</li>
|
168 |
<li class="sidebar-item">
|
|
|
170 |
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link">
|
171 |
<span class="menu-text">ingredient_vision</span></a>
|
172 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
</li>
|
174 |
</ul>
|
175 |
</div>
|
|
|
181 |
<h2 id="toc-title">On this page</h2>
|
182 |
|
183 |
<ul>
|
184 |
+
<li><a href="#put-the-chat-backend-pieces-together" id="toc-put-the-chat-backend-pieces-together" class="nav-link active" data-scroll-target="#put-the-chat-backend-pieces-together">Put the chat backend pieces together</a>
|
185 |
+
<ul class="collapse">
|
186 |
+
<li><a href="#conversationbuffermemory" id="toc-conversationbuffermemory" class="nav-link" data-scroll-target="#conversationbuffermemory">ConversationBufferMemory</a></li>
|
187 |
+
<li><a href="#chatmessagehistory" id="toc-chatmessagehistory" class="nav-link" data-scroll-target="#chatmessagehistory">ChatMessageHistory</a></li>
|
188 |
+
<li><a href="#chatopenai" id="toc-chatopenai" class="nav-link" data-scroll-target="#chatopenai">ChatOpenAI</a></li>
|
189 |
+
<li><a href="#conversationbot" id="toc-conversationbot" class="nav-link" data-scroll-target="#conversationbot">ConversationBot</a></li>
|
190 |
<li><a href="#create_demo" id="toc-create_demo" class="nav-link" data-scroll-target="#create_demo">create_demo</a></li>
|
191 |
+
</ul></li>
|
192 |
</ul>
|
193 |
<div class="toc-actions"><div><i class="bi bi-git"></i></div><div class="action-links"><p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
|
194 |
</div>
|
|
|
218 |
</header>
|
219 |
|
220 |
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
221 |
+
<div class="cell">
|
222 |
+
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> dotenv <span class="im">import</span> load_dotenv</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
223 |
+
</div>
|
224 |
+
<div class="cell">
|
225 |
+
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">#: eval: false</span></span>
|
226 |
+
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>load_dotenv()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
227 |
+
<div class="cell-output cell-output-display">
|
228 |
+
<pre><code>True</code></pre>
|
229 |
+
</div>
|
230 |
+
</div>
|
231 |
+
<section id="put-the-chat-backend-pieces-together" class="level2">
|
232 |
+
<h2 class="anchored" data-anchor-id="put-the-chat-backend-pieces-together">Put the chat backend pieces together</h2>
|
233 |
<hr>
|
234 |
+
<section id="conversationbuffermemory" class="level3">
|
235 |
+
<h3 class="anchored" data-anchor-id="conversationbuffermemory">ConversationBufferMemory</h3>
|
|
|
236 |
<blockquote class="blockquote">
|
237 |
+
<pre><code> ConversationBufferMemory
|
238 |
+
(chat_memory:langchain.schema.memory.BaseChatMe
|
239 |
+
ssageHistory=None,
|
240 |
+
output_key:Optional[str]=None,
|
241 |
+
input_key:Optional[str]=None,
|
242 |
+
return_messages:bool=False,
|
243 |
+
human_prefix:str='Human', ai_prefix:str='AI',
|
244 |
+
memory_key:str='history')</code></pre>
|
245 |
</blockquote>
|
246 |
+
<p>Buffer for storing conversation memory.</p>
|
247 |
+
<hr>
|
248 |
+
</section>
|
249 |
+
<section id="chatmessagehistory" class="level3">
|
250 |
+
<h3 class="anchored" data-anchor-id="chatmessagehistory">ChatMessageHistory</h3>
|
251 |
+
<blockquote class="blockquote">
|
252 |
+
<pre><code> ChatMessageHistory
|
253 |
+
(messages:List[langchain.schema.messages.BaseMessage]
|
254 |
+
=[])</code></pre>
|
255 |
+
</blockquote>
|
256 |
+
<p>In memory implementation of chat message history.</p>
|
257 |
+
<p>Stores messages in an in memory list.</p>
|
258 |
+
<hr>
|
259 |
+
</section>
|
260 |
+
<section id="chatopenai" class="level3">
|
261 |
+
<h3 class="anchored" data-anchor-id="chatopenai">ChatOpenAI</h3>
|
262 |
+
<blockquote class="blockquote">
|
263 |
+
<pre><code> ChatOpenAI (cache:Optional[bool]=None, verbose:bool=None, callbacks:Union
|
264 |
+
[List[langchain.callbacks.base.BaseCallbackHandler],langchain
|
265 |
+
.callbacks.base.BaseCallbackManager,NoneType]=None, callback_
|
266 |
+
manager:Optional[langchain.callbacks.base.BaseCallbackManager
|
267 |
+
]=None, tags:Optional[List[str]]=None,
|
268 |
+
metadata:Optional[Dict[str,Any]]=None, client:Any=None,
|
269 |
+
model:str='gpt-3.5-turbo', temperature:float=0.7,
|
270 |
+
model_kwargs:Dict[str,Any]=None,
|
271 |
+
openai_api_key:Optional[str]=None,
|
272 |
+
openai_api_base:Optional[str]=None,
|
273 |
+
openai_organization:Optional[str]=None,
|
274 |
+
openai_proxy:Optional[str]=None, request_timeout:Union[float,
|
275 |
+
Tuple[float,float],NoneType]=None, max_retries:int=6,
|
276 |
+
streaming:bool=False, n:int=1, max_tokens:Optional[int]=None,
|
277 |
+
tiktoken_model_name:Optional[str]=None)</code></pre>
|
278 |
+
</blockquote>
|
279 |
+
<p>Wrapper around OpenAI Chat large language models.</p>
|
280 |
+
<p>To use, you should have the <code>openai</code> python package installed, and the environment variable <code>OPENAI_API_KEY</code> set with your API key.</p>
|
281 |
+
<p>Any parameters that are valid to be passed to the openai.create call can be passed in, even if not explicitly saved on this class.</p>
|
282 |
+
<p>Example: .. code-block:: python</p>
|
283 |
+
<pre><code> from langchain.chat_models import ChatOpenAI
|
284 |
+
openai = ChatOpenAI(model_name="gpt-3.5-turbo")</code></pre>
|
285 |
+
<div class="cell">
|
286 |
+
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>llm <span class="op">=</span> ChatOpenAI(temperature<span class="op">=</span><span class="dv">1</span>)</span>
|
287 |
+
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>MEMORY_KEY <span class="op">=</span> <span class="st">"chat_history"</span></span>
|
288 |
+
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>chat_msgs <span class="op">=</span> INIT_PROMPT.format_prompt(</span>
|
289 |
+
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> ingredients<span class="op">=</span><span class="st">"tofu, pickles, mustard, olives, tomatoes, lettuce, bell peppers, carrots, bread"</span>,</span>
|
290 |
+
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> allergies<span class="op">=</span><span class="st">""</span>,</span>
|
291 |
+
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> recipe_freeform_input<span class="op">=</span><span class="st">"The preparation time shVegan spaghetti aglio e olio ould be less than 30 minutes. I really love Thai food!"</span>,</span>
|
292 |
+
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a>)</span>
|
293 |
+
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a>chat_msgs <span class="op">=</span> chat_msgs.to_messages()</span>
|
294 |
+
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a>results <span class="op">=</span> llm.generate([chat_msgs])</span>
|
295 |
+
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a></span>
|
296 |
+
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a>chat_msgs.append(results.generations[<span class="dv">0</span>][<span class="dv">0</span>].message)</span>
|
297 |
+
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a>tools <span class="op">=</span> [vegan_recipe_edamam_search]</span>
|
298 |
+
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a>prompt <span class="op">=</span> OpenAIFunctionsAgent.create_prompt(</span>
|
299 |
+
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a> system_message<span class="op">=</span>INIT_PROMPT.messages[<span class="dv">0</span>],</span>
|
300 |
+
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a> extra_prompt_messages<span class="op">=</span>chat_msgs <span class="op">+</span> [MessagesPlaceholder(variable_name<span class="op">=</span>MEMORY_KEY)],</span>
|
301 |
+
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a>)</span>
|
302 |
+
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a>memory <span class="op">=</span> ConversationBufferMemory(</span>
|
303 |
+
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a> chat_memory<span class="op">=</span>ChatMessageHistory(messages<span class="op">=</span>chat_msgs),</span>
|
304 |
+
<span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a> return_messages<span class="op">=</span><span class="va">True</span>,</span>
|
305 |
+
<span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a> memory_key<span class="op">=</span>MEMORY_KEY,</span>
|
306 |
+
<span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a>)</span>
|
307 |
+
<span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a>agent_executor <span class="op">=</span> AgentExecutor(</span>
|
308 |
+
<span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a> agent<span class="op">=</span>OpenAIFunctionsAgent(llm<span class="op">=</span>llm, tools<span class="op">=</span>tools, prompt<span class="op">=</span>prompt),</span>
|
309 |
+
<span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a> tools<span class="op">=</span>tools,</span>
|
310 |
+
<span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a> memory<span class="op">=</span>memory,</span>
|
311 |
+
<span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a> verbose<span class="op">=</span><span class="va">True</span>,</span>
|
312 |
+
<span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
313 |
+
</div>
|
314 |
<div class="cell">
|
315 |
+
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>memory.chat_memory.messages</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
316 |
<div class="cell-output cell-output-display">
|
317 |
+
<pre><code>[SystemMessage(content='The following is a conversation between a human and a friendly vegan AI. \nThe AI is compassionate to animals and therefore serves to promote veganism.\nKnowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\nIf the human messages are not aligned with veganism, remind them of your purpose.\nThe AI never generates vegan recipes itself but instead uses a tool.', additional_kwargs={}),
|
318 |
+
AIMessage(content='What ingredients do you wish to cook with?', additional_kwargs={}, example=False),
|
319 |
+
HumanMessage(content='Ingredients: tofu, pickles, mustard, olives, tomatoes, lettuce, bell peppers, carrots, bread', additional_kwargs={}, example=False),
|
320 |
+
AIMessage(content='Do you have any allergies I should be aware of?', additional_kwargs={}, example=False),
|
321 |
+
HumanMessage(content='Allergies: ', additional_kwargs={}, example=False),
|
322 |
+
AIMessage(content='Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?', additional_kwargs={}, example=False),
|
323 |
+
HumanMessage(content="Preferences: `The preparation time shVegan spaghetti aglio e olio ould be less than 30 minutes. I really love Thai food!`\nYour task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.\nThink step by step.\n\n1. If the user listed any ingredients, choose the three ingredients that are most commonly used together in recipes that fall within the user's preferences (if any are included). \n2. If the user provided any allergies, include them in the query.\nFormat your response as message with the allergy and diet preferences first and then the ingredients.\nExamples:\n'Vegan gluten-free chicken peppers' or 'Vegan tofu, brocolli, and miso'", additional_kwargs={}, example=False),
|
324 |
+
AIMessage(content='Vegan, quick, Thai tofu, bell peppers', additional_kwargs={}, example=False)]</code></pre>
|
325 |
+
</div>
|
326 |
+
</div>
|
327 |
+
<div class="cell">
|
328 |
+
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>agent_executor.run(<span class="st">"Search for vegan recipe"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
329 |
+
<div class="cell-output cell-output-stdout">
|
330 |
+
<pre><code>
|
331 |
+
|
332 |
+
> Entering new AgentExecutor chain...
|
333 |
+
|
334 |
+
Invoking: `vegan_recipe_edamam_search` with `{'query': 'Tofu pickle sandwich with Thai-inspired flavors'}`
|
335 |
+
|
336 |
+
|
337 |
+
[]I apologize, but I couldn't find any vegan recipes matching your query. Can I help you with anything else?
|
338 |
+
|
339 |
+
> Finished chain.</code></pre>
|
340 |
+
</div>
|
341 |
+
<div class="cell-output cell-output-display">
|
342 |
+
<pre><code>"I apologize, but I couldn't find any vegan recipes matching your query. Can I help you with anything else?"</code></pre>
|
343 |
</div>
|
344 |
</div>
|
345 |
<div class="cell">
|
346 |
+
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>agent_executor.run(<span class="st">"Which ingredients that I provided go the best together in dishes?"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
347 |
+
<div class="cell-output cell-output-error">
|
348 |
+
<pre><code>NameError: name 'agent_executor' is not defined</code></pre>
|
349 |
</div>
|
350 |
+
</div>
|
351 |
+
<hr>
|
352 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/app.py#L42" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
353 |
+
</section>
|
354 |
+
<section id="conversationbot" class="level3">
|
355 |
+
<h3 class="anchored" data-anchor-id="conversationbot">ConversationBot</h3>
|
356 |
+
<blockquote class="blockquote">
|
357 |
+
<pre><code> ConversationBot (verbose=True)</code></pre>
|
358 |
+
</blockquote>
|
359 |
+
<p>Initialize self. See help(type(self)) for accurate signature.</p>
|
360 |
<div class="cell">
|
361 |
+
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>os.listdir(SAMPLE_IMG_DIR)</span>
|
362 |
+
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>SAMPLE_IMG_DIR</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
363 |
<div class="cell-output cell-output-display">
|
364 |
+
<pre><code>Path('/home/evylz/AnimalEquality/lv-recipe-chatbot/assets/images/vegan_ingredients')</code></pre>
|
365 |
</div>
|
366 |
</div>
|
367 |
<div class="cell">
|
368 |
+
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
369 |
<div class="cell-output cell-output-stdout">
|
370 |
<pre><code>CPU times: user 6.19 s, sys: 1.47 s, total: 7.66 s
|
371 |
Wall time: 4.68 s</code></pre>
|
372 |
</div>
|
373 |
</div>
|
374 |
<div class="cell">
|
375 |
+
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
376 |
<div class="cell-output cell-output-stdout">
|
377 |
<pre><code>I uploaded an image that may contain vegan ingredients.
|
378 |
The description of the image is: `a refrigerator with food inside`.
|
|
|
389 |
</div>
|
390 |
</div>
|
391 |
<hr>
|
392 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/app.py#L126" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
393 |
</section>
|
394 |
<section id="create_demo" class="level3">
|
395 |
<h3 class="anchored" data-anchor-id="create_demo">create_demo</h3>
|
|
|
397 |
<pre><code> create_demo (bot=<class '__main__.ConversationBot'>)</code></pre>
|
398 |
</blockquote>
|
399 |
<div class="cell">
|
400 |
+
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="st">"demo"</span> <span class="kw">in</span> <span class="bu">globals</span>():</span>
|
401 |
+
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a> demo.close()</span>
|
402 |
+
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a>demo <span class="op">=</span> create_demo(bot)</span>
|
403 |
+
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a>demo.launch()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
404 |
<div class="cell-output cell-output-stdout">
|
405 |
<pre><code>Closing server running on port: 7860
|
406 |
Running on local URL: http://127.0.0.1:7860
|
|
|
416 |
</div>
|
417 |
|
418 |
|
419 |
+
</section>
|
420 |
</section>
|
421 |
|
422 |
</main> <!-- /main -->
|
_proc/_docs/engineer_prompt.html
CHANGED
@@ -126,7 +126,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
126 |
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
127 |
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
128 |
</button>
|
129 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item">engineer_prompt</li></ol></nav>
|
130 |
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
131 |
</a>
|
132 |
</div>
|
@@ -136,11 +136,51 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
136 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
|
137 |
<!-- sidebar -->
|
138 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
</nav>
|
140 |
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
141 |
<!-- margin-sidebar -->
|
142 |
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
</div>
|
145 |
<!-- main -->
|
146 |
<main class="content" id="quarto-document-content">
|
@@ -168,148 +208,108 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
168 |
</header>
|
169 |
|
170 |
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
|
|
|
|
|
171 |
<p>Setup env</p>
|
172 |
<div class="cell">
|
173 |
-
<div class="sourceCode cell-code" id="
|
174 |
</div>
|
175 |
<div class="cell">
|
176 |
-
<div class="sourceCode cell-code" id="
|
177 |
<div class="cell-output cell-output-display">
|
178 |
<pre><code>True</code></pre>
|
179 |
</div>
|
180 |
</div>
|
181 |
<p>Evaluate chat backend</p>
|
182 |
<div class="cell">
|
183 |
-
<div class="sourceCode cell-code" id="
|
184 |
-
<span id="
|
185 |
-
<span id="
|
186 |
-
<span id="
|
187 |
-
<span id="
|
188 |
-
<span id="
|
189 |
-
<span id="
|
190 |
-
<span id="
|
191 |
-
<span id="
|
192 |
-
<span id="
|
193 |
-
<span id="
|
194 |
-
<span id="
|
195 |
-
<span id="
|
196 |
-
<span id="
|
197 |
-
<span id="
|
198 |
-
<span id="
|
199 |
-
<span id="
|
200 |
-
<span id="
|
201 |
-
<span id="
|
202 |
-
<span id="
|
203 |
-
<span id="
|
204 |
-
<span id="
|
205 |
-
<
|
206 |
-
<
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
<div class="cell-output cell-output-stdout">
|
213 |
<pre><code>
|
214 |
|
215 |
> Entering new ConversationChain chain...
|
216 |
Prompt after formatting:
|
217 |
-
System: The following is a conversation between a human and a friendly AI
|
218 |
-
The AI is compassionate to animals and
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
Let's think step by step.
|
223 |
-
If the human messages are unrelated to vegan recipes, remind them of your purpose to recommend vegan recipes.
|
224 |
AI: What ingredients do you wish to cook with?
|
225 |
Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread
|
226 |
AI: Do you have any allergies I should be aware of?
|
227 |
Human: Allergies:
|
228 |
AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?
|
229 |
-
Human:
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
Ingredients (List of ingredients with quantities):
|
243 |
-
- <quantity and unit> <ingredient>
|
244 |
-
|
245 |
-
Steps (detailed):
|
246 |
-
1.
|
247 |
-
2.
|
248 |
-
3.
|
249 |
-
...
|
250 |
-
AI: Here is a Thai-inspired vegan recipe for you:
|
251 |
-
|
252 |
-
**Thai Tofu Lettuce Wraps**
|
253 |
-
Preparation time: Less than 30 minutes
|
254 |
-
|
255 |
-
Ingredients:
|
256 |
-
- 1/2 block of firm tofu, crumbled
|
257 |
-
- 1/4 cup pickles, chopped
|
258 |
-
- 1/4 cup olives, sliced
|
259 |
-
- 1/2 bell pepper, sliced
|
260 |
-
- 1/2 carrot, finely chopped
|
261 |
-
- 4-6 lettuce leaves
|
262 |
-
- 2 tablespoons soy sauce
|
263 |
-
- 1 tablespoon rice vinegar
|
264 |
-
- 1 tablespoon agave nectar
|
265 |
-
- 1/2 tablespoon garlic powder
|
266 |
-
- 1/2 tablespoon onion powder
|
267 |
-
- 1/2 teaspoon dried basil
|
268 |
-
- 1/2 teaspoon dried oregano
|
269 |
-
- 1/2 teaspoon salt
|
270 |
-
- 1/4 teaspoon black pepper
|
271 |
-
- 4-6 slices of bread, toasted
|
272 |
-
|
273 |
-
Steps:
|
274 |
-
1. In a large bowl, combine crumbled tofu, pickles, olives, bell pepper, and carrot.
|
275 |
-
2. In a small bowl, whisk together soy sauce, rice vinegar, agave nectar, garlic powder, onion powder, basil, oregano, salt, and black pepper.
|
276 |
-
3. Pour the dressing over the tofu mixture, and stir until everything is coated.
|
277 |
-
4. Place a spoonful of the tofu mixture into each lettuce leaf, and serve with a slice of toasted bread.
|
278 |
-
Human: Recommend a different recipe please.
|
279 |
|
280 |
> Finished chain.
|
281 |
-
|
282 |
-
|
283 |
-
**Vegan Mediterranean Tofu Sandwich**
|
284 |
-
Preparation time: Less than 30 minutes
|
285 |
-
|
286 |
-
Ingredients:
|
287 |
-
- 1/2 block of firm tofu, sliced
|
288 |
-
- 2 teaspoons olive oil
|
289 |
-
- 1/2 teaspoon dried oregano
|
290 |
-
- 1/2 teaspoon dried basil
|
291 |
-
- Salt and pepper to taste
|
292 |
-
- 2 slices of bread
|
293 |
-
- 1/4 cup hummus
|
294 |
-
- 2-3 lettuce leaves
|
295 |
-
- 1/4 cup sliced tomatoes
|
296 |
-
- 1/4 cup sliced bell peppers
|
297 |
-
- 1/4 cup grated carrot
|
298 |
-
|
299 |
-
Steps:
|
300 |
-
1. Preheat the oven to 375°F.
|
301 |
-
2. In a small bowl, mix olive oil, oregano, basil, salt, and pepper, and place tofu slices on a baking sheet. Brush tofu with the olive oil mixture, covering both sides.
|
302 |
-
3. Place the baking sheet in the oven and bake the tofu for 15 minutes, flipping the slices halfway through.
|
303 |
-
4. Toast the bread slices.
|
304 |
-
5. Spread the hummus on one slice of bread, and layer lettuce, tomatoes, bell peppers, grated carrot, and baked tofu on top. Top with the other slice of bread.
|
305 |
-
6. Slice the sandwich in half, and enjoy!</code></pre>
|
306 |
</div>
|
307 |
</div>
|
308 |
<div class="cell">
|
309 |
-
<div class="sourceCode cell-code" id="
|
|
|
|
|
|
|
310 |
</div>
|
311 |
|
312 |
|
|
|
313 |
|
314 |
</main> <!-- /main -->
|
315 |
<script id="quarto-html-after-body" type="application/javascript">
|
@@ -549,4 +549,4 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
|
|
549 |
|
550 |
|
551 |
|
552 |
-
|
|
|
126 |
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
127 |
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
128 |
</button>
|
129 |
+
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./engineer_prompt.html">engineer_prompt</a></li></ol></nav>
|
130 |
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
131 |
</a>
|
132 |
</div>
|
|
|
136 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
|
137 |
<!-- sidebar -->
|
138 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
|
139 |
+
<div class="sidebar-menu-container">
|
140 |
+
<ul class="list-unstyled mt-1">
|
141 |
+
<li class="sidebar-item">
|
142 |
+
<div class="sidebar-item-container">
|
143 |
+
<a href="./index.html" class="sidebar-item-text sidebar-link">
|
144 |
+
<span class="menu-text">lv-recipe-chatbot</span></a>
|
145 |
+
</div>
|
146 |
+
</li>
|
147 |
+
<li class="sidebar-item">
|
148 |
+
<div class="sidebar-item-container">
|
149 |
+
<a href="./engineer_prompt.html" class="sidebar-item-text sidebar-link active">
|
150 |
+
<span class="menu-text">engineer_prompt</span></a>
|
151 |
+
</div>
|
152 |
+
</li>
|
153 |
+
<li class="sidebar-item">
|
154 |
+
<div class="sidebar-item-container">
|
155 |
+
<a href="./app.html" class="sidebar-item-text sidebar-link">
|
156 |
+
<span class="menu-text">app</span></a>
|
157 |
+
</div>
|
158 |
+
</li>
|
159 |
+
<li class="sidebar-item">
|
160 |
+
<div class="sidebar-item-container">
|
161 |
+
<a href="./vegan_recipe_tools.html" class="sidebar-item-text sidebar-link">
|
162 |
+
<span class="menu-text">vegan_recipe_tools</span></a>
|
163 |
+
</div>
|
164 |
+
</li>
|
165 |
+
<li class="sidebar-item">
|
166 |
+
<div class="sidebar-item-container">
|
167 |
+
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link">
|
168 |
+
<span class="menu-text">ingredient_vision</span></a>
|
169 |
+
</div>
|
170 |
+
</li>
|
171 |
+
</ul>
|
172 |
+
</div>
|
173 |
</nav>
|
174 |
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
|
175 |
<!-- margin-sidebar -->
|
176 |
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
177 |
+
<nav id="TOC" role="doc-toc" class="toc-active">
|
178 |
+
<h2 id="toc-title">On this page</h2>
|
179 |
+
|
180 |
+
<ul>
|
181 |
+
<li><a href="#test-with-vegan-recipe-search-tool" id="toc-test-with-vegan-recipe-search-tool" class="nav-link active" data-scroll-target="#test-with-vegan-recipe-search-tool">Test with vegan recipe search tool</a></li>
|
182 |
+
</ul>
|
183 |
+
<div class="toc-actions"><div><i class="bi bi-git"></i></div><div class="action-links"><p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/issues/new" class="toc-action">Report an issue</a></p></div></div></nav>
|
184 |
</div>
|
185 |
<!-- main -->
|
186 |
<main class="content" id="quarto-document-content">
|
|
|
208 |
</header>
|
209 |
|
210 |
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
211 |
+
<div class="cell">
|
212 |
+
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> lv_recipe_chatbot.vegan_recipe_tools <span class="im">import</span> vegan_recipe_edamam_search</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
213 |
+
</div>
|
214 |
<p>Setup env</p>
|
215 |
<div class="cell">
|
216 |
+
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> dotenv <span class="im">import</span> load_dotenv</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
217 |
</div>
|
218 |
<div class="cell">
|
219 |
+
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>load_dotenv()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
220 |
<div class="cell-output cell-output-display">
|
221 |
<pre><code>True</code></pre>
|
222 |
</div>
|
223 |
</div>
|
224 |
<p>Evaluate chat backend</p>
|
225 |
<div class="cell">
|
226 |
+
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>chat <span class="op">=</span> PromptLayerChatOpenAI(temperature<span class="op">=</span><span class="fl">0.6</span>, pl_tags<span class="op">=</span>[<span class="st">"langchain"</span>], return_pl_id<span class="op">=</span><span class="va">True</span>)</span>
|
227 |
+
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>memory <span class="op">=</span> ConversationBufferMemory(return_messages<span class="op">=</span><span class="va">True</span>)</span>
|
228 |
+
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>chat_msgs <span class="op">=</span> INIT_PROMPT.format_prompt(</span>
|
229 |
+
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> ingredients<span class="op">=</span><span class="st">"tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread"</span>,</span>
|
230 |
+
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> allergies<span class="op">=</span><span class="st">""</span>,</span>
|
231 |
+
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> recipe_freeform_input<span class="op">=</span><span class="st">"The preparation time should be less than 30 minutes. I really love Thai food!"</span>,</span>
|
232 |
+
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>)</span>
|
233 |
+
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a></span>
|
234 |
+
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a>chat_msgs <span class="op">=</span> chat_msgs.to_messages()</span>
|
235 |
+
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a>results <span class="op">=</span> chat.generate([chat_msgs])</span>
|
236 |
+
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a>chat_msgs.extend(</span>
|
237 |
+
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a> [</span>
|
238 |
+
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a> results.generations[<span class="dv">0</span>][<span class="dv">0</span>].message,</span>
|
239 |
+
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a> MessagesPlaceholder(variable_name<span class="op">=</span><span class="st">"history"</span>),</span>
|
240 |
+
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a> HumanMessagePromptTemplate.from_template(<span class="st">"</span><span class="sc">{input}</span><span class="st">"</span>),</span>
|
241 |
+
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a> ]</span>
|
242 |
+
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a>)</span>
|
243 |
+
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a>open_prompt <span class="op">=</span> ChatPromptTemplate.from_messages(chat_msgs)</span>
|
244 |
+
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a>conversation <span class="op">=</span> ConversationChain(</span>
|
245 |
+
<span id="cb5-20"><a href="#cb5-20" aria-hidden="true" tabindex="-1"></a> llm<span class="op">=</span>chat, verbose<span class="op">=</span><span class="va">True</span>, memory<span class="op">=</span>memory, prompt<span class="op">=</span>open_prompt</span>
|
246 |
+
<span id="cb5-21"><a href="#cb5-21" aria-hidden="true" tabindex="-1"></a>)</span>
|
247 |
+
<span id="cb5-22"><a href="#cb5-22" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(results.generations[<span class="dv">0</span>][<span class="dv">0</span>].message)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
248 |
+
<div class="cell-output cell-output-stdout">
|
249 |
+
<pre><code>content='Vegan, Thai, tofu, bell peppers, carrots' additional_kwargs={} example=False</code></pre>
|
250 |
+
</div>
|
251 |
+
</div>
|
252 |
+
<div class="cell">
|
253 |
+
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>results.generations[<span class="dv">0</span>][<span class="dv">0</span>].message.content</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
254 |
+
<div class="cell-output cell-output-display">
|
255 |
+
<pre><code>'Vegan, Thai, tofu, bell peppers, carrots'</code></pre>
|
256 |
+
</div>
|
257 |
+
</div>
|
258 |
+
<section id="test-with-vegan-recipe-search-tool" class="level3">
|
259 |
+
<h3 class="anchored" data-anchor-id="test-with-vegan-recipe-search-tool">Test with vegan recipe search tool</h3>
|
260 |
+
<div class="cell">
|
261 |
+
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>vegan_recipe_edamam_search(results.generations[<span class="dv">0</span>][<span class="dv">0</span>].message.content)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
262 |
+
<div class="cell-output cell-output-display">
|
263 |
+
<pre><code>"[{'label': 'Vegan Panang Curry with Tofu', 'url': 'https://pipingpotcurry.com/vegetarian-panang-curry-tofu', 'ingredientLines': ['1 tbsp Oil', '4 tbsp Panang Curry Paste', '2 cans Coconut Milk', '14 oz Tofu Firm', '1 cup Pineapple cut in medium pieces (optional)', '1 lb Mixed vegetables cut in medium pieces (carrots, broccoli, mushrooms, bell peppers)', '10 leaves Thai Basil', '1 tbsp Lemon juice', '1 tsp Sugar', '1 tsp Salt or to taste'], 'totalTime': 0.0}, {'label': 'Vegan Rainbow Thai Peanut Noodle Bake', 'url': 'https://tastykitchen.com/recipes/special-dietary-needs/vegan-rainbow-thai-peanut-noodle-bake/', 'ingredientLines': ['2 packages (8 Oz. Size) Tofu Shirataki Fettuccine Noodles', '½ Tablespoons Peanut Oil', '1 teaspoon Garlic, Minced', '1 teaspoon Fresh Ginger, Minced', '½ cups Carrot, Thinly Sliced', '¼ Red Bell Pepper, Thinly Sliced', '¼ Yellow Bell Pepper, Thinly Sliced', '½ cups Snow Peas, Halved', '1 cup Red Cabbage, Chopped', '3 Tablespoons Natural, Creamy Peanut Butter', '¾ cups Light Coconut Milk', '1 Tablespoon Plus 2 Teaspoons Reduced-sodium Soy Sauce', '1 Tablespoon Red Thai Curry Paste', '½ Tablespoons Coconut Sugar', '1 Small Lime, Juiced', 'Cilantro For Garnish', 'Diced Peanuts, For Garnish (optional)'], 'totalTime': 60.0}, {'label': 'Vegan Pad Thai recipes', 'url': 'http://www.godairyfree.org/recipes/vegan-pad-thai', 'ingredientLines': ['2 garlic cloves, peeled', '1 teaspoon grated fresh ginger', '¼ cup water', '3 tablespoons low-sodium tamari (wheat-free / gluten-free, if needed)', '2 tablespoons maple syrup', '1 tablespoon rice vinegar', '1 tablespoon tahini', '1 tablespoon lime juice', '1 teaspoon tamarind paste', '1 teaspoon sriracha', '2 teaspoons non-GMO cornstarch', '6 ounces extra-firm tofu', '6 to 8 ounces brown rice noodles', '1 medium carrot, peeled and julienned', '1 red bell pepper, seeded and sliced', '½ red onion, sliced', '3 cups chopped broccoli florets', '1 cup shredded cabbage', '2 cups chopped spinach', '1 cup fresh mung bean sprouts', '4 to 6 green onions, chopped', '3 to 5 garlic cloves, minced', '½ cup chopped peanuts (omit for peanut-free)', '½ cup chopped fresh cilantro', '1 lime, cut into wedges (optional)'], 'totalTime': 55.0}]"</code></pre>
|
264 |
</div>
|
265 |
+
</div>
|
266 |
+
<div class="cell">
|
267 |
+
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>result <span class="op">=</span> conversation.predict(</span>
|
268 |
+
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">input</span><span class="op">=</span><span class="st">"Aactually how about italian instead with those same ingredients?"</span></span>
|
269 |
+
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>)</span>
|
270 |
+
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(result)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
271 |
<div class="cell-output cell-output-stdout">
|
272 |
<pre><code>
|
273 |
|
274 |
> Entering new ConversationChain chain...
|
275 |
Prompt after formatting:
|
276 |
+
System: The following is a conversation between a human and a friendly vegan AI.
|
277 |
+
The AI is compassionate to animals and therefore serves to promote veganism.
|
278 |
+
Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.
|
279 |
+
If the human messages are not aligned with veganism, remind them of your purpose.
|
280 |
+
The AI never generates vegan recipes itself but instead uses a tool.
|
|
|
|
|
281 |
AI: What ingredients do you wish to cook with?
|
282 |
Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread
|
283 |
AI: Do you have any allergies I should be aware of?
|
284 |
Human: Allergies:
|
285 |
AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?
|
286 |
+
Human: Preferences: `The preparation time should be less than 30 minutes. I really love Thai food!`
|
287 |
+
Your task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.
|
288 |
+
Think step by step.
|
289 |
+
|
290 |
+
1. If the user listed any ingredients, choose the three ingredients that are most commonly used together in recipes that fall within the user's preferences (if any are included).
|
291 |
+
2. If the user provided any allergies, include them in the query.
|
292 |
+
Format your response as message with the allergy and diet preferences first and then the ingredients.
|
293 |
+
Examples:
|
294 |
+
'Vegan gluten-free chicken peppers' or 'Vegan tofu, brocolli, and miso'
|
295 |
+
AI: Vegan, Thai, tofu, bell peppers, carrots
|
296 |
+
Human: Aactually how about italian instead with those same ingredients?
|
297 |
+
AI: Vegan, Italian, tofu, bell peppers, carrots
|
298 |
+
Human: Aactually how about italian instead with those same ingredients?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
> Finished chain.
|
301 |
+
I'm sorry, but as a vegan AI, I cannot provide a recipe that includes animal products such as meat or dairy. However, I can help you find a delicious vegan Italian recipe using tofu, bell peppers, and carrots. Would you like me to assist you with that?</code></pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
</div>
|
303 |
</div>
|
304 |
<div class="cell">
|
305 |
+
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>vegan_recipe_edamam_search(<span class="st">"Vegan, Italian, tofu, bell peppers, carrots"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
306 |
+
<div class="cell-output cell-output-display">
|
307 |
+
<pre><code>"[{'label': 'RBC Vegan Stuffed Cabbage Leaves', 'url': 'https://www.bigoven.com/recipe/rbc-vegan-stuffed-cabbage-leaves/517323', 'ingredientLines': ['2 heads Cabbage ; Steamed 10 minutes cooled', '1 pound Firm tofu ; Sliced thinly', '14 ounces Canned tomato sauce', '7 ounces Beets ; Canned', '1 Carrot ; Shredded', '1 Green or red bell pepper ; Thinly sliced', '8 ounces Fresh mushrooms ; Sliced', '4 cloves Garlic cloves ; Chopped', '2 cups Dry wild rice ; Prepared as directed', '5 ounces Non dairy cream cheese', '1 teaspoon Italian seasoning', 'Salt & pepper ; To taste'], 'totalTime': 0.0}]"</code></pre>
|
308 |
+
</div>
|
309 |
</div>
|
310 |
|
311 |
|
312 |
+
</section>
|
313 |
|
314 |
</main> <!-- /main -->
|
315 |
<script id="quarto-html-after-body" type="application/javascript">
|
|
|
549 |
|
550 |
|
551 |
|
552 |
+
</body></html>
|
_proc/_docs/index.html
CHANGED
@@ -161,8 +161,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
161 |
</li>
|
162 |
<li class="sidebar-item">
|
163 |
<div class="sidebar-item-container">
|
164 |
-
<a href="./
|
165 |
-
<span class="menu-text">
|
166 |
</div>
|
167 |
</li>
|
168 |
<li class="sidebar-item">
|
@@ -170,12 +170,6 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
170 |
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link">
|
171 |
<span class="menu-text">ingredient_vision</span></a>
|
172 |
</div>
|
173 |
-
</li>
|
174 |
-
<li class="sidebar-item">
|
175 |
-
<div class="sidebar-item-container">
|
176 |
-
<a href="./edamam_api.html" class="sidebar-item-text sidebar-link">
|
177 |
-
<span class="menu-text">edamam_api</span></a>
|
178 |
-
</div>
|
179 |
</li>
|
180 |
</ul>
|
181 |
</div>
|
|
|
161 |
</li>
|
162 |
<li class="sidebar-item">
|
163 |
<div class="sidebar-item-container">
|
164 |
+
<a href="./vegan_recipe_tools.html" class="sidebar-item-text sidebar-link">
|
165 |
+
<span class="menu-text">vegan_recipe_tools</span></a>
|
166 |
</div>
|
167 |
</li>
|
168 |
<li class="sidebar-item">
|
|
|
170 |
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link">
|
171 |
<span class="menu-text">ingredient_vision</span></a>
|
172 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
</li>
|
174 |
</ul>
|
175 |
</div>
|
_proc/_docs/ingredient_vision.html
CHANGED
@@ -164,8 +164,8 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
164 |
</li>
|
165 |
<li class="sidebar-item">
|
166 |
<div class="sidebar-item-container">
|
167 |
-
<a href="./
|
168 |
-
<span class="menu-text">
|
169 |
</div>
|
170 |
</li>
|
171 |
<li class="sidebar-item">
|
@@ -173,12 +173,6 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
173 |
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link active">
|
174 |
<span class="menu-text">ingredient_vision</span></a>
|
175 |
</div>
|
176 |
-
</li>
|
177 |
-
<li class="sidebar-item">
|
178 |
-
<div class="sidebar-item-container">
|
179 |
-
<a href="./edamam_api.html" class="sidebar-item-text sidebar-link">
|
180 |
-
<span class="menu-text">edamam_api</span></a>
|
181 |
-
</div>
|
182 |
</li>
|
183 |
</ul>
|
184 |
</div>
|
@@ -228,7 +222,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
228 |
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
229 |
<p>Inspiration drawn from <a href="https://github.com/microsoft/TaskMatrix">TaskMartix aka Visual ChatGPT</a></p>
|
230 |
<hr>
|
231 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
232 |
<section id="format_image" class="level3">
|
233 |
<h3 class="anchored" data-anchor-id="format_image">format_image</h3>
|
234 |
<blockquote class="blockquote">
|
@@ -251,7 +245,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
251 |
</tbody>
|
252 |
</table>
|
253 |
<hr>
|
254 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
255 |
</section>
|
256 |
<section id="blipimagecaptioning" class="level3">
|
257 |
<h3 class="anchored" data-anchor-id="blipimagecaptioning">BlipImageCaptioning</h3>
|
@@ -260,7 +254,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
260 |
</blockquote>
|
261 |
<p>Useful when you want to know what is inside the photo.</p>
|
262 |
<hr>
|
263 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
264 |
</section>
|
265 |
<section id="blipimagecaptioning.inference" class="level3">
|
266 |
<h3 class="anchored" data-anchor-id="blipimagecaptioning.inference">BlipImageCaptioning.inference</h3>
|
@@ -293,7 +287,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
293 |
</tbody>
|
294 |
</table>
|
295 |
<hr>
|
296 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
297 |
</section>
|
298 |
<section id="blipvqa" class="level3">
|
299 |
<h3 class="anchored" data-anchor-id="blipvqa">BlipVQA</h3>
|
@@ -302,7 +296,7 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
302 |
</blockquote>
|
303 |
<p>BLIP Visual Question Answering Useful when you need an answer for a question based on an image. Examples: what is the background color of this image, how many cats are in this figure, what is in this figure?</p>
|
304 |
<hr>
|
305 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
306 |
</section>
|
307 |
<section id="blipvqa.inference" class="level3">
|
308 |
<h3 class="anchored" data-anchor-id="blipvqa.inference">BlipVQA.inference</h3>
|
@@ -519,7 +513,7 @@ no</code></pre>
|
|
519 |
</div>
|
520 |
</div>
|
521 |
<hr>
|
522 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
523 |
</section>
|
524 |
<section id="veganingredientfinder" class="level3">
|
525 |
<h3 class="anchored" data-anchor-id="veganingredientfinder">VeganIngredientFinder</h3>
|
@@ -528,7 +522,7 @@ no</code></pre>
|
|
528 |
</blockquote>
|
529 |
<p>Initialize self. See help(type(self)) for accurate signature.</p>
|
530 |
<hr>
|
531 |
-
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#
|
532 |
</section>
|
533 |
<section id="veganingredientfinder.list_ingredients" class="level3">
|
534 |
<h3 class="anchored" data-anchor-id="veganingredientfinder.list_ingredients">VeganIngredientFinder.list_ingredients</h3>
|
|
|
164 |
</li>
|
165 |
<li class="sidebar-item">
|
166 |
<div class="sidebar-item-container">
|
167 |
+
<a href="./vegan_recipe_tools.html" class="sidebar-item-text sidebar-link">
|
168 |
+
<span class="menu-text">vegan_recipe_tools</span></a>
|
169 |
</div>
|
170 |
</li>
|
171 |
<li class="sidebar-item">
|
|
|
173 |
<a href="./ingredient_vision.html" class="sidebar-item-text sidebar-link active">
|
174 |
<span class="menu-text">ingredient_vision</span></a>
|
175 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
</li>
|
177 |
</ul>
|
178 |
</div>
|
|
|
222 |
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
223 |
<p>Inspiration drawn from <a href="https://github.com/microsoft/TaskMatrix">TaskMartix aka Visual ChatGPT</a></p>
|
224 |
<hr>
|
225 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L26" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
226 |
<section id="format_image" class="level3">
|
227 |
<h3 class="anchored" data-anchor-id="format_image">format_image</h3>
|
228 |
<blockquote class="blockquote">
|
|
|
245 |
</tbody>
|
246 |
</table>
|
247 |
<hr>
|
248 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L41" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
249 |
</section>
|
250 |
<section id="blipimagecaptioning" class="level3">
|
251 |
<h3 class="anchored" data-anchor-id="blipimagecaptioning">BlipImageCaptioning</h3>
|
|
|
254 |
</blockquote>
|
255 |
<p>Useful when you want to know what is inside the photo.</p>
|
256 |
<hr>
|
257 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L60" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
258 |
</section>
|
259 |
<section id="blipimagecaptioning.inference" class="level3">
|
260 |
<h3 class="anchored" data-anchor-id="blipimagecaptioning.inference">BlipImageCaptioning.inference</h3>
|
|
|
287 |
</tbody>
|
288 |
</table>
|
289 |
<hr>
|
290 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L71" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
291 |
</section>
|
292 |
<section id="blipvqa" class="level3">
|
293 |
<h3 class="anchored" data-anchor-id="blipvqa">BlipVQA</h3>
|
|
|
296 |
</blockquote>
|
297 |
<p>BLIP Visual Question Answering Useful when you need an answer for a question based on an image. Examples: what is the background color of this image, how many cats are in this figure, what is in this figure?</p>
|
298 |
<hr>
|
299 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L89" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
300 |
</section>
|
301 |
<section id="blipvqa.inference" class="level3">
|
302 |
<h3 class="anchored" data-anchor-id="blipvqa.inference">BlipVQA.inference</h3>
|
|
|
513 |
</div>
|
514 |
</div>
|
515 |
<hr>
|
516 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L106" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
517 |
</section>
|
518 |
<section id="veganingredientfinder" class="level3">
|
519 |
<h3 class="anchored" data-anchor-id="veganingredientfinder">VeganIngredientFinder</h3>
|
|
|
522 |
</blockquote>
|
523 |
<p>Initialize self. See help(type(self)) for accurate signature.</p>
|
524 |
<hr>
|
525 |
+
<p><a href="https://gitlab.com/animalequality/lv-recipe-chatbot/blob/main/lv_recipe_chatbot/ingredient_vision.py#L111" target="_blank" style="float:right; font-size:smaller">source</a></p>
|
526 |
</section>
|
527 |
<section id="veganingredientfinder.list_ingredients" class="level3">
|
528 |
<h3 class="anchored" data-anchor-id="veganingredientfinder.list_ingredients">VeganIngredientFinder.list_ingredients</h3>
|
_proc/_docs/search.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
_proc/_docs/sitemap.xml
CHANGED
@@ -2,15 +2,15 @@
|
|
2 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
3 |
<url>
|
4 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/ingredient_vision.html</loc>
|
5 |
-
<lastmod>2023-
|
6 |
</url>
|
7 |
<url>
|
8 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/app.html</loc>
|
9 |
-
<lastmod>2023-
|
10 |
</url>
|
11 |
<url>
|
12 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/index.html</loc>
|
13 |
-
<lastmod>2023-
|
14 |
</url>
|
15 |
<url>
|
16 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/lchain_tool.html</loc>
|
@@ -18,10 +18,14 @@
|
|
18 |
</url>
|
19 |
<url>
|
20 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/engineer_prompt.html</loc>
|
21 |
-
<lastmod>2023-
|
22 |
</url>
|
23 |
<url>
|
24 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/edamam_api.html</loc>
|
25 |
<lastmod>2023-06-12T17:36:54.115Z</lastmod>
|
26 |
</url>
|
|
|
|
|
|
|
|
|
27 |
</urlset>
|
|
|
2 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
3 |
<url>
|
4 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/ingredient_vision.html</loc>
|
5 |
+
<lastmod>2023-08-02T20:27:17.667Z</lastmod>
|
6 |
</url>
|
7 |
<url>
|
8 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/app.html</loc>
|
9 |
+
<lastmod>2023-08-02T20:27:18.539Z</lastmod>
|
10 |
</url>
|
11 |
<url>
|
12 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/index.html</loc>
|
13 |
+
<lastmod>2023-08-02T20:27:18.915Z</lastmod>
|
14 |
</url>
|
15 |
<url>
|
16 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/lchain_tool.html</loc>
|
|
|
18 |
</url>
|
19 |
<url>
|
20 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/engineer_prompt.html</loc>
|
21 |
+
<lastmod>2023-08-02T20:27:19.143Z</lastmod>
|
22 |
</url>
|
23 |
<url>
|
24 |
<loc>https://animalequality.github.io/lv-recipe-chatbot/edamam_api.html</loc>
|
25 |
<lastmod>2023-06-12T17:36:54.115Z</lastmod>
|
26 |
</url>
|
27 |
+
<url>
|
28 |
+
<loc>https://animalequality.github.io/lv-recipe-chatbot/vegan_recipe_tools.html</loc>
|
29 |
+
<lastmod>2023-08-02T20:30:36.613Z</lastmod>
|
30 |
+
</url>
|
31 |
</urlset>
|
_proc/_docs/vegan_recipe_tools.html
ADDED
The diff for this file is too large to render.
See raw diff
|
|
_proc/sidebar.yml
CHANGED
@@ -4,6 +4,5 @@ website:
|
|
4 |
- index.ipynb
|
5 |
- 00_engineer_prompt.ipynb
|
6 |
- 01_app.ipynb
|
7 |
-
-
|
8 |
- 03_ingredient_vision.ipynb
|
9 |
-
- 04_edamam_api.ipynb
|
|
|
4 |
- index.ipynb
|
5 |
- 00_engineer_prompt.ipynb
|
6 |
- 01_app.ipynb
|
7 |
+
- 02_vegan_recipe_tools.ipynb
|
8 |
- 03_ingredient_vision.ipynb
|
|
lv_recipe_chatbot/engineer_prompt.py
CHANGED
@@ -17,18 +17,15 @@ from langchain.prompts.chat import (
|
|
17 |
)
|
18 |
from langchain.schema import AIMessage, HumanMessage, SystemMessage
|
19 |
|
20 |
-
# %% ../nbs/00_engineer_prompt.ipynb
|
21 |
INIT_PROMPT = ChatPromptTemplate.from_messages(
|
22 |
[
|
23 |
SystemMessagePromptTemplate.from_template(
|
24 |
-
"""The following is a conversation between a human and a friendly AI
|
25 |
-
The AI is compassionate to animals.
|
26 |
-
The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs.
|
27 |
Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.
|
28 |
-
|
29 |
-
|
30 |
-
If the human messages are unrelated to vegan recipes, remind them of your purpose to recipes.
|
31 |
-
Only generate keyword queries as other tools should be used to fetch full recipes."""
|
32 |
),
|
33 |
AIMessagePromptTemplate.from_template(
|
34 |
"What ingredients do you wish to cook with?"
|
@@ -42,12 +39,15 @@ Only generate keyword queries as other tools should be used to fetch full recipe
|
|
42 |
"Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?"
|
43 |
),
|
44 |
HumanMessagePromptTemplate.from_template(
|
45 |
-
"""
|
46 |
-
|
|
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
),
|
52 |
]
|
53 |
)
|
|
|
17 |
)
|
18 |
from langchain.schema import AIMessage, HumanMessage, SystemMessage
|
19 |
|
20 |
+
# %% ../nbs/00_engineer_prompt.ipynb 8
|
21 |
INIT_PROMPT = ChatPromptTemplate.from_messages(
|
22 |
[
|
23 |
SystemMessagePromptTemplate.from_template(
|
24 |
+
"""The following is a conversation between a human and a friendly vegan AI.
|
25 |
+
The AI is compassionate to animals and therefore serves to promote veganism.
|
|
|
26 |
Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.
|
27 |
+
If the human messages are not aligned with veganism, remind them of your purpose.
|
28 |
+
The AI NEVER generates vegan recipes itself but instead uses a tool."""
|
|
|
|
|
29 |
),
|
30 |
AIMessagePromptTemplate.from_template(
|
31 |
"What ingredients do you wish to cook with?"
|
|
|
39 |
"Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?"
|
40 |
),
|
41 |
HumanMessagePromptTemplate.from_template(
|
42 |
+
"""Preferences: `{recipe_freeform_input}`
|
43 |
+
Your task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.
|
44 |
+
Think step by step.
|
45 |
|
46 |
+
1. If the user listed any ingredients, choose the three ingredients that are most commonly go together in recipes that match the user's preferences (if any are included).
|
47 |
+
2. If the user provided any allergies, include them in the query.
|
48 |
+
Format your response as message with the allergy and diet preferences first and then the ingredients.
|
49 |
+
Examples:
|
50 |
+
'Vegan gluten-free chicken peppers' or 'Vegan Japanese tofu, brocolli, and miso'"""
|
51 |
),
|
52 |
]
|
53 |
)
|
nbs/00_engineer_prompt.ipynb
CHANGED
@@ -49,6 +49,15 @@
|
|
49 |
"from langchain.schema import AIMessage, HumanMessage, SystemMessage"
|
50 |
]
|
51 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
{
|
53 |
"cell_type": "markdown",
|
54 |
"metadata": {},
|
@@ -96,14 +105,11 @@
|
|
96 |
"INIT_PROMPT = ChatPromptTemplate.from_messages(\n",
|
97 |
" [\n",
|
98 |
" SystemMessagePromptTemplate.from_template(\n",
|
99 |
-
" \"\"\"The following is a conversation between a human and a friendly AI
|
100 |
-
"The AI is compassionate to animals.\n",
|
101 |
-
"The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs.\n",
|
102 |
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
103 |
-
"
|
104 |
-
"
|
105 |
-
"If the human messages are unrelated to vegan recipes, remind them of your purpose to recipes.\n",
|
106 |
-
"Only generate keyword queries as other tools should be used to fetch full recipes.\"\"\"\n",
|
107 |
" ),\n",
|
108 |
" AIMessagePromptTemplate.from_template(\n",
|
109 |
" \"What ingredients do you wish to cook with?\"\n",
|
@@ -117,12 +123,15 @@
|
|
117 |
" \"Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\"\n",
|
118 |
" ),\n",
|
119 |
" HumanMessagePromptTemplate.from_template(\n",
|
120 |
-
" \"\"\"
|
121 |
-
"
|
|
|
122 |
"\n",
|
123 |
-
"
|
124 |
-
"
|
125 |
-
"
|
|
|
|
|
126 |
" ),\n",
|
127 |
" ]\n",
|
128 |
")"
|
@@ -144,69 +153,13 @@
|
|
144 |
"name": "stdout",
|
145 |
"output_type": "stream",
|
146 |
"text": [
|
147 |
-
"\n"
|
148 |
-
"\n",
|
149 |
-
"\u001b[1m> Entering new ConversationChain chain...\u001b[0m\n",
|
150 |
-
"Prompt after formatting:\n",
|
151 |
-
"\u001b[32;1m\u001b[1;3mSystem: The following is a conversation between a human and a friendly AI chef. \n",
|
152 |
-
"The AI is compassionate to animals.\n",
|
153 |
-
"The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs.\n",
|
154 |
-
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
155 |
-
"\n",
|
156 |
-
"Let's think step by step.\n",
|
157 |
-
"If the human messages are unrelated to vegan recipes, remind them of your purpose to recipes.\n",
|
158 |
-
"Only generate keyword queries as other tools should be used to fetch full recipes.\n",
|
159 |
-
"AI: What ingredients do you wish to cook with?\n",
|
160 |
-
"Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\n",
|
161 |
-
"AI: Do you have any allergies I should be aware of?\n",
|
162 |
-
"Human: Allergies: \n",
|
163 |
-
"AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\n",
|
164 |
-
"Human: Generate a vegan recipe keyword query that is aligned with the user's allergies and contains at least a few of the ingredients provided (if any).\n",
|
165 |
-
"Draw some inspiration from the user's preferences delimited below if any are specified.\n",
|
166 |
-
"\n",
|
167 |
-
"###\n",
|
168 |
-
"Preferences: The preparation time should be less than 30 minutes. I really love Thai food!\n",
|
169 |
-
"###\n",
|
170 |
-
"AI: Based on your preferences, allergies, and ingredients, a concise vegan recipe keyword query could be: \"vegan Thai tofu sandwich with pickles, olives, tomatoes, lettuce, bell peppers, and carrots\". This should help you find a suitable recipe using recipe APIs or other recipe platforms.\n",
|
171 |
-
"Human: Recommend a different recipe please.\u001b[0m\n",
|
172 |
-
"\n",
|
173 |
-
"\u001b[1m> Finished chain.\u001b[0m\n",
|
174 |
-
"\n",
|
175 |
-
"\n",
|
176 |
-
"\u001b[1m> Entering new ConversationChain chain...\u001b[0m\n",
|
177 |
-
"Prompt after formatting:\n",
|
178 |
-
"\u001b[32;1m\u001b[1;3mSystem: The following is a conversation between a human and a friendly AI chef. \n",
|
179 |
-
"The AI is compassionate to animals.\n",
|
180 |
-
"The AI generates a simple concise keyword query for a vegan recipe, based on the ingredients, allergies, and other preferences the human has, to use in recipe APIs.\n",
|
181 |
-
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
182 |
-
"\n",
|
183 |
-
"Let's think step by step.\n",
|
184 |
-
"If the human messages are unrelated to vegan recipes, remind them of your purpose to recipes.\n",
|
185 |
-
"Only generate keyword queries as other tools should be used to fetch full recipes.\n",
|
186 |
-
"AI: What ingredients do you wish to cook with?\n",
|
187 |
-
"Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\n",
|
188 |
-
"AI: Do you have any allergies I should be aware of?\n",
|
189 |
-
"Human: Allergies: \n",
|
190 |
-
"AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\n",
|
191 |
-
"Human: Generate a vegan recipe keyword query that is aligned with the user's allergies and contains at least a few of the ingredients provided (if any).\n",
|
192 |
-
"Draw some inspiration from the user's preferences delimited below if any are specified.\n",
|
193 |
-
"\n",
|
194 |
-
"###\n",
|
195 |
-
"Preferences: The preparation time should be less than 30 minutes. I really love Thai food!\n",
|
196 |
-
"###\n",
|
197 |
-
"AI: Based on your preferences, allergies, and ingredients, a concise vegan recipe keyword query could be: \"vegan Thai tofu sandwich with pickles, olives, tomatoes, lettuce, bell peppers, and carrots\". This should help you find a suitable recipe using recipe APIs or other recipe platforms.\n",
|
198 |
-
"Human: Recommend a different recipe please.\n",
|
199 |
-
"AI: Certainly! How about a vegan Thai peanut tofu stir-fry? It's a delicious and easy-to-make dish that incorporates some of the ingredients you mentioned. Here's a concise vegan recipe keyword query for it: \"vegan Thai peanut tofu stir-fry with tofu, bell peppers, carrots, and peanuts\". This should give you some great recipe options to explore!\n",
|
200 |
-
"Human: Aactually how about italian instead?\u001b[0m\n",
|
201 |
-
"\n",
|
202 |
-
"\u001b[1m> Finished chain.\u001b[0m\n",
|
203 |
-
"Of course! If you prefer an Italian-inspired vegan recipe, how about a vegan Caprese salad with marinated tofu? It's a refreshing and flavorful dish that combines tomatoes, tofu, and basil. Here's a concise vegan recipe keyword query for it: \"vegan Caprese salad with marinated tofu, tomatoes, and basil\". This should help you find some delicious Italian vegan recipes to try out!\n"
|
204 |
]
|
205 |
}
|
206 |
],
|
207 |
"source": [
|
208 |
"#| eval: false\n",
|
209 |
-
"chat = PromptLayerChatOpenAI(temperature=1, pl_tags=[\"langchain\"], return_pl_id=True)\n",
|
210 |
"memory = ConversationBufferMemory(return_messages=True)\n",
|
211 |
"chat_msgs = INIT_PROMPT.format_prompt(\n",
|
212 |
" ingredients=\"tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\",\n",
|
@@ -227,12 +180,129 @@
|
|
227 |
"conversation = ConversationChain(\n",
|
228 |
" llm=chat, verbose=True, memory=memory, prompt=open_prompt\n",
|
229 |
")\n",
|
230 |
-
"
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
"print(result)"
|
234 |
]
|
235 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
{
|
237 |
"cell_type": "code",
|
238 |
"execution_count": null,
|
|
|
49 |
"from langchain.schema import AIMessage, HumanMessage, SystemMessage"
|
50 |
]
|
51 |
},
|
52 |
+
{
|
53 |
+
"cell_type": "code",
|
54 |
+
"execution_count": null,
|
55 |
+
"metadata": {},
|
56 |
+
"outputs": [],
|
57 |
+
"source": [
|
58 |
+
"from lv_recipe_chatbot.vegan_recipe_tools import vegan_recipe_edamam_search"
|
59 |
+
]
|
60 |
+
},
|
61 |
{
|
62 |
"cell_type": "markdown",
|
63 |
"metadata": {},
|
|
|
105 |
"INIT_PROMPT = ChatPromptTemplate.from_messages(\n",
|
106 |
" [\n",
|
107 |
" SystemMessagePromptTemplate.from_template(\n",
|
108 |
+
" \"\"\"The following is a conversation between a human and a friendly vegan AI. \n",
|
109 |
+
"The AI is compassionate to animals and therefore serves to promote veganism.\n",
|
|
|
110 |
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
111 |
+
"If the human messages are not aligned with veganism, remind them of your purpose.\n",
|
112 |
+
"The AI NEVER generates vegan recipes itself but instead uses a tool.\"\"\"\n",
|
|
|
|
|
113 |
" ),\n",
|
114 |
" AIMessagePromptTemplate.from_template(\n",
|
115 |
" \"What ingredients do you wish to cook with?\"\n",
|
|
|
123 |
" \"Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\"\n",
|
124 |
" ),\n",
|
125 |
" HumanMessagePromptTemplate.from_template(\n",
|
126 |
+
" \"\"\"Preferences: `{recipe_freeform_input}`\n",
|
127 |
+
"Your task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.\n",
|
128 |
+
"Think step by step.\n",
|
129 |
"\n",
|
130 |
+
"1. If the user listed any ingredients, choose the three ingredients that are most commonly go together in recipes that match the user's preferences (if any are included). \n",
|
131 |
+
"2. If the user provided any allergies, include them in the query.\n",
|
132 |
+
"Format your response as message with the allergy and diet preferences first and then the ingredients.\n",
|
133 |
+
"Examples:\n",
|
134 |
+
"'Vegan gluten-free chicken peppers' or 'Vegan Japanese tofu, brocolli, and miso'\"\"\"\n",
|
135 |
" ),\n",
|
136 |
" ]\n",
|
137 |
")"
|
|
|
153 |
"name": "stdout",
|
154 |
"output_type": "stream",
|
155 |
"text": [
|
156 |
+
"content='Vegan Thai tofu, bell peppers, carrots' additional_kwargs={} example=False\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
]
|
158 |
}
|
159 |
],
|
160 |
"source": [
|
161 |
"#| eval: false\n",
|
162 |
+
"chat = PromptLayerChatOpenAI(temperature=0.1, pl_tags=[\"langchain\"], return_pl_id=True)\n",
|
163 |
"memory = ConversationBufferMemory(return_messages=True)\n",
|
164 |
"chat_msgs = INIT_PROMPT.format_prompt(\n",
|
165 |
" ingredients=\"tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\",\n",
|
|
|
180 |
"conversation = ConversationChain(\n",
|
181 |
" llm=chat, verbose=True, memory=memory, prompt=open_prompt\n",
|
182 |
")\n",
|
183 |
+
"print(results.generations[0][0].message)"
|
184 |
+
]
|
185 |
+
},
|
186 |
+
{
|
187 |
+
"cell_type": "code",
|
188 |
+
"execution_count": null,
|
189 |
+
"metadata": {},
|
190 |
+
"outputs": [
|
191 |
+
{
|
192 |
+
"data": {
|
193 |
+
"text/plain": [
|
194 |
+
"'Vegan Thai tofu, bell peppers, carrots'"
|
195 |
+
]
|
196 |
+
},
|
197 |
+
"execution_count": null,
|
198 |
+
"metadata": {},
|
199 |
+
"output_type": "execute_result"
|
200 |
+
}
|
201 |
+
],
|
202 |
+
"source": [
|
203 |
+
"#| eval: false\n",
|
204 |
+
"results.generations[0][0].message.content"
|
205 |
+
]
|
206 |
+
},
|
207 |
+
{
|
208 |
+
"cell_type": "markdown",
|
209 |
+
"metadata": {},
|
210 |
+
"source": [
|
211 |
+
"### Test with vegan recipe search tool"
|
212 |
+
]
|
213 |
+
},
|
214 |
+
{
|
215 |
+
"cell_type": "code",
|
216 |
+
"execution_count": null,
|
217 |
+
"metadata": {},
|
218 |
+
"outputs": [
|
219 |
+
{
|
220 |
+
"data": {
|
221 |
+
"text/plain": [
|
222 |
+
"\"[{'label': 'Vegan Panang Curry with Tofu', 'url': 'https://pipingpotcurry.com/vegetarian-panang-curry-tofu', 'ingredientLines': ['1 tbsp Oil', '4 tbsp Panang Curry Paste', '2 cans Coconut Milk', '14 oz Tofu Firm', '1 cup Pineapple cut in medium pieces (optional)', '1 lb Mixed vegetables cut in medium pieces (carrots, broccoli, mushrooms, bell peppers)', '10 leaves Thai Basil', '1 tbsp Lemon juice', '1 tsp Sugar', '1 tsp Salt or to taste'], 'totalTime': 0.0}, {'label': 'Vegan Rainbow Thai Peanut Noodle Bake', 'url': 'https://tastykitchen.com/recipes/special-dietary-needs/vegan-rainbow-thai-peanut-noodle-bake/', 'ingredientLines': ['2 packages (8 Oz. Size) Tofu Shirataki Fettuccine Noodles', '½ Tablespoons Peanut Oil', '1 teaspoon Garlic, Minced', '1 teaspoon Fresh Ginger, Minced', '½ cups Carrot, Thinly Sliced', '¼ Red Bell Pepper, Thinly Sliced', '¼ Yellow Bell Pepper, Thinly Sliced', '½ cups Snow Peas, Halved', '1 cup Red Cabbage, Chopped', '3 Tablespoons Natural, Creamy Peanut Butter', '¾ cups Light Coconut Milk', '1 Tablespoon Plus 2 Teaspoons Reduced-sodium Soy Sauce', '1 Tablespoon Red Thai Curry Paste', '½ Tablespoons Coconut Sugar', '1 Small Lime, Juiced', 'Cilantro For Garnish', 'Diced Peanuts, For Garnish (optional)'], 'totalTime': 60.0}, {'label': 'Vegan Pad Thai recipes', 'url': 'http://www.godairyfree.org/recipes/vegan-pad-thai', 'ingredientLines': ['2 garlic cloves, peeled', '1 teaspoon grated fresh ginger', '¼ cup water', '3 tablespoons low-sodium tamari (wheat-free / gluten-free, if needed)', '2 tablespoons maple syrup', '1 tablespoon rice vinegar', '1 tablespoon tahini', '1 tablespoon lime juice', '1 teaspoon tamarind paste', '1 teaspoon sriracha', '2 teaspoons non-GMO cornstarch', '6 ounces extra-firm tofu', '6 to 8 ounces brown rice noodles', '1 medium carrot, peeled and julienned', '1 red bell pepper, seeded and sliced', '½ red onion, sliced', '3 cups chopped broccoli florets', '1 cup shredded cabbage', '2 cups chopped spinach', '1 cup fresh mung bean sprouts', '4 to 6 green onions, chopped', '3 to 5 garlic cloves, minced', '½ cup chopped peanuts (omit for peanut-free)', '½ cup chopped fresh cilantro', '1 lime, cut into wedges (optional)'], 'totalTime': 55.0}]\""
|
223 |
+
]
|
224 |
+
},
|
225 |
+
"execution_count": null,
|
226 |
+
"metadata": {},
|
227 |
+
"output_type": "execute_result"
|
228 |
+
}
|
229 |
+
],
|
230 |
+
"source": [
|
231 |
+
"#| eval: false\n",
|
232 |
+
"vegan_recipe_edamam_search(results.generations[0][0].message.content)"
|
233 |
+
]
|
234 |
+
},
|
235 |
+
{
|
236 |
+
"cell_type": "code",
|
237 |
+
"execution_count": null,
|
238 |
+
"metadata": {},
|
239 |
+
"outputs": [
|
240 |
+
{
|
241 |
+
"name": "stdout",
|
242 |
+
"output_type": "stream",
|
243 |
+
"text": [
|
244 |
+
"\n",
|
245 |
+
"\n",
|
246 |
+
"\u001b[1m> Entering new ConversationChain chain...\u001b[0m\n",
|
247 |
+
"Prompt after formatting:\n",
|
248 |
+
"\u001b[32;1m\u001b[1;3mSystem: The following is a conversation between a human and a friendly vegan AI. \n",
|
249 |
+
"The AI is compassionate to animals and therefore serves to promote veganism.\n",
|
250 |
+
"Knowledge: A vegan diet implies a plant-based diet avoiding all animal foods such as meat (including fish, shellfish and insects), dairy, eggs and honey.\n",
|
251 |
+
"If the human messages are not aligned with veganism, remind them of your purpose.\n",
|
252 |
+
"The AI never generates vegan recipes itself but instead uses a tool.\n",
|
253 |
+
"AI: What ingredients do you wish to cook with?\n",
|
254 |
+
"Human: Ingredients: tofu, pickles, olives, tomatoes, lettuce, bell peppers, carrots, bread\n",
|
255 |
+
"AI: Do you have any allergies I should be aware of?\n",
|
256 |
+
"Human: Allergies: \n",
|
257 |
+
"AI: Do you have any preferences I should consider for the recipe such as preparation time, difficulty, or cuisine region?\n",
|
258 |
+
"Human: Preferences: `The preparation time should be less than 30 minutes. I really love Thai food!`\n",
|
259 |
+
"Your task is compose a concise, 6 word max vegan recipe keyword query to use in an API search.\n",
|
260 |
+
"Think step by step.\n",
|
261 |
+
"\n",
|
262 |
+
"1. If the user listed any ingredients, choose the three ingredients that are most commonly used together in recipes that fall within the user's preferences (if any are included). \n",
|
263 |
+
"2. If the user provided any allergies, include them in the query.\n",
|
264 |
+
"Format your response as message with the allergy and diet preferences first and then the ingredients.\n",
|
265 |
+
"Examples:\n",
|
266 |
+
"'Vegan gluten-free chicken peppers' or 'Vegan tofu, brocolli, and miso'\n",
|
267 |
+
"AI: Vegan, Thai, tofu, bell peppers, carrots\n",
|
268 |
+
"Human: Aactually how about italian instead with those same ingredients?\n",
|
269 |
+
"AI: Vegan, Italian, tofu, bell peppers, carrots\n",
|
270 |
+
"Human: Aactually how about italian instead with those same ingredients?\u001b[0m\n",
|
271 |
+
"\n",
|
272 |
+
"\u001b[1m> Finished chain.\u001b[0m\n",
|
273 |
+
"I'm sorry, but as a vegan AI, I cannot provide a recipe that includes animal products such as meat or dairy. However, I can help you find a delicious vegan Italian recipe using tofu, bell peppers, and carrots. Would you like me to assist you with that?\n"
|
274 |
+
]
|
275 |
+
}
|
276 |
+
],
|
277 |
+
"source": [
|
278 |
+
"#| eval: false\n",
|
279 |
+
"result = conversation.predict(\n",
|
280 |
+
" input=\"Aactually how about italian instead with those same ingredients?\"\n",
|
281 |
+
")\n",
|
282 |
"print(result)"
|
283 |
]
|
284 |
},
|
285 |
+
{
|
286 |
+
"cell_type": "code",
|
287 |
+
"execution_count": null,
|
288 |
+
"metadata": {},
|
289 |
+
"outputs": [
|
290 |
+
{
|
291 |
+
"data": {
|
292 |
+
"text/plain": [
|
293 |
+
"\"[{'label': 'RBC Vegan Stuffed Cabbage Leaves', 'url': 'https://www.bigoven.com/recipe/rbc-vegan-stuffed-cabbage-leaves/517323', 'ingredientLines': ['2 heads Cabbage ; Steamed 10 minutes cooled', '1 pound Firm tofu ; Sliced thinly', '14 ounces Canned tomato sauce', '7 ounces Beets ; Canned', '1 Carrot ; Shredded', '1 Green or red bell pepper ; Thinly sliced', '8 ounces Fresh mushrooms ; Sliced', '4 cloves Garlic cloves ; Chopped', '2 cups Dry wild rice ; Prepared as directed', '5 ounces Non dairy cream cheese', '1 teaspoon Italian seasoning', 'Salt & pepper ; To taste'], 'totalTime': 0.0}]\""
|
294 |
+
]
|
295 |
+
},
|
296 |
+
"execution_count": null,
|
297 |
+
"metadata": {},
|
298 |
+
"output_type": "execute_result"
|
299 |
+
}
|
300 |
+
],
|
301 |
+
"source": [
|
302 |
+
"#| eval: false\n",
|
303 |
+
"vegan_recipe_edamam_search(\"Vegan, Italian, tofu, bell peppers, carrots\")"
|
304 |
+
]
|
305 |
+
},
|
306 |
{
|
307 |
"cell_type": "code",
|
308 |
"execution_count": null,
|