WEBVTT

00:01.040 --> 00:05.720
So I want to add here some real world searching over the internet.

00:05.960 --> 00:09.640
So I'm going to import from Tavileh, the Tavileh client.

00:11.240 --> 00:14.920
So let me now go and initialize this Tavileh client.

00:15.000 --> 00:17.960
So I'm simply going to create a variable called Tavileh.

00:18.160 --> 00:21.200
And I'm going to initialize the client.

00:21.400 --> 00:27.360
And this client when it's going to initialize and it's going to be looking for an environment variable

00:27.360 --> 00:28.920
called Tavileh API key.

00:29.080 --> 00:33.000
So this is where we put in our dot env file the API key.

00:33.040 --> 00:35.200
So everything should be working right now.

00:35.720 --> 00:42.360
So let me now instead of returning the Tokyo weather is sunny, let's go and run the actual search query

00:42.360 --> 00:43.960
and let's return the results.

00:43.960 --> 00:45.600
We'll be doing it with Tavileh.

00:45.840 --> 00:50.480
Search and search need to receive an argument called query and query.

00:50.520 --> 00:55.440
Here is going to be equal to our query, which is the input to our search function.

00:57.720 --> 00:58.400
Amazing.

00:58.560 --> 01:00.080
So let's go and run it now.

01:00.080 --> 01:03.540
And it's going to have now a real searching capability.

01:04.700 --> 01:06.660
So we'll just wait for it to finish.

01:07.860 --> 01:10.460
We can see now it's searching over the web.

01:11.660 --> 01:17.540
And once we have an answer, we'll head up to Lenox-smith to review again the traces.

01:18.460 --> 01:21.820
So everything now should be very similar.

01:21.820 --> 01:30.100
But if we go now to the search execution here, we can see that instead of returning a static string

01:30.100 --> 01:36.260
here, we're actually going to output some real information of the weather in Tokyo.

01:36.260 --> 01:39.820
And this is an example of a search made.

01:40.060 --> 01:43.020
And it got the information from the weather API.

01:43.820 --> 01:46.660
And here you can see all the information of the weather.

01:46.660 --> 01:51.180
So it also provided us with other results and other answers.

01:51.180 --> 01:54.460
So it provided us with the top results here.

01:54.460 --> 01:59.460
And if we want we can control this parameter of how many results you get.

01:59.740 --> 02:06.600
And if I go to the last LM response here, we can see now we get a different answer, which is a much

02:06.600 --> 02:13.600
more elaborate answer here, which is grounded on real time information, which we got through research.

02:14.040 --> 02:14.680
All right.

02:14.680 --> 02:21.440
So now let's go and let me change now the query to be what I showed you in the demo.

02:21.680 --> 02:28.720
So now let's have a look and let's see if we can get some job openings for link chain professionals.

02:29.080 --> 02:31.040
So let me go back to the code here.

02:31.240 --> 02:38.160
And here in the message I'm going to tell the agent that I want to search for three job postings for

02:38.160 --> 02:46.120
an AI engineer in chain in the Bay area in LinkedIn, and to list all of their details here.

02:46.520 --> 02:51.280
And don't worry about this prompt if you'll check out the repo in the videos resources, you can simply

02:51.280 --> 02:52.280
copy and paste it.

02:52.680 --> 02:56.080
Anyways, let me go now and let's go and run this.

03:01.760 --> 03:06.440
And we can learn from this log over here that we are running now.

03:06.480 --> 03:09.020
LinkedIn is running the search tool here.

03:09.020 --> 03:12.980
It's running it five times with five different queries.

03:12.980 --> 03:21.820
So the first query is to look inside LinkedIn.com slash jobs looking for LinkedIn, Bay area, San Francisco

03:21.860 --> 03:23.540
San Jose AI engineer.

03:23.540 --> 03:25.700
So we have multiple search queries here.

03:25.900 --> 03:26.420
All right.

03:26.420 --> 03:28.340
We got now a result.

03:28.380 --> 03:30.980
We can see now here in that it finished.

03:30.980 --> 03:33.940
We can see here a it's all printed out.

03:33.980 --> 03:34.860
Not very nicely.

03:34.860 --> 03:37.100
So let's go and open it.

03:37.100 --> 03:38.540
And let's check out the trace.

03:39.420 --> 03:43.060
And now we can see our input our query.

03:43.340 --> 03:51.340
And notice that in the output of the LLM in the AI response here we get multiple tool calls.

03:51.340 --> 03:54.540
So the AI decides to call multiple tool calls.

03:54.540 --> 03:57.260
And it's going to execute them in parallel.

03:57.260 --> 04:03.220
So this is because function calling in GPT five supports multiple function calling and will be elaborating

04:03.220 --> 04:04.340
it later in the course.

04:04.620 --> 04:07.460
This is an example of one tool call.

04:07.780 --> 04:11.440
This is an example of another tool call.

04:12.000 --> 04:14.600
And we have here a five tool course.

04:14.840 --> 04:21.480
And the final request to the MLM contains all the tool calls and all their answers.

04:21.680 --> 04:24.680
And let me go here and down.

04:24.680 --> 04:27.640
And let's see the final answer of the LM.

04:27.840 --> 04:29.320
And here we got the answer.

04:29.320 --> 04:35.600
So and we got here all of the job postings on LinkedIn and the URL to LinkedIn.

04:37.080 --> 04:40.280
Notice that some of them are no longer accepting candidates.

04:40.280 --> 04:43.680
But this is the final response here of the LM.

04:44.320 --> 04:44.680
All right.

04:44.680 --> 04:46.360
I want to go back to the code now.

04:46.360 --> 04:51.360
And I want to discuss now a best practice when using LinkedIn.

04:51.840 --> 04:59.800
So in our example we wrote a custom tool and used the SDK inside that tool.

05:00.480 --> 05:07.920
However, this will require us as the developers to know every bit and byte and to know how the SDK

05:07.960 --> 05:08.680
is working.

05:09.160 --> 05:19.490
And in fact I do not know exactly all the internals of the SDK so heavily because it has a LinkedIn

05:19.490 --> 05:20.290
integration.

05:20.450 --> 05:30.050
The team, they wrote a package link chain which takes the SDK and wraps it as a chain tool.

05:30.370 --> 05:40.050
And you can trust you should trust the vendor, in this case the team, to write a much better description,

05:40.050 --> 05:48.090
much better arguments, and they can do a far better job writing the link chain tools than we do here.

05:48.330 --> 05:55.010
So what I'm going to do right now, I'm going to remove the custom tool, and I'm going to use the built

05:55.010 --> 05:59.450
in Tavileh search tool that the Tavileh team wrote.

06:00.250 --> 06:04.650
So let me add link chain Tavileh just to make sure I have this package installed.

06:05.530 --> 06:08.690
And let me now remove all of these search tool.

06:08.730 --> 06:09.930
We do not need it.

06:10.330 --> 06:11.890
Also the Tavileh client.

06:12.170 --> 06:20.310
And let's instead of this import let's right from link chain underscore tavileh let's go and import.

06:20.710 --> 06:25.470
It's called Tavileh search and Tavileh search.

06:25.510 --> 06:29.310
Let's go and check out the implementation is a base tool here.

06:29.550 --> 06:30.950
So it's a link chain tool.

06:31.270 --> 06:33.430
So let me go back now.

06:33.430 --> 06:38.630
And because this is already a tool all I need to do is to initialize this object.

06:38.790 --> 06:41.590
I won't be sending it any custom arguments.

06:42.550 --> 06:45.190
So let's go now and run it again.

06:45.470 --> 06:49.830
And I'm going to fast forward this because it may take some time.

06:50.430 --> 06:55.350
And let me go back now to link and let's check out this trace.

06:56.630 --> 07:02.950
So notice here that the name of the tool here is called underscore search.

07:02.950 --> 07:05.030
And this is how Tavileh named their tool.

07:05.190 --> 07:07.030
And our name was search.

07:07.030 --> 07:09.230
And you can compare it with the previous trace.

07:09.830 --> 07:13.750
And let's go and check out an example of an execution here.

07:14.070 --> 07:21.130
And we can see here we have the query like we had before, but we have here some extra arguments that

07:21.130 --> 07:24.130
the LM decided to make with the tool call.

07:24.170 --> 07:27.850
So those are arguments that I didn't know about.

07:27.890 --> 07:31.010
So they are include domains linkedin.com.

07:31.010 --> 07:35.970
So this is probably going to say to to really to only get results from LinkedIn.com.

07:36.290 --> 07:42.090
And it has an extra argument which is called search depth which is advanced.

07:42.210 --> 07:46.970
And I will be explaining this further in the course because we'll be seeing much more examples with

07:46.970 --> 07:47.490
David.

07:47.530 --> 07:49.650
What is this argument here?

07:49.850 --> 07:55.890
But the point I want to show you here is that we are getting a much more elaborate tool calls here.

07:56.090 --> 08:03.570
And while the answer is very similar to what we executed before, however, it's a bit more accurate

08:03.610 --> 08:10.570
now because the agent was able to make much more specific tool calls, which should ground the answer

08:10.570 --> 08:12.370
in better sources.

08:12.410 --> 08:19.150
All right, let me go now and let me bring back the implementation with our custom tool here, and let

08:19.150 --> 08:24.790
me push everything to the repository and I will be linking everything in the videos resources.

08:25.510 --> 08:26.070
All right.

08:26.070 --> 08:29.510
So let me go now and add everything into git.

08:29.510 --> 08:33.070
And let me now see all the files here.

08:33.470 --> 08:35.350
So let me now commit everything.

08:35.390 --> 08:41.590
Let me right in the message intro to search agents and let me push it.

08:42.230 --> 08:42.550
Sorry.

08:42.550 --> 08:44.870
Let me set the upstream and let me push it again.

08:45.790 --> 08:49.990
All right let's go back to the repo and you can find everything.

08:49.990 --> 08:55.950
If you go to the branches it should be called project slash search agent.

08:56.510 --> 08:58.390
You can see it right over here.

08:59.430 --> 09:02.750
And let me now show you here the commit.

09:09.430 --> 09:12.750
And let's go check out the main file.

09:15.510 --> 09:18.550
And everything you can see it's right over here.
