How to use output parsers with a new long chain language.
So, as you know, right now, we can, uh, use the classic way and the new way in long chain.
Uh, the new way is what long chain calls long chain expression language.
And as you know, uh, the purpose of this, uh, new way is to make it easier.
And the the the the the code and also to make it easier to integrate long chain with other applications
like Lang Smith.
So in this exercise, we are going to compare the classic way with the new way, uh, using an output
parser.
So as usual, we connect with the dot m file in order to get the credentials to communicate with the
OpenAI API.
Then we import the string output parser and we create a chain in the classic way.
You are familiar with this.
So we are creating the chain with the language model, with the prompt template, and with the output
parser.
And we execute the chain with predict and the user input in the new way.
Instead of a entering the output parser in the classic way, we are adding an additional pipe and then
calling the a string output parser.
Uh, here.
Okay, remember that in the new way we are using invoke and we are entering the user input with a Python
dictionary.
So it's a more succinct, way more concise.
But uh, in my opinion this was a very easy to to do.
But now you have this other way.
And remember that in the long chain documentation you can see more examples and details about this new,
uh, methodology.
Remember that right now both of these methods work, but it's important to be prepared with, uh, with
this second method, because Lang Chain wants to focus the attention here in the following months and
years.