thrag commited on
Commit
6caa33e
1 Parent(s): 1a58233

Swapped pywin32 for pypiwin32, running

Browse files
Files changed (2) hide show
  1. demo-tools-1.ipynb +44 -66
  2. requirements.txt +0 -0
demo-tools-1.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 239,
6
  "metadata": {},
7
  "outputs": [
8
  {
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "cell_type": "code",
40
- "execution_count": 237,
41
  "metadata": {},
42
  "outputs": [
43
  {
@@ -46,7 +46,7 @@
46
  "False"
47
  ]
48
  },
49
- "execution_count": 237,
50
  "metadata": {},
51
  "output_type": "execute_result"
52
  }
@@ -64,7 +64,7 @@
64
  },
65
  {
66
  "cell_type": "code",
67
- "execution_count": 223,
68
  "metadata": {},
69
  "outputs": [],
70
  "source": [
@@ -109,7 +109,7 @@
109
  },
110
  {
111
  "cell_type": "code",
112
- "execution_count": 224,
113
  "metadata": {},
114
  "outputs": [],
115
  "source": [
@@ -197,8 +197,7 @@
197
  " \"title\": \"Happy Roast Chicken\",\n",
198
  " \"url\": \"https://www.allrecipes.com/recipe/214478/happy-roast-chicken/\"\n",
199
  " }\n",
200
- "]\n",
201
- "\n"
202
  ]
203
  },
204
  {
@@ -210,7 +209,7 @@
210
  },
211
  {
212
  "cell_type": "code",
213
- "execution_count": 225,
214
  "metadata": {},
215
  "outputs": [],
216
  "source": [
@@ -246,7 +245,7 @@
246
  },
247
  {
248
  "cell_type": "code",
249
- "execution_count": 226,
250
  "metadata": {},
251
  "outputs": [
252
  {
@@ -303,7 +302,7 @@
303
  },
304
  {
305
  "cell_type": "code",
306
- "execution_count": null,
307
  "metadata": {},
308
  "outputs": [],
309
  "source": [
@@ -324,7 +323,6 @@
324
  " max_iterations=7, \n",
325
  " return_intermediate_steps=True\n",
326
  ")\n",
327
- "\n",
328
  "system = \"If the answer is not in the tools or context passed to you then don't answer. \\nIf you don't know the answer then say so.\" \n",
329
  "#query = \"Can you show tell me what ingredients I need for the first baked chicken recipe?\"\n",
330
  "#query = \"Can you show tell me what ingredients I need for the last baked chicken recipe? \"\n",
@@ -334,59 +332,10 @@
334
  "#query = \"Is the moon closer to earth or the sun?\"\n",
335
  "#query = \"How good are the apple pie cookies?\"\n",
336
  "query = \"What tools do I need for the Nutella Ice Cream?\"\n",
337
- "\n",
338
  "#query = \"My bowl is broken, can I still make Nutella Ice Cream? Answer as a yes/no.\"\n",
339
- "\n",
340
  "#response = agent({\"input\": f\"{system} {query}\"})\n"
341
  ]
342
  },
343
- {
344
- "cell_type": "code",
345
- "execution_count": 228,
346
- "metadata": {},
347
- "outputs": [
348
- {
349
- "name": "stdout",
350
- "output_type": "stream",
351
- "text": [
352
- "Step: 1 of 2\n",
353
- "Thought: I need to find the recipe for Nutella Ice Cream to know what tools are needed.\n",
354
- "Action: Dessert Recipes tool\n",
355
- "Action Input: Nutella Ice Cream\n",
356
- "\n",
357
- "Action response: [{'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'}]\n",
358
- "###########################\n",
359
- "\n",
360
- "Step: 2 of 2\n",
361
- "Thought: I found the recipe for Nutella Ice Cream. Now I need to fetch the recipe to see what tools are needed.\n",
362
- "Action: Get a Recipe tool\n",
363
- "Action Input: https://www.allrecipes.com/nutella-ice-cream-recipe-7508716\n",
364
- "\n",
365
- "Action response: {'@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': []}\n",
366
- "###########################\n",
367
- "\n",
368
- "\n",
369
- "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"
370
- ]
371
- }
372
- ],
373
- "source": [
374
- "# from langchain.load.dump import dumps\n",
375
- "\n",
376
- "# stepsDict = json.loads(dumps(response[\"intermediate_steps\"], pretty=True))\n",
377
- "# for i in range(len(stepsDict)):\n",
378
- "# print(f'Step: {i+1} of {len(stepsDict)}')\n",
379
- "# print(f\"Thought: {stepsDict[i][0]['kwargs']['log']}\")\n",
380
- "# print('')\n",
381
- "# print(f\"Action response: {stepsDict[i][1]}\")\n",
382
- "# print('###########################')\n",
383
- "# print('')\n",
384
- "\n",
385
- "# print('')\n",
386
- "# print(f\"Final Thought: {response['output']}\")\n",
387
- "\n"
388
- ]
389
- },
390
  {
391
  "cell_type": "markdown",
392
  "metadata": {},
@@ -396,7 +345,7 @@
396
  },
397
  {
398
  "cell_type": "code",
399
- "execution_count": 236,
400
  "metadata": {},
401
  "outputs": [
402
  {
@@ -411,7 +360,7 @@
411
  "name": "stdout",
412
  "output_type": "stream",
413
  "text": [
414
- "Running on local URL: http://127.0.0.1:7899\n",
415
  "\n",
416
  "To create a public link, set `share=True` in `launch()`.\n"
417
  ]
@@ -419,7 +368,7 @@
419
  {
420
  "data": {
421
  "text/html": [
422
- "<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>"
423
  ],
424
  "text/plain": [
425
  "<IPython.core.display.HTML object>"
@@ -432,7 +381,7 @@
432
  "data": {
433
  "text/plain": []
434
  },
435
- "execution_count": 236,
436
  "metadata": {},
437
  "output_type": "execute_result"
438
  }
@@ -467,9 +416,38 @@
467
  },
468
  {
469
  "cell_type": "code",
470
- "execution_count": 240,
471
  "metadata": {},
472
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  "source": [
474
  "# import gradio as gr\n",
475
  "\n",
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 241,
6
  "metadata": {},
7
  "outputs": [
8
  {
 
37
  },
38
  {
39
  "cell_type": "code",
40
+ "execution_count": 242,
41
  "metadata": {},
42
  "outputs": [
43
  {
 
46
  "False"
47
  ]
48
  },
49
+ "execution_count": 242,
50
  "metadata": {},
51
  "output_type": "execute_result"
52
  }
 
64
  },
65
  {
66
  "cell_type": "code",
67
+ "execution_count": 243,
68
  "metadata": {},
69
  "outputs": [],
70
  "source": [
 
109
  },
110
  {
111
  "cell_type": "code",
112
+ "execution_count": 244,
113
  "metadata": {},
114
  "outputs": [],
115
  "source": [
 
197
  " \"title\": \"Happy Roast Chicken\",\n",
198
  " \"url\": \"https://www.allrecipes.com/recipe/214478/happy-roast-chicken/\"\n",
199
  " }\n",
200
+ "]"
 
201
  ]
202
  },
203
  {
 
209
  },
210
  {
211
  "cell_type": "code",
212
+ "execution_count": 245,
213
  "metadata": {},
214
  "outputs": [],
215
  "source": [
 
245
  },
246
  {
247
  "cell_type": "code",
248
+ "execution_count": 246,
249
  "metadata": {},
250
  "outputs": [
251
  {
 
302
  },
303
  {
304
  "cell_type": "code",
305
+ "execution_count": 247,
306
  "metadata": {},
307
  "outputs": [],
308
  "source": [
 
323
  " max_iterations=7, \n",
324
  " return_intermediate_steps=True\n",
325
  ")\n",
 
326
  "system = \"If the answer is not in the tools or context passed to you then don't answer. \\nIf you don't know the answer then say so.\" \n",
327
  "#query = \"Can you show tell me what ingredients I need for the first baked chicken recipe?\"\n",
328
  "#query = \"Can you show tell me what ingredients I need for the last baked chicken recipe? \"\n",
 
332
  "#query = \"Is the moon closer to earth or the sun?\"\n",
333
  "#query = \"How good are the apple pie cookies?\"\n",
334
  "query = \"What tools do I need for the Nutella Ice Cream?\"\n",
 
335
  "#query = \"My bowl is broken, can I still make Nutella Ice Cream? Answer as a yes/no.\"\n",
 
336
  "#response = agent({\"input\": f\"{system} {query}\"})\n"
337
  ]
338
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  {
340
  "cell_type": "markdown",
341
  "metadata": {},
 
345
  },
346
  {
347
  "cell_type": "code",
348
+ "execution_count": 249,
349
  "metadata": {},
350
  "outputs": [
351
  {
 
360
  "name": "stdout",
361
  "output_type": "stream",
362
  "text": [
363
+ "Running on local URL: http://127.0.0.1:7900\n",
364
  "\n",
365
  "To create a public link, set `share=True` in `launch()`.\n"
366
  ]
 
368
  {
369
  "data": {
370
  "text/html": [
371
+ "<div><iframe src=\"http://127.0.0.1:7900/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
372
  ],
373
  "text/plain": [
374
  "<IPython.core.display.HTML object>"
 
381
  "data": {
382
  "text/plain": []
383
  },
384
+ "execution_count": 249,
385
  "metadata": {},
386
  "output_type": "execute_result"
387
  }
 
416
  },
417
  {
418
  "cell_type": "code",
419
+ "execution_count": 250,
420
  "metadata": {},
421
+ "outputs": [
422
+ {
423
+ "name": "stdout",
424
+ "output_type": "stream",
425
+ "text": [
426
+ "\n",
427
+ "\n",
428
+ "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
429
+ "\u001b[32;1m\u001b[1;3mThe question is asking for a subjective opinion, which is not something that can be determined using the tools available. \n",
430
+ "Final Answer: As an AI, I don't have personal experiences or opinions. However, many people enjoy chicken for its versatility and protein content.\u001b[0m\n",
431
+ "\n",
432
+ "\u001b[1m> Finished chain.\u001b[0m\n",
433
+ "\n",
434
+ "\n",
435
+ "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
436
+ "\u001b[32;1m\u001b[1;3mThe question is asking for the tools needed to bake a chicken, not a specific recipe. However, I can use the Chicken Recipes tool to find a recipe for baked chicken, and then use the Get a Recipe tool to find out what tools are needed for that recipe.\n",
437
+ "Action: Chicken Recipes tool\n",
438
+ "Action Input: \"baked chicken\"\u001b[0m\n",
439
+ "Observation: \u001b[36;1m\u001b[1;3m[{'title': 'Crispy Roasted Chicken', 'url': 'https://www.allrecipes.com/recipe/228363/crispy-roasted-chicken/'}, {'title': 'Roasted Spatchcocked Chicken With Potatoes', 'url': 'https://www.allrecipes.com/recipe/254877/roasted-spatchcocked-chicken-with-potatoes/'}, {'title': 'Easy Baked Chicken Thighs', 'url': 'https://www.allrecipes.com/recipe/235153/easy-baked-chicken-thighs/'}, {'title': 'Crispy Baked Chicken Thighs', 'url': 'https://www.allrecipes.com/recipe/258878/crispy-baked-chicken-thighs/'}, {'title': 'Crispy and Tender Baked Chicken Thighs', 'url': 'https://www.allrecipes.com/recipe/235151/crispy-and-tender-baked-chicken-thighs/'}, {'title': 'Million Dollar Chicken', 'url': 'https://www.allrecipes.com/recipe/233953/million-dollar-chicken/'}, {'title': 'Simple Whole Roasted Chicken', 'url': 'https://www.allrecipes.com/recipe/70679/simple-whole-roasted-chicken/'}, {'title': 'Beer Can Chicken', 'url': 'https://www.allrecipes.com/recipe/214618/beer-can-chicken/'}, {'title': 'Air Fryer Chicken Thighs', 'url': 'https://www.allrecipes.com/recipe/272858/air-fryer-chicken-thighs/'}, {'title': 'Happy Roast Chicken', 'url': 'https://www.allrecipes.com/recipe/214478/happy-roast-chicken/'}]\u001b[0m\n",
440
+ "Thought:\u001b[32;1m\u001b[1;3mI have found a list of chicken recipes. I will choose the first one, 'Crispy Roasted Chicken', and use the Get a Recipe tool to find out what tools are needed for this recipe.\n",
441
+ "Action: Get a Recipe tool\n",
442
+ "Action Input: 'https://www.allrecipes.com/recipe/228363/crispy-roasted-chicken/'\u001b[0m\n",
443
+ "Observation: \u001b[38;5;200m\u001b[1;3m{'@context': 'http://schema.org', '@type': ['Recipe'], 'headline': 'Crispy Roasted Chicken', 'datePublished': '2014-08-26T18:22:55.000-04:00', 'dateModified': '2023-01-30T04:44:54.000-05:00', 'author': [{'@type': 'Person', 'name': 'Doc Simonson', 'url': 'https://www.allrecipes.com/cook/docsimonson'}], 'description': 'This roasted half chicken is prepared Bavarian-style with spices and herbs, including caraway, sage, fennel, garlic, rosemary, coriander, and paprika.', 'name': 'Crispy Roasted Chicken', 'aggregateRating': {'@type': 'AggregateRating', 'ratingValue': '4.7', 'ratingCount': '134'}, 'cookTime': 'PT60M', 'nutrition': {'@type': 'NutritionInformation', 'calories': '495 kcal', 'carbohydrateContent': '3 g', 'cholesterolContent': '129 mg', 'fiberContent': '1 g', 'proteinContent': '42 g', 'saturatedFatContent': '8 g', 'sodiumContent': '446 mg', 'sugarContent': '1 g', 'fatContent': '35 g', 'unsaturatedFatContent': '0 g'}, 'prepTime': 'PT20M', 'recipeCategory': ['Dinner', 'Drink'], 'recipeCuisine': ['German'], 'recipeIngredient': ['1 teaspoon kosher salt', '0.5 teaspoon caraway seeds', '0.5 teaspoon dried sage', '0.25 teaspoon fennel seeds', '0.25 teaspoon coriander seeds', '0.25 teaspoon dried rosemary', '2 tablespoons paprika', '2 teaspoons garlic powder', '2 teaspoons all-purpose flour', '1 teaspoon onion powder', '5 tablespoons vegetable oil', '1 (4 pound) broiler-fryer chicken, cut in half lengthwise'], 'recipeInstructions': [{'@type': 'HowToStep', 'text': 'Preheat the oven to 425 degrees F (220 degrees C).'}, {'@type': 'HowToStep', 'text': 'Combine kosher salt, caraway, sage, fennel, coriander, and rosemary in a spice grinder or mortar. Grind to a coarse powder. Transfer spice mixture to a bowl; stir in paprika, garlic powder, flour, and onion powder. Mix in vegetable oil to make a smooth paste.'}, {'@type': 'HowToStep', 'text': 'Pat chicken halves dry with paper towels and tuck wing tips behind the back. Brush spice paste onto chicken halves, coating all sides and seasoning under wings and legs. Place chicken halves, skin-sides up, in a baking dish or roasting pan, leaving space around chickens so halves aren&#39;t touching.'}, {'@type': 'HowToStep', 'text': 'Roast in the preheated oven until no longer pink at the bone and the juices run clear, about 1 hour. An instant-read thermometer inserted into the thickest part of the thigh, near the bone, should read 165 degrees F (74 degrees C). Remove from the oven and let rest for 10 minutes before slicing.'}], 'recipeYield': ['6'], 'totalTime': 'PT90M', 'about': []}\u001b[0m\n",
444
+ "Thought:\u001b[32;1m\u001b[1;3mThe recipe provides a list of instructions which mention the tools needed to bake the chicken.\n",
445
+ "Final Answer: The tools needed to bake a chicken according to the 'Crispy Roasted Chicken' recipe are: an oven, a spice grinder or mortar, a bowl, a brush, a baking dish or roasting pan, paper towels, and an instant-read thermometer.\u001b[0m\n",
446
+ "\n",
447
+ "\u001b[1m> Finished chain.\u001b[0m\n"
448
+ ]
449
+ }
450
+ ],
451
  "source": [
452
  "# import gradio as gr\n",
453
  "\n",
requirements.txt DELETED
Binary file (4.54 kB)