thrag commited on
Commit
d5bc134
·
1 Parent(s): 91bd517

Final check off previous checkin.

Browse files
Files changed (1) hide show
  1. demo-tools-1.ipynb +60 -34
demo-tools-1.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 7,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -35,7 +35,7 @@
35
  },
36
  {
37
  "cell_type": "code",
38
- "execution_count": 168,
39
  "metadata": {},
40
  "outputs": [],
41
  "source": [
@@ -80,7 +80,7 @@
80
  },
81
  {
82
  "cell_type": "code",
83
- "execution_count": 9,
84
  "metadata": {},
85
  "outputs": [],
86
  "source": [
@@ -181,7 +181,7 @@
181
  },
182
  {
183
  "cell_type": "code",
184
- "execution_count": 169,
185
  "metadata": {},
186
  "outputs": [],
187
  "source": [
@@ -217,15 +217,45 @@
217
  },
218
  {
219
  "cell_type": "code",
220
- "execution_count": null,
221
  "metadata": {},
222
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  "source": [
224
  "print('Chicken dishes:')\n",
225
  "for i in chickenDishList:\n",
226
- " resp += i['title'])\n",
227
  " \n",
228
- "resp += )\n",
229
  "print('Desserts:')\n",
230
  "for i in dessertList:\n",
231
  " print(i['title'])"
@@ -244,7 +274,7 @@
244
  },
245
  {
246
  "cell_type": "code",
247
- "execution_count": 210,
248
  "metadata": {},
249
  "outputs": [
250
  {
@@ -253,17 +283,23 @@
253
  "text": [
254
  "\n",
255
  "\n",
256
- "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
 
 
 
 
 
 
257
  "\u001b[32;1m\u001b[1;3mI need to find the recipe for Nutella Ice Cream to know what tools are needed.\n",
258
  "Action: Dessert Recipes tool\n",
259
  "Action Input: Nutella Ice Cream\u001b[0m\n",
260
  "Observation: \u001b[33;1m\u001b[1;3m[{'title': 'Chocolate Snack Cake', 'url': 'https://www.allrecipes.com/chocolate-snack-cake-recipe-8350343'}, {'title': 'Charred Spiced Pears with Smoky Vanilla Cherry Sauce', 'url': 'https://www.allrecipes.com/charred-spiced-pears-with-smoky-vanilla-cherry-sauce-recipe-8347080'}, {'title': 'Meringue Topped Banana Pudding', 'url': 'https://www.allrecipes.com/meringue-topped-banana-pudding-recipe-8347040'}, {'title': 'White Chocolate Cinnamon Toast Crunch Bars', 'url': 'https://www.allrecipes.com/white-chocolate-cinnamon-toast-crunch-bars-recipe-7556790'}, {'title': 'Plum Cobbler for Two', 'url': 'https://www.allrecipes.com/plum-cobbler-for-two-recipe-8304143'}, {'title': 'Pumpkin Cheesecake Cookies', 'url': 'https://www.allrecipes.com/pumpkin-cheesecake-cookies-recipe-7972485'}, {'title': 'Chocolate Whipped Cottage Cheese', 'url': 'https://www.allrecipes.com/chocolate-whipped-cottage-cheese-recipe-8303272'}, {'title': 'Nutella Ice Cream', 'url': 'https://www.allrecipes.com/nutella-ice-cream-recipe-7508716'}, {'title': '3-Ingredient Banana Oatmeal Cookies', 'url': 'https://www.allrecipes.com/3-ingredient-banana-oatmeal-cookies-recipe-7972686'}, {'title': 'Caramel Apple Pie Cookies', 'url': 'https://www.allrecipes.com/caramel-apple-pie-cookies-recipe-7642173'}]\u001b[0m\n",
261
- "Thought:\u001b[32;1m\u001b[1;3mI found the recipe for Nutella Ice Cream. Now I need to fetch the recipe to find out what tools are needed.\n",
262
  "Action: Get a Recipe tool\n",
263
  "Action Input: https://www.allrecipes.com/nutella-ice-cream-recipe-7508716\u001b[0m\n",
264
  "Observation: \u001b[38;5;200m\u001b[1;3m{'@context': 'http://schema.org', '@type': ['Recipe'], 'headline': 'Nutella Ice Cream', 'datePublished': '2023-09-28T17:27:33.088-04:00', 'dateModified': '2023-10-12T11:27:16.725-04:00', 'author': [{'@type': 'Person', 'name': 'Laka kuharika - Easy Cook', 'url': 'https://www.allrecipes.com/cook/lakakuharica'}], 'description': 'This exquisite homemade Nutella ice cream is full of nutty flavor, and everyone will simply love it. Nutella gives this ice cream an unbelievable hazelnut taste.', 'name': 'Nutella Ice Cream', 'cookTime': 'PT15M', 'nutrition': {'@type': 'NutritionInformation', 'calories': '305 kcal', 'carbohydrateContent': '16 g', 'cholesterolContent': '156 mg', 'fiberContent': '1 g', 'proteinContent': '8 g', 'saturatedFatContent': '14 g', 'sodiumContent': '78 mg', 'sugarContent': '14 g', 'fatContent': '23 g', 'unsaturatedFatContent': '0 g'}, 'prepTime': 'PT10M', 'recipeCategory': ['Dessert'], 'recipeCuisine': ['American'], 'recipeIngredient': ['2 cups whole milk', '1 cup heavy cream, divided', '4 egg yolks', '1/2 teaspoon vanilla extract', '1/2\\xa0 cup cocoa hazelnut spread (such as Nutella®)', 'Hazelnuts, crushed, for garnish'], 'recipeInstructions': [{'@type': 'HowToStep', 'text': 'Combine milk, cream, and 1/2 cup sugar in a saucepan over medium heat. Cook until sugar dissolves, about 5 minutes.'}, {'@type': 'HowToStep', 'text': 'Beat egg yolks with the remaining sugar in a bowl with an electric mixer until eggs become thick and pale yellow, about 4 minutes.'}, {'@type': 'HowToStep', 'text': 'Pour 1/2 cup warm milk mixture into egg mixture and stir. Add this mixture back into the saucepan. Cook over very low heat, stirring constantly, until the mixture becomes thick enough to coat the back of a wooden spoon, 7 to 10 minutes.'}, {'@type': 'HowToStep', 'text': 'Place a strainer over a bowl and pour the warm custard mixture through the strainer. Stir in vanilla and hazelnut spread until it dissolves.'}, {'@type': 'HowToStep', 'text': 'Chill mixture completely, about 1 hour. Pour into an ice cream maker and churn until frozen according to manufacturer’s instructions, 15 to 20 minutes.'}, {'@type': 'HowToStep', 'text': 'Transfer to a plastic container and place in the freezer for an hour before serving. Top with crushed hazelnuts for serving.'}], 'recipeYield': ['8'], 'totalTime': 'PT160M', 'about': []}\u001b[0m\n",
265
- "Thought:\u001b[32;1m\u001b[1;3mI now have the recipe and can identify the tools needed.\n",
266
- "Final Answer: The tools needed for the Nutella Ice Cream recipe are a saucepan, an electric mixer, a bowl, a strainer, and an ice cream maker.\u001b[0m\n",
267
  "\n",
268
  "\u001b[1m> Finished chain.\u001b[0m\n"
269
  ]
@@ -295,7 +331,9 @@
295
  "#query = \"Is there a Chicken recipe that's prepared with an alchohol? And if so how long does it take in total from start time to finish?\"\n",
296
  "#query = \"Which is healthier the Caramel Apple Pie Cookies or the beer chicken? Please explain how you got to your answer.\"\n",
297
  "#query = \"Is the moon closer to earth or the sun?\"\n",
 
298
  "query = \"What tools do I need for the Nutella Ice Cream?\"\n",
 
299
  "#query = \"My bowl is broken, can I still make Nutella Ice Cream? Answer as a yes/no.\"\n",
300
  "\n",
301
  "response = agent({\"input\": f\"{system} {query}\"})\n"
@@ -303,7 +341,7 @@
303
  },
304
  {
305
  "cell_type": "code",
306
- "execution_count": 211,
307
  "metadata": {},
308
  "outputs": [
309
  {
@@ -319,7 +357,7 @@
319
  "###########################\n",
320
  "\n",
321
  "Step: 2 of 2\n",
322
- "Thought: I found the recipe for Nutella Ice Cream. Now I need to fetch the recipe to find out what tools are needed.\n",
323
  "Action: Get a Recipe tool\n",
324
  "Action Input: https://www.allrecipes.com/nutella-ice-cream-recipe-7508716\n",
325
  "\n",
@@ -327,7 +365,7 @@
327
  "###########################\n",
328
  "\n",
329
  "\n",
330
- "Final Thought: The tools needed for the Nutella Ice Cream recipe are a saucepan, an electric mixer, a bowl, a strainer, and an ice cream maker.\n"
331
  ]
332
  }
333
  ],
@@ -362,7 +400,7 @@
362
  },
363
  {
364
  "cell_type": "code",
365
- "execution_count": 221,
366
  "metadata": {},
367
  "outputs": [
368
  {
@@ -377,7 +415,7 @@
377
  "name": "stdout",
378
  "output_type": "stream",
379
  "text": [
380
- "Running on local URL: http://127.0.0.1:7897\n",
381
  "\n",
382
  "To create a public link, set `share=True` in `launch()`.\n"
383
  ]
@@ -385,7 +423,7 @@
385
  {
386
  "data": {
387
  "text/html": [
388
- "<div><iframe src=\"http://127.0.0.1:7897/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
389
  ],
390
  "text/plain": [
391
  "<IPython.core.display.HTML object>"
@@ -398,22 +436,9 @@
398
  "data": {
399
  "text/plain": []
400
  },
401
- "execution_count": 221,
402
  "metadata": {},
403
  "output_type": "execute_result"
404
- },
405
- {
406
- "name": "stdout",
407
- "output_type": "stream",
408
- "text": [
409
- "\n",
410
- "\n",
411
- "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
412
- "\u001b[32;1m\u001b[1;3mThe question is asking for the location of a watch, which is not information that can be obtained from the available tools. \n",
413
- "Final Answer: I'm sorry, I don't have the ability to locate physical objects.\u001b[0m\n",
414
- "\n",
415
- "\u001b[1m> Finished chain.\u001b[0m\n"
416
- ]
417
  }
418
  ],
419
  "source": [
@@ -439,7 +464,8 @@
439
  " return resp\n",
440
  "\n",
441
  "demo = gr.Interface(fn=ask_query, inputs=\"text\", outputs=\"text\", allow_flagging=False)\n",
442
- " \n",
 
443
  "demo.launch(show_error=True)"
444
  ]
445
  }
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 222,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
35
  },
36
  {
37
  "cell_type": "code",
38
+ "execution_count": 223,
39
  "metadata": {},
40
  "outputs": [],
41
  "source": [
 
80
  },
81
  {
82
  "cell_type": "code",
83
+ "execution_count": 224,
84
  "metadata": {},
85
  "outputs": [],
86
  "source": [
 
181
  },
182
  {
183
  "cell_type": "code",
184
+ "execution_count": 225,
185
  "metadata": {},
186
  "outputs": [],
187
  "source": [
 
217
  },
218
  {
219
  "cell_type": "code",
220
+ "execution_count": 226,
221
  "metadata": {},
222
+ "outputs": [
223
+ {
224
+ "name": "stdout",
225
+ "output_type": "stream",
226
+ "text": [
227
+ "Chicken dishes:\n",
228
+ "Crispy Roasted Chicken\n",
229
+ "Roasted Spatchcocked Chicken With Potatoes\n",
230
+ "Easy Baked Chicken Thighs\n",
231
+ "Crispy Baked Chicken Thighs\n",
232
+ "Crispy and Tender Baked Chicken Thighs\n",
233
+ "Million Dollar Chicken\n",
234
+ "Simple Whole Roasted Chicken\n",
235
+ "Beer Can Chicken\n",
236
+ "Air Fryer Chicken Thighs\n",
237
+ "Happy Roast Chicken\n",
238
+ "\n",
239
+ "Desserts:\n",
240
+ "Chocolate Snack Cake\n",
241
+ "Charred Spiced Pears with Smoky Vanilla Cherry Sauce\n",
242
+ "Meringue Topped Banana Pudding\n",
243
+ "White Chocolate Cinnamon Toast Crunch Bars\n",
244
+ "Plum Cobbler for Two\n",
245
+ "Pumpkin Cheesecake Cookies\n",
246
+ "Chocolate Whipped Cottage Cheese\n",
247
+ "Nutella Ice Cream\n",
248
+ "3-Ingredient Banana Oatmeal Cookies\n",
249
+ "Caramel Apple Pie Cookies\n"
250
+ ]
251
+ }
252
+ ],
253
  "source": [
254
  "print('Chicken dishes:')\n",
255
  "for i in chickenDishList:\n",
256
+ " print(i['title'])\n",
257
  " \n",
258
+ "print('')\n",
259
  "print('Desserts:')\n",
260
  "for i in dessertList:\n",
261
  " print(i['title'])"
 
274
  },
275
  {
276
  "cell_type": "code",
277
+ "execution_count": 227,
278
  "metadata": {},
279
  "outputs": [
280
  {
 
283
  "text": [
284
  "\n",
285
  "\n",
286
+ "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n"
287
+ ]
288
+ },
289
+ {
290
+ "name": "stdout",
291
+ "output_type": "stream",
292
+ "text": [
293
  "\u001b[32;1m\u001b[1;3mI need to find the recipe for Nutella Ice Cream to know what tools are needed.\n",
294
  "Action: Dessert Recipes tool\n",
295
  "Action Input: Nutella Ice Cream\u001b[0m\n",
296
  "Observation: \u001b[33;1m\u001b[1;3m[{'title': 'Chocolate Snack Cake', 'url': 'https://www.allrecipes.com/chocolate-snack-cake-recipe-8350343'}, {'title': 'Charred Spiced Pears with Smoky Vanilla Cherry Sauce', 'url': 'https://www.allrecipes.com/charred-spiced-pears-with-smoky-vanilla-cherry-sauce-recipe-8347080'}, {'title': 'Meringue Topped Banana Pudding', 'url': 'https://www.allrecipes.com/meringue-topped-banana-pudding-recipe-8347040'}, {'title': 'White Chocolate Cinnamon Toast Crunch Bars', 'url': 'https://www.allrecipes.com/white-chocolate-cinnamon-toast-crunch-bars-recipe-7556790'}, {'title': 'Plum Cobbler for Two', 'url': 'https://www.allrecipes.com/plum-cobbler-for-two-recipe-8304143'}, {'title': 'Pumpkin Cheesecake Cookies', 'url': 'https://www.allrecipes.com/pumpkin-cheesecake-cookies-recipe-7972485'}, {'title': 'Chocolate Whipped Cottage Cheese', 'url': 'https://www.allrecipes.com/chocolate-whipped-cottage-cheese-recipe-8303272'}, {'title': 'Nutella Ice Cream', 'url': 'https://www.allrecipes.com/nutella-ice-cream-recipe-7508716'}, {'title': '3-Ingredient Banana Oatmeal Cookies', 'url': 'https://www.allrecipes.com/3-ingredient-banana-oatmeal-cookies-recipe-7972686'}, {'title': 'Caramel Apple Pie Cookies', 'url': 'https://www.allrecipes.com/caramel-apple-pie-cookies-recipe-7642173'}]\u001b[0m\n",
297
+ "Thought:\u001b[32;1m\u001b[1;3mI found the recipe for Nutella Ice Cream. Now I need to fetch the recipe to see what tools are needed.\n",
298
  "Action: Get a Recipe tool\n",
299
  "Action Input: https://www.allrecipes.com/nutella-ice-cream-recipe-7508716\u001b[0m\n",
300
  "Observation: \u001b[38;5;200m\u001b[1;3m{'@context': 'http://schema.org', '@type': ['Recipe'], 'headline': 'Nutella Ice Cream', 'datePublished': '2023-09-28T17:27:33.088-04:00', 'dateModified': '2023-10-12T11:27:16.725-04:00', 'author': [{'@type': 'Person', 'name': 'Laka kuharika - Easy Cook', 'url': 'https://www.allrecipes.com/cook/lakakuharica'}], 'description': 'This exquisite homemade Nutella ice cream is full of nutty flavor, and everyone will simply love it. Nutella gives this ice cream an unbelievable hazelnut taste.', 'name': 'Nutella Ice Cream', 'cookTime': 'PT15M', 'nutrition': {'@type': 'NutritionInformation', 'calories': '305 kcal', 'carbohydrateContent': '16 g', 'cholesterolContent': '156 mg', 'fiberContent': '1 g', 'proteinContent': '8 g', 'saturatedFatContent': '14 g', 'sodiumContent': '78 mg', 'sugarContent': '14 g', 'fatContent': '23 g', 'unsaturatedFatContent': '0 g'}, 'prepTime': 'PT10M', 'recipeCategory': ['Dessert'], 'recipeCuisine': ['American'], 'recipeIngredient': ['2 cups whole milk', '1 cup heavy cream, divided', '4 egg yolks', '1/2 teaspoon vanilla extract', '1/2\\xa0 cup cocoa hazelnut spread (such as Nutella®)', 'Hazelnuts, crushed, for garnish'], 'recipeInstructions': [{'@type': 'HowToStep', 'text': 'Combine milk, cream, and 1/2 cup sugar in a saucepan over medium heat. Cook until sugar dissolves, about 5 minutes.'}, {'@type': 'HowToStep', 'text': 'Beat egg yolks with the remaining sugar in a bowl with an electric mixer until eggs become thick and pale yellow, about 4 minutes.'}, {'@type': 'HowToStep', 'text': 'Pour 1/2 cup warm milk mixture into egg mixture and stir. Add this mixture back into the saucepan. Cook over very low heat, stirring constantly, until the mixture becomes thick enough to coat the back of a wooden spoon, 7 to 10 minutes.'}, {'@type': 'HowToStep', 'text': 'Place a strainer over a bowl and pour the warm custard mixture through the strainer. Stir in vanilla and hazelnut spread until it dissolves.'}, {'@type': 'HowToStep', 'text': 'Chill mixture completely, about 1 hour. Pour into an ice cream maker and churn until frozen according to manufacturer’s instructions, 15 to 20 minutes.'}, {'@type': 'HowToStep', 'text': 'Transfer to a plastic container and place in the freezer for an hour before serving. Top with crushed hazelnuts for serving.'}], 'recipeYield': ['8'], 'totalTime': 'PT160M', 'about': []}\u001b[0m\n",
301
+ "Thought:\u001b[32;1m\u001b[1;3mI now know the tools needed for the Nutella Ice Cream recipe.\n",
302
+ "Final Answer: The tools needed for the Nutella Ice Cream recipe are a saucepan, an electric mixer, a wooden spoon, a strainer, a bowl, an ice cream maker, and a plastic container.\u001b[0m\n",
303
  "\n",
304
  "\u001b[1m> Finished chain.\u001b[0m\n"
305
  ]
 
331
  "#query = \"Is there a Chicken recipe that's prepared with an alchohol? And if so how long does it take in total from start time to finish?\"\n",
332
  "#query = \"Which is healthier the Caramel Apple Pie Cookies or the beer chicken? Please explain how you got to your answer.\"\n",
333
  "#query = \"Is the moon closer to earth or the sun?\"\n",
334
+ "#query = \"How good are the apple pie cookies?\"\n",
335
  "query = \"What tools do I need for the Nutella Ice Cream?\"\n",
336
+ "\n",
337
  "#query = \"My bowl is broken, can I still make Nutella Ice Cream? Answer as a yes/no.\"\n",
338
  "\n",
339
  "response = agent({\"input\": f\"{system} {query}\"})\n"
 
341
  },
342
  {
343
  "cell_type": "code",
344
+ "execution_count": 228,
345
  "metadata": {},
346
  "outputs": [
347
  {
 
357
  "###########################\n",
358
  "\n",
359
  "Step: 2 of 2\n",
360
+ "Thought: I found the recipe for Nutella Ice Cream. Now I need to fetch the recipe to see what tools are needed.\n",
361
  "Action: Get a Recipe tool\n",
362
  "Action Input: https://www.allrecipes.com/nutella-ice-cream-recipe-7508716\n",
363
  "\n",
 
365
  "###########################\n",
366
  "\n",
367
  "\n",
368
+ "Final Thought: The tools needed for the Nutella Ice Cream recipe are a saucepan, an electric mixer, a wooden spoon, a strainer, a bowl, an ice cream maker, and a plastic container.\n"
369
  ]
370
  }
371
  ],
 
400
  },
401
  {
402
  "cell_type": "code",
403
+ "execution_count": 236,
404
  "metadata": {},
405
  "outputs": [
406
  {
 
415
  "name": "stdout",
416
  "output_type": "stream",
417
  "text": [
418
+ "Running on local URL: http://127.0.0.1:7899\n",
419
  "\n",
420
  "To create a public link, set `share=True` in `launch()`.\n"
421
  ]
 
423
  {
424
  "data": {
425
  "text/html": [
426
+ "<div><iframe src=\"http://127.0.0.1:7899/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
427
  ],
428
  "text/plain": [
429
  "<IPython.core.display.HTML object>"
 
436
  "data": {
437
  "text/plain": []
438
  },
439
+ "execution_count": 236,
440
  "metadata": {},
441
  "output_type": "execute_result"
 
 
 
 
 
 
 
 
 
 
 
 
 
442
  }
443
  ],
444
  "source": [
 
464
  " return resp\n",
465
  "\n",
466
  "demo = gr.Interface(fn=ask_query, inputs=\"text\", outputs=\"text\", allow_flagging=False)\n",
467
+ "#gr.Markdown(\"# Hello there\")\n",
468
+ "#gr.Examples(\"text\", \"text\")\n",
469
  "demo.launch(show_error=True)"
470
  ]
471
  }