-: This is a quick video showing you how you can
actually chain multiple LLM requests together.
So we've got our from item getter,
we also import ChatOpen AI,
chat prompt template, and a string output passer.
Now we have two prompts that we're setting up.
Firstly, we have the what is the city person is from,
and we also have the what country is the city?
City in respond in language.
We set up our LLM model,
which in this case is a ChatOpen AI.
We then have the first chain, which is prompt one,
pipe model, pipe string output passer.
And then that gets associated
with a key inside of chain two.
So you can see the result of chain one
will be under the city key, right?
And then the language we are getting from the item getter.
That will then get piped into prompt two.
So that's how we're getting this citY in curly braces,
it says its from our first chain that you can see here.
That then gets piped into the model,
which then also gets piped into a string output passer.
So let's do the invoke on the second chain,
which we'll use the first chain.
So we invoke with a person
and then the language in Spanish.
And then what you'll see is
we're basically saying, what is the city person?
So that'll be what is the city Obama is from.
And then basically when we get the city,
we're then asking what country is the city in?
And then we're asking it to respond in Spanish.
So this is an example of
where you have more than one LLM request.
You've got a chain here, and you've got a chain here,
and you are using the output of chain one
and assigning it to a key of city,
which will then be used
in the prompt template, prompt two.
So the best way that I would recommend thinking
about this is always working backwards.
Like where is the last prompt?
Like what kind of keys does it require?
Oh, okay. It requires a city key.
Oh, that comes from this prompt chain.
The other interesting thing to be thinking about
is you can't just do prompt pipe model
because you can't pass, you know,
an open AI or a lang chain class
into the next as a prompt value.
So what you really need to do is make sure
that you use these string output passes
so the output of chain one
gets associated with a string,
which can then be injected into
the prompt template for prompt two.
Cool. So that was a little bit on making some chains.