WEBVTT

00:00.240 --> 00:06.120
Okay, so I checked out this branch which is called project slash react search agent.

00:06.280 --> 00:12.000
And just a quick note if you want to check out the code for this section, check out this branch over

00:12.000 --> 00:12.520
here.

00:12.520 --> 00:18.280
And for technical reasons, I committed the code to this branch over here and not the branch on the

00:18.280 --> 00:19.320
bottom left here.

00:20.000 --> 00:23.480
Alright, let's start by initializing our Python project.

00:23.480 --> 00:24.800
Let's write UV init.

00:25.560 --> 00:28.520
And now let's go install the dependencies.

00:28.520 --> 00:30.160
Let's add link chain.

00:30.480 --> 00:32.520
We want to use link chain OpenAI.

00:33.040 --> 00:36.520
And we discussed those packages in previous videos.

00:37.040 --> 00:41.640
So now we want to add a new package which is called link Chain.

00:42.440 --> 00:49.680
And Tivoli is a third party which is going to help us connect our agent to the web and give the agent

00:49.720 --> 00:54.360
searching capabilities so it will act as a search engine for our agent.

00:54.360 --> 01:01.480
And it also has other very useful APIs like Tivoli Crawl, Tivoli Map, Tivoli Extract, which are very

01:01.480 --> 01:04.080
useful services for AI agents.

01:04.360 --> 01:10.060
And we'll be using those capabilities in direct section of the course, so we'll cover them as well.

01:10.260 --> 01:17.300
And by the way, today is actually the most popular choice for integrating a web search into an agent.

01:17.580 --> 01:25.100
And they're even featured in the official documentation as the default service for a search engine when

01:25.140 --> 01:26.540
implementing agents.

01:26.700 --> 01:29.020
So they really did go to example.

01:29.300 --> 01:33.700
And I think the reason for that is that they first of all have an excellent API.

01:33.740 --> 01:34.860
It scales very well.

01:34.900 --> 01:36.100
It's very easy to use.

01:36.340 --> 01:40.460
And I think they were actually the first ones to go and integrate this.

01:40.460 --> 01:44.380
So to connect an agent A with searching capabilities.

01:44.420 --> 01:49.140
Now it's also important to note that they have a very generous free tier.

01:49.340 --> 01:55.460
And you can see it's 1000 API requests per month, which is going to be more than enough for this course.

01:56.260 --> 01:56.540
All right.

01:56.540 --> 02:00.460
Let me just show you a quick demo of the capabilities that we can integrate with it.

02:01.180 --> 02:08.700
So in the API playground let me write a query like what are the latest anthropic models.

02:08.980 --> 02:12.560
And we can see in the response we get here the URL of the source.

02:12.760 --> 02:15.520
We also get the content you can see here.

02:15.560 --> 02:18.360
It's talking about Cloud Outpost 4.1.

02:18.760 --> 02:23.480
And in this search result it talks about Cloud Ops and site four.

02:24.600 --> 02:26.760
And the search can be much more advanced.

02:26.800 --> 02:30.640
We can have some special filtering and advanced capabilities.

02:30.640 --> 02:34.160
However in this section we're only going to stick with the basics.

02:34.200 --> 02:36.160
All right so that's enough about me.

02:36.280 --> 02:39.600
And I'm going to link to in the videos resources.

02:40.600 --> 02:41.200
Alrighty.

02:41.200 --> 02:42.720
Let's go back to the code here.

02:42.880 --> 02:47.920
And link chain Tavileh is the Tavileh link chain integration.

02:48.160 --> 02:54.520
And here the provider is Tavileh in contrast to open AI in the previous example.

02:54.760 --> 03:00.960
So a provider of link chain doesn't have to be a vendor which offers large language models.

03:00.960 --> 03:07.000
It can also be a vendor which offer services that are exposed via API's and clients.

03:07.000 --> 03:12.760
So in this case Tavileh is going to expose their services, their searching capabilities, their scraping

03:12.760 --> 03:19.500
capabilities, and the link chain integration here is going to make our lives very, very easy when

03:19.500 --> 03:25.740
we want to integrate those capabilities into our link chain link graph applications here, because the

03:26.220 --> 03:30.940
team they wrote now, this integration, they connected to all the link chain objects, which we're

03:30.940 --> 03:31.540
going to use.

03:31.540 --> 03:32.540
And I'll give you a quick hint.

03:32.540 --> 03:34.260
It's going to be link chain tools.

03:34.260 --> 03:37.500
And this is another example of a link chain provider.

03:37.820 --> 03:42.700
And I also forgot to add please also install Python.

03:42.700 --> 03:50.580
And this is the original SDK which we are going to also be using in order to show you something very

03:50.580 --> 03:51.500
very important.

03:52.260 --> 03:59.260
All right let's go and also install Python dot env to load environment variables like we did before.

03:59.540 --> 04:03.220
And let me also install black insert for some formatting.

04:03.460 --> 04:06.100
And uh yeah let's go and install everything.

04:06.100 --> 04:07.660
So let me go and click enter.

04:09.460 --> 04:13.660
We can check out the packages in the Pyproject.toml file over here.

04:13.660 --> 04:17.300
And if you want the exact packages we can check out the UV dot log.

04:17.660 --> 04:21.030
And let's go to our main.py file.

04:21.070 --> 04:22.190
The boilerplate code.

04:22.230 --> 04:23.110
Let's try it.

04:23.110 --> 04:25.830
And let's run this code and make sure that it's working.

04:26.470 --> 04:26.950
All right.

04:26.950 --> 04:28.310
So we can see it's working.

04:28.630 --> 04:31.910
And now let me show you what I have in my env file.

04:32.150 --> 04:38.790
So like in the previous section I have my open API key I have Lang Smith.

04:38.830 --> 04:40.270
Tracing equals true.

04:40.270 --> 04:45.910
So we want to trace everything and we want to check out the traces I have here my link Smith API key.

04:45.950 --> 04:51.910
Like previous sections I have my Lang Smith project which I changed in code search agent.

04:52.110 --> 04:58.830
And I also have here a API key which I got from the UI.

04:59.150 --> 05:01.390
All right, let me show you how you can get it.

05:01.390 --> 05:04.270
You simply need to go to Tavileh to log in.

05:07.630 --> 05:09.830
Let me now go and log with Google.

05:12.310 --> 05:14.550
And right here I have my environment.

05:14.550 --> 05:16.150
You can see all my API keys.

05:16.470 --> 05:18.190
Let me go and generate an API key.

05:18.230 --> 05:19.990
For example I'm using the free plan.

05:20.030 --> 05:20.550
By the way.

05:20.990 --> 05:27.250
Let me go and click here this plus button Now let's name the API key.

05:28.250 --> 05:29.650
Let's call it API key.

05:30.210 --> 05:32.530
I'm going to limit my monthly usage.

05:32.810 --> 05:35.050
And yeah let's hit create.

05:35.170 --> 05:38.690
And here you can simply go you can check out you can review the API key.

05:38.730 --> 05:39.970
You can copy it.

05:39.970 --> 05:43.650
And this is the value that you should put in your um dot env file.

05:44.450 --> 05:47.010
So let me go back now to the env file.

05:47.410 --> 05:54.010
And it's also important to note that the name of the environment variable needs to be underscore API

05:54.010 --> 05:59.130
key, because that's where link chain is going to be looking for the credentials to authenticate to

05:59.170 --> 06:00.450
the services.

06:00.450 --> 06:07.890
So it's working very similarly to the OpenAI API key here, where it's going to look for that API key

06:07.930 --> 06:09.410
in the environment variables.

06:09.650 --> 06:13.210
Alrighty, let's go now to our main.py file.

06:13.210 --> 06:15.530
And let's start with the imports.

06:15.810 --> 06:21.970
And first let's go and let's load all the environment variables from the env file like we did in the

06:21.970 --> 06:23.010
previous video.

06:23.010 --> 06:26.010
So let's import the load function.

06:26.010 --> 06:29.690
And I want to call it in the beginning of the file here.
