WEBVTT

00:00.440 --> 00:04.160
Let me first import the prompt template class.

00:05.160 --> 00:06.560
What are prompt templates?

00:06.640 --> 00:11.240
Well, large language models receive as input something which is called a prompt.

00:11.560 --> 00:18.240
What is a prompt is simply text input that we give the LLM and the LLM processes it and returns us an

00:18.240 --> 00:18.880
output.

00:19.360 --> 00:25.480
Now, if you want to learn the formal definition of prompt and what elements it comprised of, then

00:25.480 --> 00:31.200
feel free to check out this video where I elaborately break down all the elements of a prompt formally.

00:31.560 --> 00:33.480
Okay, that's pretty straightforward.

00:33.720 --> 00:40.760
However, when we're dealing with programmatic access to the LLM, then we might want to take a prompt

00:40.760 --> 00:42.120
and to give it parameters.

00:42.520 --> 00:46.440
So one time I want to run this prompt where the product is cat food.

00:46.480 --> 00:49.160
The other time where the product is purchase.

00:49.200 --> 00:54.560
And for the last time, let's say I want to run it where the product is a piano.

00:55.000 --> 00:55.320
Okay.

00:55.360 --> 01:01.100
So for each different prompt I will get different output because the input was different.

01:01.780 --> 01:05.620
So this is the first abstraction that blockchain is introducing us.

01:05.660 --> 01:10.540
It's a prompt template and it's simply a wrapper class around a prompt.

01:10.660 --> 01:14.260
So it adds functionality to prompt to receive an input.

01:14.260 --> 01:18.380
For example, we can run this prompt now many times with different inputs.

01:18.580 --> 01:25.300
And the gist of it is that it simply helps us format things into strings, which are eventually being

01:25.300 --> 01:26.460
sent to llms.

01:27.060 --> 01:32.740
It also provides a lot more functionality than that which we are going to explore and check out in the

01:32.740 --> 01:33.220
course.

01:34.100 --> 01:34.540
Cool.

01:34.580 --> 01:44.940
So let's now import the chat OpenAI class, which is a chat model and a wrapper over the OpenAI API.

01:45.300 --> 01:52.820
The chat model object is often going to be our primary interface for interacting with large language

01:52.820 --> 01:53.460
models.

01:53.740 --> 02:00.920
And it is a standard way that LinkedIn help us to talk to those llms like GPT four.

02:01.360 --> 02:09.880
Anthropic lad, Google, Gemini, and even open source models like Llama by Facebook via O llama.

02:11.840 --> 02:20.480
So historically, many Llms just took a single string of text as an input and returned as a single string

02:20.480 --> 02:21.440
of text.

02:21.640 --> 02:29.560
However, modern llms are designed for conversation and interaction between a user, so they work best

02:29.560 --> 02:36.480
when we provide them with a list of messages representing the dialogue and the history, and they return

02:36.480 --> 02:37.880
us a message back.

02:38.120 --> 02:41.160
And this is the core of the chat model interface.

02:41.440 --> 02:48.560
The input is going to be a list of structured messages like a system instruction, user questions or

02:48.600 --> 02:49.680
AI responses.

02:49.920 --> 02:56.080
And the output is going to be an AI message representing the response of the large language model.

02:56.480 --> 03:05.180
However, chat model objects are very powerful and beyond generating human like text, they have very

03:05.180 --> 03:08.940
cool capabilities which a lot of them will be using in the course.

03:08.940 --> 03:14.100
And if you're curious about those capabilities, you can check out this video in the glossary section.

03:14.100 --> 03:19.220
But don't worry about it too much because we will be covering this hands on in the course.

03:19.580 --> 03:21.500
All right, let's go back to the code.

03:21.860 --> 03:30.260
And one of the best habits you can develop as a developer is to look inside the actual source code of

03:30.540 --> 03:33.660
the frameworks you're working with, and in this case Linkchain.

03:33.860 --> 03:39.260
And exploring the implementations directly is a great way to really understand what's going on behind

03:39.260 --> 03:39.900
the scenes.

03:39.900 --> 03:42.300
And we're going to be doing a lot of this in the course.

03:42.300 --> 03:44.260
So let me just show you how to do it.

03:44.260 --> 03:48.420
So I'm simply going to click command and on the class name.

03:48.420 --> 03:50.700
And then we can see the implementation of the class.

03:55.260 --> 03:57.720
Let's do the same for chat OpenAI.

04:00.960 --> 04:08.280
And here we can check out all the documentation, which is hardcoded in the source code itself and the

04:08.280 --> 04:09.480
functionality itself.

04:09.480 --> 04:11.280
But we're not going to cover this right now.

04:11.280 --> 04:13.320
This is a very high level overview.

04:13.360 --> 04:17.960
And of course, I'm not expecting you to know the inside implementation of all of those classes and

04:18.000 --> 04:18.600
objects.

04:18.760 --> 04:21.600
We're here to write our first link chain chain.

04:21.960 --> 04:30.480
And a link chain chain is a workflow that connects multiple components in linked chain together.

04:30.480 --> 04:37.360
In a sequence where the output of one step becomes the input of the next step.

04:37.680 --> 04:45.880
And just to give you a bit more detail here, each step can be an LM call, a prompt, a plate data

04:45.880 --> 04:50.440
transformation or tool call, and we'll get to tool calls.

04:50.440 --> 04:51.560
Don't worry about it.

04:51.560 --> 04:53.880
And it can even be another chain.

04:54.200 --> 05:00.220
And a chain Let us go beyond just making a single LLM prompt in response.

05:00.500 --> 05:07.220
So, for example, instead of asking a model one big question, we might want to format the user query

05:07.220 --> 05:09.020
into a structured prompt.

05:09.300 --> 05:11.940
We want to send this prompt to the LLM.

05:12.260 --> 05:19.540
Then we want to parse the llms output into some structured data, and then use this data to call to

05:19.580 --> 05:25.020
an external API and feed the API response into another LLM prompt.

05:25.180 --> 05:30.100
And with this composition idea, we can build some very advanced tech here.

05:30.300 --> 05:37.580
And this is why LinkedIn became so popular and so widely adopted and used, because it was the first

05:37.900 --> 05:45.420
framework that really allowed us to do those really complex things and to build on top of those llms

05:45.460 --> 05:52.820
some very cool stuff like agents, and we'll be diving very deep into agents, so don't worry about

05:52.820 --> 05:53.100
it.
