WEBVTT

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

00:06.320 --> 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.360
And for technical reasons, I committed the code to this branch over here and not the branch on the

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

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

00:23.480 --> 00:24.840
Let's write init.

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

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

00:30.520 --> 00:32.480
We want to use link chain OpenAI.

00:33.080 --> 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.480 --> 00:49.720
And Tivoli is a third party which is going to help us connect our agent to the web and give the agent

00:49.760 --> 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:08.610
useful services for AI agents, and we'll be using those capabilities in direct section of the course,

01:08.610 --> 01:10.050
so we'll cover them as well.

01:10.250 --> 01:17.290
And by the way, David is actually the most popular choice for integrating a web search into an agent.

01:17.570 --> 01:24.490
And they're even featured in the official documentation as the default service for a search engine.

01:24.610 --> 01:26.490
And when implementing agents.

01:26.690 --> 01:29.010
So they really go to example.

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

01:33.730 --> 01:34.850
It scales very well.

01:34.890 --> 01:36.090
It's very easy to use.

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

01:40.450 --> 01:44.370
So to connect an agent A with searching capabilities.

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

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

01:56.250 --> 01:56.570
All right.

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

02:01.250 --> 02:08.740
So in the API playground let me write a query like what are the latest anthropic models?

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

02:12.740 --> 02:18.340
We also get the content you can see here it's talking about Cloud Outpost 4.1.

02:18.740 --> 02:23.460
And in this search result it talks about Cloud Ops and Sonet four.

02:24.620 --> 02:26.780
And the search can be much more advanced.

02:26.820 --> 02:30.620
We can have some special filtering and advanced capabilities.

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

02:34.220 --> 02:34.580
All right.

02:34.580 --> 02:36.140
So that's enough about me.

02:36.260 --> 02:38.900
And I'm going to link to Vili in the videos.

02:38.900 --> 02:39.620
Resources.

02:40.620 --> 02:41.220
Alrighty.

02:41.220 --> 02:47.900
Let's go back to the code here and link to Vili is the link chain integration.

02:48.180 --> 02:54.540
And here the provider is the Vili a in contrast to OpenAI in the previous example.

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

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

03:06.980 --> 03:12.840
So in this case Turville is going to expose their services, their searching capabilities, their scraping

03:12.840 --> 03:19.600
capabilities, and the LinkedIn integration here is going to make our lives very, very easy when we

03:19.640 --> 03:26.600
want to integrate those capabilities into our link chain graph applications here, because the team

03:26.640 --> 03:31.200
they wrote now, this integration, they connected to all the link chain objects, which we're going

03:31.200 --> 03:31.560
to use.

03:31.560 --> 03:32.560
And I'll give you a quick hint.

03:32.560 --> 03:34.280
It's going to be link chain tools.

03:34.280 --> 03:37.480
And this is another example of a link chain provider.

03:37.840 --> 03:38.320
All right.

03:38.320 --> 03:44.840
Let's go and also install Python dot env to load environment variables like we did before.

03:45.160 --> 03:46.760
And let me also install black.

03:46.760 --> 03:51.760
And I sought for some formatting and uh yeah let's go and install everything.

03:51.760 --> 03:53.280
So let me go and click enter.

03:55.120 --> 03:59.240
We can check out the packages in the pyproject.toml file over here.

03:59.240 --> 04:02.920
And if you want the exact packages we can check out the dot log.

04:03.280 --> 04:07.680
And let's go to our main.py file the boilerplate code.

04:07.680 --> 04:08.680
So let's try it.

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

04:12.090 --> 04:12.610
All right.

04:12.610 --> 04:13.970
So we can see it's working.

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

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

04:24.450 --> 04:25.890
Tracing equals true.

04:25.890 --> 04:30.050
So we want to trace everything and we want to check out the traces I have here.

04:30.050 --> 04:31.530
My Lang Smith API key.

04:31.570 --> 04:37.530
Like previous sections I have my Lang Smith project which I changed in called Search Agent.

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

04:44.770 --> 04:45.210
All right.

04:45.210 --> 04:47.010
Let me show you how you can get it.

04:47.010 --> 04:49.890
You simply need to go to the village to log in.

04:53.250 --> 04:55.450
Let me now go and log with Google.

04:57.930 --> 05:00.170
And right here I have my environment.

05:00.170 --> 05:01.770
You can see all my API keys.

05:02.090 --> 05:03.810
Let me go and generate an API key.

05:03.850 --> 05:06.130
For example I'm using the free plan by the way.

05:06.570 --> 05:08.770
Let me go and click here this plus button.

05:10.770 --> 05:12.810
Now let's name the API key.

05:13.900 --> 05:15.260
let's call it API key.

05:15.820 --> 05:18.140
I'm going to limit my monthly usage.

05:18.420 --> 05:20.660
And yeah let's hit create.

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

05:24.340 --> 05:25.580
You can copy it.

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

05:30.060 --> 05:32.620
So let me go back now to the env file.

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

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

05:44.780 --> 05:46.060
the services.

05:46.060 --> 05:53.500
So it's working very similarly to the OpenAI API key here, where it's going to look for that API key

05:53.540 --> 05:55.060
in the environment variables.

05:55.260 --> 05:58.820
Alrighty, let's go now to our main.py file.

05:58.820 --> 06:01.140
And let's start with the imports.

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

06:07.580 --> 06:08.620
previous videos.

06:08.620 --> 06:11.620
So let's import the load env function.

06:11.620 --> 06:16.670
And I want to call it in the beginning of the file here Hey there.

06:16.710 --> 06:17.470
Ethan here.

06:17.590 --> 06:19.430
Um, just a quick disclaimer.

06:19.430 --> 06:27.070
So this is being added in October 20th, 2025, and I just want to have a quick note before we jump

06:27.070 --> 06:27.430
in.

06:27.630 --> 06:30.510
So LinkedIn recently released version one.

06:30.950 --> 06:35.070
And it does have some breaking changes, especially with imports.

06:35.230 --> 06:39.470
And I'm working really hard to make sure everything in this course is compatible for you.

06:39.710 --> 06:46.590
But right now, because LinkedIn v1 has a few mismatches and bugs between the documentation and the

06:46.590 --> 06:52.670
code, I recommend you using for the imports link chain Dash classic package.

06:52.870 --> 06:59.350
That package keeps the old import stable and I'll show you the updated imports alongside the original

06:59.350 --> 07:05.070
ones in the code, so you can follow along easily in case you installed link chain version one, which

07:05.070 --> 07:07.990
is currently now the rolled out default.

07:08.110 --> 07:09.830
So thanks for bearing with me.

07:09.830 --> 07:14.510
I'm making sure everything is going to be as smooth as possible for you, and I will be refilming,

07:14.510 --> 07:18.400
re-editing and adjusting the videos for everything to be compatible.

07:18.400 --> 07:22.280
But right now, because this is so new, this is a transition period.

07:22.600 --> 07:26.960
So let me now import from LinkedIn the hub object.

07:26.960 --> 07:30.320
And the election hub is within the LinkedIn ecosystem.

07:30.320 --> 07:37.120
And it's designed for sharing and exploring prompts, chains and agents created by the community.

07:37.400 --> 07:43.520
So it serves also as a resource where developers can find inspiration, can reuse components.

07:43.720 --> 07:49.680
And we're going to use the hub in order to download a very special prompt, which is called a react

07:49.680 --> 07:50.200
prompt.

07:50.640 --> 07:51.200
All right.

07:51.200 --> 07:57.440
And we want to import the create react agent function and the agent executor class.

07:57.840 --> 07:58.280
Hey there.

07:58.320 --> 07:59.840
This is hidden here popping up.

08:00.200 --> 08:04.000
Now I want to give you a quick heads up in this section.

08:04.000 --> 08:08.200
I want us to treat the react agent as a black box.

08:08.200 --> 08:13.760
So it's going to receive the tools that we want our agent to have, and it's going to run it, and it's

08:13.760 --> 08:16.840
going to give us some awesome capabilities like we saw in the demo.

08:17.240 --> 08:21.490
Now, I am not expecting you to know how it's working under the hood.

08:21.650 --> 08:27.770
In fact, the next section is entirely dedicated for us to figure out how this magic is working.

08:28.010 --> 08:32.330
So in this section, I am not expecting you to understand how this is working.

08:32.330 --> 08:33.290
And what's the magic?

08:33.290 --> 08:35.170
This is going to be in the next section.

08:35.210 --> 08:39.650
I am expecting you just to learn the interface of how to use those objects.

08:40.090 --> 08:40.370
Right.

08:40.410 --> 08:43.650
So back to the code and let's explain those imports.

08:44.010 --> 08:53.810
So the Create react agent is a built in special function that is going to create us a runnable a link

08:53.810 --> 08:58.650
chain chain which is referred to as the react agent.

08:59.010 --> 09:02.130
Now this agent is not really an agent.

09:02.170 --> 09:03.450
It's a link chain chain.

09:03.490 --> 09:05.210
It's a runnable object.

09:05.210 --> 09:09.890
And it's going to be our reasoning engine of our react agent.

09:10.050 --> 09:13.330
And the create react agent receives an LLM.

09:13.330 --> 09:17.250
So this is going to be the LLM which is going to be our reasoning engine.

09:17.250 --> 09:19.170
It's going to receive a list of tools.

09:19.170 --> 09:21.770
So here in our example it's going to be a search tool.

09:21.970 --> 09:24.150
And it's going to receive a prompt.

09:24.310 --> 09:30.390
And the prompt we're going to give it is going to be the react prompt, which we're going to cover in

09:30.390 --> 09:30.750
depth.

09:30.750 --> 09:31.350
Trust me.

09:31.550 --> 09:38.350
And everything together is going to be a very special prompt that is being sent to the LM, and it's

09:38.350 --> 09:43.070
going to make our LM become the reasoning engine, the brain of our agent.

09:43.070 --> 09:48.270
So it's going to decide what we want to do, maybe to invoke something to call a tool, or maybe to

09:48.310 --> 09:49.350
return the answer.

09:49.390 --> 09:50.790
This is going to be the brain.

09:50.830 --> 09:53.670
Now again, you do not need to fully understand it, okay?

09:53.670 --> 09:58.590
You just need to know that it's going to receive the LM, the tools and the special prompt.

09:59.190 --> 09:59.630
All right.

09:59.670 --> 10:02.070
Now let's talk about the agent executor.

10:02.510 --> 10:07.470
And the agent executor is going to be the runtime of the agent.

10:07.950 --> 10:14.470
If the reasoning engine is going to tell us what we need to run, if we need to call the search tool

10:14.470 --> 10:19.430
with which arguments, then the agent executor is going to make the actual calls.

10:19.430 --> 10:20.870
So it's going to be the runtime.

10:20.870 --> 10:24.190
So it's going to be the things that is going to execute everything.

10:24.390 --> 10:26.240
And I'll give you a quick spoiler.

10:26.640 --> 10:31.120
The agent executor is not that complicated as it may sound.

10:31.160 --> 10:35.000
It has a very fancy name, but in the end it's a for loop.

10:35.160 --> 10:37.160
And you're going to see this in the next section.

10:37.560 --> 10:40.720
All right, so I know I introduced a lot of terminology right now.

10:40.880 --> 10:42.840
I hope I didn't freak you out too much.

10:42.880 --> 10:48.560
I remind you, the goal of this section is just to review the interface and to review the capabilities.

10:49.040 --> 10:49.480
Cool.

10:49.480 --> 10:51.440
So let's continue to other imports.

10:51.680 --> 10:55.960
We want to import chat OpenAI because we're going to be using GPT.

10:56.360 --> 11:03.120
And let's go and also import from let's go and import the Tavileh search.

11:03.560 --> 11:09.400
And Tavileh search is a link chain tool that we're going to connect to our LLM, which is going to give

11:09.400 --> 11:14.280
our agent the capability to make searches over the internet.

11:14.480 --> 11:21.720
And Tavileh search is the Tavileh API that the Tavileh team wrapped as a learning tool.

11:21.920 --> 11:27.640
And now it's compatible with the link chain ecosystem, and we can connect it to our link chain agents.
