WEBVTT

00:00.080 --> 00:00.600
Hey there.

00:00.640 --> 00:01.240
Eden here.

00:01.240 --> 00:05.760
And in this video we're going to be bootstrapping our environment for the project.

00:05.760 --> 00:08.800
So it's going to be a bit long around 15 minutes.

00:08.800 --> 00:14.560
And it's not going to be interesting because let's face it, bootstrapping a Python environment is not

00:14.560 --> 00:15.680
that interesting.

00:15.720 --> 00:17.840
We'll be cloning the course repository.

00:17.880 --> 00:20.720
We will create a new branch that will be working in.

00:20.760 --> 00:23.560
We'll be using UV as our package manager.

00:23.560 --> 00:27.880
We'll install some dependencies, configure the API keys for the LLM.

00:27.920 --> 00:31.960
We're going to be talking to defining environment variables.

00:31.960 --> 00:37.360
And by the end of this video we'll have our environment ready to write our first link chain chain.

00:37.720 --> 00:39.120
So let's go to the code.

00:39.120 --> 00:41.920
So this is the course's GitHub repository.

00:42.080 --> 00:45.120
And I'll be linking it in the video's resources.

00:45.120 --> 00:47.640
And you can also find it in the introduction section.

00:47.840 --> 00:52.360
And all the code that we'll be writing can be accessed via this repository.

00:52.360 --> 00:56.080
So I will be linking the exact commit code of every video.

00:56.080 --> 00:59.720
So you can have the exact code as I'm having in running.

00:59.760 --> 01:00.200
All right.

01:00.200 --> 01:02.520
So let's go now and set up our environment.

01:02.520 --> 01:05.880
And the first thing I want to do is to clone this repository.

01:06.160 --> 01:09.520
So I'm going to go and copy here this link here.

01:09.720 --> 01:11.560
And let me open my terminal.

01:12.920 --> 01:15.600
Let me go now and CD into my desktop.

01:15.600 --> 01:17.400
And here I'll be cloning the code.

01:18.360 --> 01:22.680
And let's now write git clone and paste here the URL.

01:25.360 --> 01:30.600
And now that it's done we can see into the directory which is called link chain course.

01:31.840 --> 01:34.680
And let me open my IDE from here.

01:34.680 --> 01:38.440
And I'm going to be using cursor for the next couple of videos.

01:38.440 --> 01:40.920
But you can use any IDE that you want.

01:41.320 --> 01:42.680
You can use PyCharm.

01:42.680 --> 01:44.240
You can use VSCode.

01:44.560 --> 01:47.200
Hey you can even use vim if you're really, really brave.

01:47.480 --> 01:49.960
The IDE that we'll be using doesn't really matter.

01:49.960 --> 01:52.640
Will be using basic functionality of Ides.

01:52.680 --> 01:55.040
So to run code to debug it.

01:55.040 --> 01:56.440
And that's pretty much it.

01:56.600 --> 02:03.130
And the funny fact is that I actually recorded this course when cursor did not exist, and I used PyCharm

02:03.130 --> 02:04.410
for most of the videos.

02:04.690 --> 02:05.170
All right.

02:05.210 --> 02:08.330
So let me open now the terminal from the IDE.

02:08.690 --> 02:13.930
And I want now to create a new branch which is going to be called Hello World branch.

02:14.090 --> 02:19.130
And this branch is going to hold all the code for the next couple of videos where we're going to introduce

02:19.130 --> 02:19.810
link chain.

02:19.970 --> 02:23.650
So I'm going to go and write git checkout dash dash orphan.

02:23.650 --> 02:27.490
And I'm going to call this branch project Slash Hello World.

02:28.210 --> 02:30.890
So when I do that I'm going to be in a new branch.

02:30.890 --> 02:33.490
You can see it right over here on the bottom left here.

02:33.770 --> 02:37.490
And the dash dash orphan creates a branch with no commit history.

02:37.490 --> 02:42.450
So it's going to start completely new without any commits from the existing repository.

02:42.490 --> 02:47.210
Now notice that by the time you'll be cloning the repository, this branch will already exist.

02:47.210 --> 02:49.770
So you might want to call this with a new name.

02:49.770 --> 02:50.210
Maybe.

02:50.250 --> 02:51.570
Hello world one.

02:52.250 --> 02:52.610
All right.

02:52.610 --> 03:01.570
Let me just write git dash rf from this directory to remove all the files that we have to really start

03:01.610 --> 03:03.090
with no files at all.

03:03.450 --> 03:05.490
So you can see we don't have any code.

03:05.490 --> 03:06.690
We don't have any commits.

03:06.730 --> 03:08.610
We are in a clean slate right now.

03:09.210 --> 03:09.690
All right.

03:09.690 --> 03:11.850
So let me write UV dash dash help.

03:12.010 --> 03:16.410
And UV is a very fast Python package manager just like pip.

03:16.410 --> 03:22.730
But it's much faster because it's built on rust and it handles installing and resolving and running

03:22.730 --> 03:24.770
dependencies very, very efficiently.

03:24.970 --> 03:29.610
And it's also going to help us manage our isolated environments with our dependencies.

03:29.850 --> 03:32.970
So we'll only be using the basic features of UV.

03:33.170 --> 03:37.050
And we'll be installing packages and managing our virtual environments.

03:37.250 --> 03:43.330
By the way, you can also use poetry or Pipenv or any other Python package manager you would like.

03:43.490 --> 03:48.490
And all we'll be doing in the course is installing packages and creating virtual environments, and

03:48.490 --> 03:50.370
running the code there with the packages.

03:50.490 --> 03:51.930
So nothing too fancy here.

03:51.930 --> 03:57.210
And in fact, we'll be using poetry and we'll be using BPMN through the entire course in some projects.

03:57.490 --> 03:58.250
All right.

03:58.250 --> 04:04.410
So let's go and enter UV Just to make sure that we have you've installed.

04:04.410 --> 04:06.930
Let me go up here in the logs.

04:07.170 --> 04:09.690
And yeah, you can see it's installed in my machine here.

04:09.690 --> 04:12.170
So we can see here the manual.

04:12.170 --> 04:18.130
And if you don't get this kind of output simply write Pip3 install UV and you should have it installed

04:18.130 --> 04:18.970
in your machine.

04:18.970 --> 04:21.850
So I already have it installed so it's not going to do anything.

04:22.370 --> 04:22.810
All right.

04:22.810 --> 04:25.810
So let's go now and initialize our project.

04:25.810 --> 04:28.170
And let's go and write UV init.

04:28.330 --> 04:31.570
And it's going to bootstrap a new Python project.

04:31.570 --> 04:34.730
And it's going to create some skeleton for our project.

04:34.730 --> 04:40.250
So it's going to create our main.py file with some boilerplate code, some hello world code.

04:40.490 --> 04:46.970
And it's going to create a Pyproject.toml file which is going to have the list of packages we have installed

04:47.290 --> 04:48.450
in our project.

04:48.810 --> 04:50.730
So right now this is a clean project.

04:50.730 --> 04:52.410
So we don't have anything installed.

04:52.570 --> 04:56.730
So let me go and write UV add and let's go and add link chain.

04:56.730 --> 05:00.050
And this is going to install link chain in our system.

05:00.330 --> 05:03.820
And notice that it also created here a folder.

05:03.820 --> 05:07.260
So it also now created the virtual environment for our project.

05:07.260 --> 05:10.700
And the package is now installed in this virtual environment.

05:10.700 --> 05:12.740
So let me go and click this play button here.

05:13.020 --> 05:16.260
And now notice that we're running the code here.

05:16.260 --> 05:19.180
So you can see here this print hello from LinkedIn course.

05:19.300 --> 05:24.900
And you can see that it's run from the virtual environment you see here LinkedIn course under those

05:24.900 --> 05:25.740
parentheses.

05:25.740 --> 05:28.900
So this means that it runs within this virtual environment.

05:29.180 --> 05:35.180
All right let me also add the link chain open AI package which is the link chain integration package

05:35.180 --> 05:36.180
for open AI.

05:36.540 --> 05:42.820
And it's a separate Python package that is going to contain all the open AI specific integrations for

05:42.820 --> 05:49.020
the link chain ecosystem and the reason why we are installing it independently, and it's not being

05:49.020 --> 05:56.820
bundled into the package itself, is because Link Chain decided to split providers, which are third

05:56.820 --> 06:03.420
party services, to link chain to different and independent packages where all the vendors maintain

06:03.420 --> 06:10.060
their own packages because we don't really want to download 100 providers if we only want to use OpenAI

06:10.180 --> 06:13.900
or anthropic or whatever service provider that we want to.

06:14.140 --> 06:21.020
Now, historically, the packages were actually bundled in the original package, but in one of their

06:21.020 --> 06:26.900
releases, they split everything into integration packages, which design wise makes a ton of sense,

06:26.900 --> 06:32.140
because right now every provider is going to maintain its own package.

06:32.140 --> 06:37.500
And if it's going to add new models or new features, it's going to maintain it independently from the

06:37.500 --> 06:38.540
other providers.

06:38.540 --> 06:40.980
So we have everything nicely decoupled.

06:41.460 --> 06:41.860
All right.

06:41.860 --> 06:43.060
Let me click enter.

06:43.420 --> 06:45.620
And now we have this package installed.

06:46.100 --> 06:53.500
Let me also add Python env which is going to help us load the environment variables from env files,

06:53.500 --> 06:58.340
which is going to be very easy to load all the API keys that we're going to be using in the course.

06:58.340 --> 07:01.900
And if you're not familiar with it, don't worry, I'll be showing it very, very shortly.

07:01.900 --> 07:09.180
Shorty and let me also install black, and I sought simply to format nicely the code here and there.

07:12.340 --> 07:13.820
All right, let me click enter.

07:14.140 --> 07:19.300
So we installed all the packages and let me show you the pyproject.toml file here.

07:19.660 --> 07:25.100
And we can see here all the packages that we have installed and all of their versions.

07:25.100 --> 07:27.140
And we have all the details here.

07:27.500 --> 07:33.540
And of course when you'll be running this code yourself, you're going to have different and newer versions

07:33.540 --> 07:34.900
of all those packages.

07:35.100 --> 07:41.140
And I will be updating the code and on GitHub and the videos themselves in case the API changes.

07:41.300 --> 07:44.940
But the code you should see should match the latest version of Linkchain.

07:45.060 --> 07:49.420
And if it's not the case, then please let me know and I will fix this ASAP.

07:49.460 --> 07:54.580
I refilmed this course like 3 or 4 times, so I'm really used to it.

07:54.900 --> 07:56.660
All right, let me create a.

07:57.020 --> 07:58.060
Gitignore file.

07:58.300 --> 08:04.070
Because there's a ton of things that we do not want to commit to the repository for example API keys

08:04.150 --> 08:06.830
or the Venv directory.

08:06.910 --> 08:09.470
So let me paste here a standard.

08:09.710 --> 08:11.910
Gitignore file for Python projects.

08:12.030 --> 08:17.430
So let me go now to my browser and let me look for Python.

08:17.470 --> 08:19.630
Gitignore a file.

08:19.670 --> 08:20.430
Let me go.

08:20.430 --> 08:23.150
And yeah let me check this project here.

08:23.750 --> 08:26.390
Let me go now and copy the content here.

08:26.790 --> 08:31.790
And by the way when you create a new GitHub project you have an option to generate these.

08:31.790 --> 08:33.390
Gitignore file automatically.

08:33.550 --> 08:38.790
But anyways let me just simply go and let me paste the content in my gitignore file.

08:39.670 --> 08:40.510
Alrighty.

08:40.910 --> 08:45.150
So now we can see that the venv directory is grayed out.

08:45.150 --> 08:46.750
So we're not going to commit it.

08:46.750 --> 08:48.510
And we're not going to track it with git.

08:48.910 --> 08:52.350
And now let's go and create a dot env file.

08:52.510 --> 08:57.870
And this file is going to hold all of our environment variables and all of our API keys.

08:58.110 --> 09:01.390
So now I want to fill in the OpenAI API key.

09:01.950 --> 09:07.710
And it's really, really important to note that you do not want to share your API keys.

09:07.910 --> 09:09.510
Do not share them with anyone.

09:09.510 --> 09:16.710
It's like a password and do not, of course, commit it to GitHub and the API keys, which I'm going

09:16.710 --> 09:21.270
to show you in the course, are all going to be revoked once I finish filming this video.

09:21.470 --> 09:27.470
So you do not want your API key to be leaked, because we have malicious people in the world which scan

09:27.510 --> 09:34.310
those kinds of files and those kinds of variables on GitHub automatically, and once they do find it,

09:34.310 --> 09:35.830
they go and abuse it.

09:35.830 --> 09:41.590
And you do not want to find yourself being charged with lots of money because your API key got leaked,

09:41.590 --> 09:44.670
or you accidentally committed it into a GitHub repository.

09:44.870 --> 09:48.750
And again, it's very important to note that I will be using OpenAI.

09:49.030 --> 09:55.150
I will also in the following video will show you how to use open source models with llama, and you

09:55.150 --> 09:56.950
can use any LLM that you want.

09:56.950 --> 09:58.190
You can use anthropic.

09:58.230 --> 09:59.510
You can use Gemini.

09:59.550 --> 10:01.550
You can use any LLM that you want.

10:01.750 --> 10:08.150
I also made a video, which is going to be in this section, which is going to tell for each project

10:08.150 --> 10:10.550
which LMS can be used for that project.

10:10.590 --> 10:11.030
All right.

10:11.030 --> 10:18.030
So let me search for OpenAI API key and let me go now to platform openai.com.

10:18.310 --> 10:22.630
Let me go and create an API key and let me call it link chain of course.

10:23.670 --> 10:28.150
And let me go and copy it and let me go and paste it.

10:28.510 --> 10:34.590
Now this is going to be working for me because I have already set up my OpenAI account and put credit

10:34.590 --> 10:40.670
card information, and I've already set up a budget that I'm going to limit my usage, which is also,

10:40.670 --> 10:45.350
by the way, a good practice to limit your usage and consumptions of APIs.

10:45.510 --> 10:50.750
So even if your API does get leaked, then you won't be maxing out the limit that you put.

10:51.150 --> 10:56.870
And a quick disclaimer OpenAI is not free, so you would need to purchase some credits beforehand.

10:57.030 --> 11:01.830
I will be showing you the free alternative to run open source models on our machines.

11:01.950 --> 11:05.400
Um, but this is going to be in the next video, not in this one.

11:05.600 --> 11:09.520
And in this video and in general in the course I will be using OpenAI.

11:09.760 --> 11:13.880
And you can use again any LLM that you want if you have free alternatives.

11:13.920 --> 11:19.720
Now it's important to note that if you're not going to have a credit card with OpenAI, then you will

11:19.720 --> 11:25.120
be encountering this 4 to 9 error, which is not going to let you use their API.

11:25.560 --> 11:30.840
And another thing is that the name here, OpenAI API key is very important.

11:30.840 --> 11:36.080
So the name should be the exact name, as you can see, because link chain is going to be looking for

11:36.080 --> 11:42.960
this exact environment variable when it's going to try making requests to the OpenAI API to get responses

11:42.960 --> 11:44.040
from their llms.

11:44.280 --> 11:51.120
By the way, if you want to use the Google API key, let me go and look for a Google AI studio.

11:54.000 --> 11:57.880
And here you can go and generate and create an API key.

11:58.720 --> 12:01.000
Let me just go and select a project.

12:01.000 --> 12:02.960
So it's going to be associated with it.

12:03.560 --> 12:06.480
and let me go and create now an API key.

12:06.720 --> 12:10.360
So this API key can be used for Google's models.

12:10.360 --> 12:11.320
So Gemini.

12:12.240 --> 12:19.280
So you need to write Google API key in case you want to use Gemini from the Google AI studio.

12:19.520 --> 12:24.560
And for that you'll need to install the link chain Google JNI integration.

12:24.560 --> 12:26.880
But I won't be showing that in the course.

12:27.200 --> 12:33.640
And in case you want to use open source models running from your local machine, you can install the

12:33.640 --> 12:35.920
link chain Dash Olama package.

12:36.040 --> 12:39.960
And I will be showing how to use link chain Olama in this section.

12:42.120 --> 12:49.360
All right let's go now and import from dot env the load dot env function.

12:50.040 --> 12:55.400
And when we call it it will go and look for a dot env file.

12:55.640 --> 12:59.200
And then it's going to take all the environment variables there.

12:59.200 --> 13:02.920
And it's going to load their values into our environment.

13:03.160 --> 13:10.520
So now after we run this, we can actually access those environment variables, the OpenAI API key that

13:10.520 --> 13:11.240
we configured.

13:11.640 --> 13:13.760
Let's see that this is indeed the case.

13:13.760 --> 13:18.800
So let me go and import the OS module so we can access the environment variable.

13:18.800 --> 13:24.880
And let me go and print here OS dot environment dot get.

13:24.960 --> 13:28.600
And here we want to get the OpenAI API key.

13:29.120 --> 13:30.520
So let's go and run it.

13:30.760 --> 13:34.000
And you can see now the value of my API key.

13:34.000 --> 13:35.840
And you should see your value here.

13:35.840 --> 13:40.840
So this means we can access the API key from our code and from our environment.

13:40.840 --> 13:43.280
And everything looks okey dokey right now.

13:43.280 --> 13:48.400
And we can continue and finally start writing our first link chain chain.

13:48.600 --> 13:50.680
So let me just remove this code from here.

13:51.200 --> 13:54.040
Let me run black to format the code nicely.

13:56.200 --> 13:59.520
Let me also run Eishort just in case.

14:00.160 --> 14:03.400
Alright, so now let's go and commit this code.

14:03.400 --> 14:04.890
So this boilerplate here.

14:05.290 --> 14:08.090
So let me go and add all of those files.

14:08.090 --> 14:09.410
Let me write git add.

14:11.450 --> 14:16.930
And now let's commit the code and let me call the commit environment setup.

14:19.250 --> 14:25.890
So let me push it and let me go copy this command and push it to the remote repository.

14:26.970 --> 14:27.490
All right.

14:27.490 --> 14:29.530
And let me show you where you can find the code.

14:30.570 --> 14:35.930
So you can go to the repo and look for the branch which is called oops.

14:35.970 --> 14:40.610
Let me refresh the page here and you can look for the branch which is called Hello World.

14:41.850 --> 14:44.970
And right over here let's go to the commit list over here.

14:45.410 --> 14:47.970
And here is the first commit environment setup.

14:47.970 --> 14:51.530
And here you can find all of the code that we wrote here.

14:51.930 --> 14:57.130
And of course this will be linked in the videos resource where you can have direct access to this link.

14:57.450 --> 14:58.290
And yeah.

14:58.290 --> 15:03.370
So now we can go and finally start writing our first link chain chain.
