Skip to content

Commit 5cc659c

Browse files
committed
Update output_parsing.ipynb
1 parent 76ed393 commit 5cc659c

File tree

1 file changed

+101
-43
lines changed
  • Module 9 - GenAI (LLMs and Prompt Engineering)/6. Building Apps Powered by GenAI using LangChain/1. Introduction to LangChain/4. Output Parsing

1 file changed

+101
-43
lines changed

Module 9 - GenAI (LLMs and Prompt Engineering)/6. Building Apps Powered by GenAI using LangChain/1. Introduction to LangChain/4. Output Parsing/output_parsing.ipynb

Lines changed: 101 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,20 @@
159159
"text/plain": [
160160
"['paneer',\n",
161161
" 'basmati rice',\n",
162+
" 'yogurt',\n",
162163
" 'onions',\n",
163164
" 'tomatoes',\n",
164-
" 'yogurt',\n",
165165
" 'ginger',\n",
166166
" 'garlic',\n",
167167
" 'green chilies',\n",
168168
" 'spices (such as cumin',\n",
169169
" 'coriander',\n",
170170
" 'turmeric',\n",
171171
" 'garam masala)',\n",
172+
" 'cilantro',\n",
173+
" 'mint',\n",
172174
" 'ghee',\n",
173-
" 'vegetable oil',\n",
174-
" 'fresh coriander leaves',\n",
175-
" 'mint leaves',\n",
176-
" 'saffron',\n",
175+
" 'salt',\n",
177176
" 'water']"
178177
]
179178
},
@@ -185,7 +184,27 @@
185184
"source": [
186185
"input = {\"dish_name\": \"paneer biryani\", \"output_format_instructions\": csv_output_parser.get_format_instructions()}\n",
187186
"\n",
188-
"chain.invoke(input)"
187+
"response = chain.invoke(input)\n",
188+
"\n",
189+
"response"
190+
]
191+
},
192+
{
193+
"cell_type": "code",
194+
"execution_count": 8,
195+
"id": "d895f2a1-c08a-4582-b9da-393410cd63dc",
196+
"metadata": {},
197+
"outputs": [
198+
{
199+
"name": "stdout",
200+
"output_type": "stream",
201+
"text": [
202+
"<class 'list'>\n"
203+
]
204+
}
205+
],
206+
"source": [
207+
"print(type(response))"
189208
]
190209
},
191210
{
@@ -198,7 +217,7 @@
198217
},
199218
{
200219
"cell_type": "code",
201-
"execution_count": 8,
220+
"execution_count": 9,
202221
"id": "f999b0d3-839b-4b60-ae6a-ebf8390008c7",
203222
"metadata": {},
204223
"outputs": [],
@@ -210,7 +229,7 @@
210229
},
211230
{
212231
"cell_type": "code",
213-
"execution_count": 9,
232+
"execution_count": 10,
214233
"id": "2c3e7a50-9db7-4941-9c94-da1ac833cda1",
215234
"metadata": {},
216235
"outputs": [],
@@ -220,41 +239,60 @@
220239
},
221240
{
222241
"cell_type": "code",
223-
"execution_count": 10,
242+
"execution_count": 11,
224243
"id": "7ef84474-2fa0-42b4-88b7-990662dad134",
225244
"metadata": {},
226245
"outputs": [
227246
{
228247
"data": {
229248
"text/plain": [
230-
"{'paneerBiryani': {'ingredients': ['1 cup basmati rice',\n",
231-
" '200g paneer, cut into cubes',\n",
232-
" '1 onion, thinly sliced',\n",
233-
" '1 tomato, chopped',\n",
234-
" '1/2 cup yogurt',\n",
235-
" '1/2 cup fried onions',\n",
236-
" '1/4 cup chopped coriander leaves',\n",
237-
" '1/4 cup chopped mint leaves',\n",
238-
" '2 tablespoons biryani masala',\n",
239-
" '1 tablespoon ginger-garlic paste',\n",
240-
" '1 teaspoon red chili powder',\n",
241-
" '1/2 teaspoon turmeric powder',\n",
242-
" '1/2 teaspoon garam masala',\n",
243-
" '2 tablespoons ghee',\n",
244-
" '2 tablespoons oil',\n",
245-
" 'Salt to taste',\n",
246-
" 'Water']}}"
249+
"{'Main Ingredients': ['Paneer (Indian cottage cheese)',\n",
250+
" 'Basmati rice',\n",
251+
" 'Onion',\n",
252+
" 'Tomato',\n",
253+
" 'Green chili',\n",
254+
" 'Ginger',\n",
255+
" 'Garlic',\n",
256+
" 'Yogurt',\n",
257+
" 'Fresh cilantro',\n",
258+
" 'Mint leaves',\n",
259+
" 'Spices (such as cumin, coriander, turmeric, garam masala)',\n",
260+
" 'Oil or ghee',\n",
261+
" 'Salt'],\n",
262+
" 'Optional Ingredients': ['Mixed vegetables (like carrots, peas, bell peppers)',\n",
263+
" 'Cashews',\n",
264+
" 'Raisins']}"
247265
]
248266
},
249-
"execution_count": 10,
267+
"execution_count": 11,
250268
"metadata": {},
251269
"output_type": "execute_result"
252270
}
253271
],
254272
"source": [
255273
"input = {\"dish_name\": \"paneer biryani\", \"output_format_instructions\": json_output_parser.get_format_instructions()}\n",
256274
"\n",
257-
"chain.invoke(input)"
275+
"response = chain.invoke(input)\n",
276+
"\n",
277+
"response"
278+
]
279+
},
280+
{
281+
"cell_type": "code",
282+
"execution_count": 12,
283+
"id": "6193c287-1341-4d08-8482-b9d34b0b2f5e",
284+
"metadata": {},
285+
"outputs": [
286+
{
287+
"name": "stdout",
288+
"output_type": "stream",
289+
"text": [
290+
"<class 'dict'>\n"
291+
]
292+
}
293+
],
294+
"source": [
295+
"print(type(response))"
258296
]
259297
},
260298
{
@@ -269,7 +307,7 @@
269307
},
270308
{
271309
"cell_type": "code",
272-
"execution_count": 11,
310+
"execution_count": 13,
273311
"id": "072bd02b-c06d-4d05-97b2-f62862e8dcc2",
274312
"metadata": {},
275313
"outputs": [],
@@ -281,17 +319,17 @@
281319
},
282320
{
283321
"cell_type": "code",
284-
"execution_count": 12,
322+
"execution_count": 14,
285323
"id": "00755d45-e38a-4c09-8412-c12eb4540175",
286324
"metadata": {},
287325
"outputs": [
288326
{
289327
"data": {
290328
"text/plain": [
291-
"\"Write a datetime string that matches the following pattern: '%Y-%m-%dT%H:%M:%S.%fZ'.\\n\\nExamples: 1892-01-30T12:13:48.068611Z, 0561-05-13T02:27:55.160011Z, 1699-05-11T04:40:29.696518Z\\n\\nReturn ONLY this string, no other words!\""
329+
"\"Write a datetime string that matches the following pattern: '%Y-%m-%dT%H:%M:%S.%fZ'.\\n\\nExamples: 0766-08-12T18:44:49.184246Z, 1953-02-26T13:12:24.798157Z, 1621-07-14T00:16:29.137230Z\\n\\nReturn ONLY this string, no other words!\""
292330
]
293331
},
294-
"execution_count": 12,
332+
"execution_count": 14,
295333
"metadata": {},
296334
"output_type": "execute_result"
297335
}
@@ -304,7 +342,7 @@
304342
},
305343
{
306344
"cell_type": "code",
307-
"execution_count": 13,
345+
"execution_count": 15,
308346
"id": "3bd3acd4-2cda-4776-a90c-968e87133d9f",
309347
"metadata": {},
310348
"outputs": [],
@@ -322,7 +360,7 @@
322360
},
323361
{
324362
"cell_type": "code",
325-
"execution_count": 14,
363+
"execution_count": 16,
326364
"id": "c18efe6f-b8d4-4839-b8d0-8cfc01fc3587",
327365
"metadata": {},
328366
"outputs": [],
@@ -335,7 +373,7 @@
335373
},
336374
{
337375
"cell_type": "code",
338-
"execution_count": 15,
376+
"execution_count": 17,
339377
"id": "69182c25-2ba5-4ad4-9287-41b31011880f",
340378
"metadata": {},
341379
"outputs": [
@@ -345,7 +383,7 @@
345383
"datetime.datetime(1947, 8, 15, 0, 0)"
346384
]
347385
},
348-
"execution_count": 15,
386+
"execution_count": 17,
349387
"metadata": {},
350388
"output_type": "execute_result"
351389
}
@@ -355,7 +393,27 @@
355393
"\n",
356394
"input = {\"question\": \"What is Indian Independence Day?\", \"output_format_instructions\": output_parser.get_format_instructions()}\n",
357395
"\n",
358-
"chain.invoke(input)"
396+
"response = chain.invoke(input)\n",
397+
"\n",
398+
"response"
399+
]
400+
},
401+
{
402+
"cell_type": "code",
403+
"execution_count": 18,
404+
"id": "0520093c-fd7c-4ab0-9c28-bd3aa8a64e6c",
405+
"metadata": {},
406+
"outputs": [
407+
{
408+
"name": "stdout",
409+
"output_type": "stream",
410+
"text": [
411+
"<class 'datetime.datetime'>\n"
412+
]
413+
}
414+
],
415+
"source": [
416+
"print(type(response))"
359417
]
360418
},
361419
{
@@ -376,7 +434,7 @@
376434
},
377435
{
378436
"cell_type": "code",
379-
"execution_count": 14,
437+
"execution_count": 19,
380438
"id": "88654381-1109-4e7d-a095-181623aea87d",
381439
"metadata": {},
382440
"outputs": [],
@@ -394,7 +452,7 @@
394452
},
395453
{
396454
"cell_type": "code",
397-
"execution_count": 15,
455+
"execution_count": 20,
398456
"id": "d7617763-9a91-48fb-b34f-89ee49951bde",
399457
"metadata": {},
400458
"outputs": [
@@ -420,7 +478,7 @@
420478
},
421479
{
422480
"cell_type": "code",
423-
"execution_count": 16,
481+
"execution_count": 21,
424482
"id": "aeae8a81-db61-498a-8a5a-f50af164b3d0",
425483
"metadata": {},
426484
"outputs": [],
@@ -441,7 +499,7 @@
441499
},
442500
{
443501
"cell_type": "code",
444-
"execution_count": 17,
502+
"execution_count": 22,
445503
"id": "fe0a8de3-da21-46f5-8a07-a2872d420b66",
446504
"metadata": {},
447505
"outputs": [],
@@ -453,7 +511,7 @@
453511
},
454512
{
455513
"cell_type": "code",
456-
"execution_count": 18,
514+
"execution_count": 23,
457515
"id": "b39be662-5ddf-449b-8c2a-c6269dcc4971",
458516
"metadata": {},
459517
"outputs": [
@@ -463,7 +521,7 @@
463521
"Song(name='Kal Ho Naa Ho', geners=['Bollywood', 'Romantic'])"
464522
]
465523
},
466-
"execution_count": 18,
524+
"execution_count": 23,
467525
"metadata": {},
468526
"output_type": "execute_result"
469527
}

0 commit comments

Comments
 (0)