1
00:00:02,710 --> 00:00:08,080
How to use output parsers with a new long chain language.

2
00:00:08,770 --> 00:00:15,520
So, as you know, right now, we can, uh, use the classic way and the new way in long chain.

3
00:00:15,970 --> 00:00:20,950
Uh, the new way is what long chain calls long chain expression language.

4
00:00:20,950 --> 00:00:27,400
And as you know, uh, the purpose of this, uh, new way is to make it easier.

5
00:00:27,400 --> 00:00:36,220
And the the the the the code and also to make it easier to integrate long chain with other applications

6
00:00:36,220 --> 00:00:37,900
like Lang Smith.

7
00:00:37,900 --> 00:00:45,400
So in this exercise, we are going to compare the classic way with the new way, uh, using an output

8
00:00:45,400 --> 00:00:46,240
parser.

9
00:00:46,420 --> 00:00:53,560
So as usual, we connect with the dot m file in order to get the credentials to communicate with the

10
00:00:53,560 --> 00:00:55,480
OpenAI API.

11
00:00:55,750 --> 00:01:03,310
Then we import the string output parser and we create a chain in the classic way.

12
00:01:03,310 --> 00:01:04,690
You are familiar with this.

13
00:01:04,690 --> 00:01:11,170
So we are creating the chain with the language model, with the prompt template, and with the output

14
00:01:11,170 --> 00:01:11,800
parser.

15
00:01:11,980 --> 00:01:18,610
And we execute the chain with predict and the user input in the new way.

16
00:01:18,610 --> 00:01:28,000
Instead of a entering the output parser in the classic way, we are adding an additional pipe and then

17
00:01:28,000 --> 00:01:32,410
calling the a string output parser.

18
00:01:32,530 --> 00:01:34,060
Uh, here.

19
00:01:34,060 --> 00:01:40,840
Okay, remember that in the new way we are using invoke and we are entering the user input with a Python

20
00:01:40,840 --> 00:01:41,560
dictionary.

21
00:01:41,560 --> 00:01:46,030
So it's a more succinct, way more concise.

22
00:01:46,030 --> 00:01:51,070
But uh, in my opinion this was a very easy to to do.

23
00:01:51,070 --> 00:01:53,530
But now you have this other way.

24
00:01:53,530 --> 00:02:00,850
And remember that in the long chain documentation you can see more examples and details about this new,

25
00:02:00,880 --> 00:02:01,750
uh, methodology.

26
00:02:01,810 --> 00:02:09,310
Remember that right now both of these methods work, but it's important to be prepared with, uh, with

27
00:02:09,310 --> 00:02:15,670
this second method, because Lang Chain wants to focus the attention here in the following months and

28
00:02:15,670 --> 00:02:16,360
years.

