WEBVTT

00:00.080 --> 00:03.800
Alrighty, let's go now and let's run everything.

00:03.800 --> 00:10.840
And I want now to show you the logs, the outputs, and we'll have a better understanding of how everything

00:10.840 --> 00:13.080
here is working together and what we just did.

00:13.400 --> 00:16.240
Let me just go and click um continue here.

00:16.960 --> 00:17.600
All right.

00:17.640 --> 00:21.720
We can see now we're entering a new agent executor chain.

00:21.920 --> 00:29.480
And right now the prompt we wrote plugged in with all the tool descriptions of the search is all being

00:29.480 --> 00:31.440
bundled up with the prompt.

00:31.440 --> 00:33.360
And that's being sent to the LM.

00:33.400 --> 00:34.040
All right.

00:34.160 --> 00:37.680
And now the LM is going to return us an answer.

00:38.000 --> 00:39.840
And this we can see in green here.

00:40.040 --> 00:45.160
And the LM returned to find the job posting I will use the search tool.

00:45.200 --> 00:51.320
This is the tool name inputting a specific query to look for an AI engineer position involving link

00:51.320 --> 00:53.000
chain, blah blah blah blah.

00:53.200 --> 00:59.360
And then we have here action which is going to be search which is going to be the tool name.

00:59.560 --> 01:05.990
And then we have here the action input which is going to be the string of AI engineer LinkedIn job description.

01:06.030 --> 01:07.390
Bay Area LinkedIn.

01:07.430 --> 01:08.150
All right.

01:08.190 --> 01:11.670
So this right here is what the LLM returned.

01:11.910 --> 01:18.950
Now it returned us this kind of answer with this specific format of action and action input just because

01:18.950 --> 01:19.990
of the react prompt.

01:20.030 --> 01:23.190
And I will be elaborating on this in the rest of this course.

01:23.190 --> 01:25.630
But this is this kind of hack here, right.

01:25.670 --> 01:31.510
So the LLM is going to always respond this with these kinds of format where we have action, which is

01:31.510 --> 01:37.310
going to have the tool name and action input, which is going to be the input for the tool name.

01:37.670 --> 01:42.310
Now LinkedIn and this is the beautiful thing LinkedIn is going to take this for us.

01:42.670 --> 01:45.350
It's going to parse out those strings.

01:45.550 --> 01:49.790
And it's going to figure out that it has in its disposal the search.

01:49.910 --> 01:58.030
And it's going to invoke the function of the search, which we imported from the LinkedIn integration.

01:58.030 --> 02:01.670
And it's going to invoke this function with this input.

02:01.670 --> 02:05.790
And LinkedIn is going to do all this parsing and all this heavy lifting for.

02:05.790 --> 02:05.820
54.

02:06.020 --> 02:11.620
And I remind you, we had this output parser from before in the Create react agent.

02:11.620 --> 02:15.260
So that's part of the chain is going to do that for us right.

02:15.300 --> 02:21.260
So it's going to take this answer and it's going to extract from it the name of the tool that we need

02:21.300 --> 02:23.020
and the input for that tool.

02:23.300 --> 02:23.540
Right.

02:23.580 --> 02:27.860
So now link chain is going to execute the search tool.

02:27.900 --> 02:29.260
So this is what's going to happen.

02:29.260 --> 02:30.820
And it's going to get a result.

02:31.020 --> 02:32.860
And this is what we're seeing right now.

02:33.380 --> 02:37.540
And here we have the result of the tool execution.

02:37.540 --> 02:41.220
So link chain ran the tool and it got us the result.

02:41.580 --> 02:48.380
And in this result here we can see we have the query which is the same query from the action input.

02:48.660 --> 02:51.540
And then we have here the results.

02:51.580 --> 02:55.940
So here we have a list of URLs and the description of the search results.

02:55.980 --> 02:59.180
Just like we saw in the playground here.

02:59.220 --> 02:59.700
Right.

02:59.740 --> 03:02.660
So we have here now the tool result.

03:02.660 --> 03:07.140
And the tool result is often referred to as an observation.

03:07.780 --> 03:14.860
And the LinkedIn component that was responsible of running and executing this tool call was the agent

03:14.860 --> 03:15.540
executor.

03:15.980 --> 03:23.340
So now the agent executor is going to take this observation, the result of the tool, and it's going

03:23.340 --> 03:27.500
to run the same reasoning chain from before.

03:27.660 --> 03:31.620
However, now it's going to attach the observation.

03:31.620 --> 03:33.380
So the result of the tool call.

03:33.420 --> 03:37.100
So now the LLM is going to have the original question.

03:37.260 --> 03:42.620
And it's going to have in its history that it's invoked the search tool with the search result.

03:42.620 --> 03:45.380
And now it's going to come up with the answer.

03:45.540 --> 03:46.100
Right.

03:46.140 --> 03:48.260
So this is what's going to happen here.

03:48.260 --> 03:49.900
And this is why we need the scratchpad.

03:49.940 --> 03:52.020
The scratchpad from the prompt template before.

03:52.060 --> 03:54.340
This is going to hold all of this history right.

03:54.380 --> 03:57.380
All of the tools that were selected and the tool result.

03:57.780 --> 04:01.660
And now the LLM has all the information it needs.

04:01.660 --> 04:05.460
And in this iteration it can actually return us the answer.

04:06.140 --> 04:09.900
And now we can see here in the green the answer of the LLM.

04:10.220 --> 04:12.330
And here we can see it has.

04:12.370 --> 04:13.450
Final answer.

04:13.650 --> 04:15.890
And now the final answer of the LM.

04:16.170 --> 04:18.730
And the agent finished running.

04:18.730 --> 04:25.250
And it provided us with three job posting for an AI engineer using LinkedIn.

04:25.770 --> 04:31.930
And at the end, LinkedIn is going to return us an object, which is a dictionary which has the key

04:31.970 --> 04:34.730
of input and has the key of output.

04:34.730 --> 04:40.930
So the input is going to be our original query and the output is going to be the final LLM response.

04:40.970 --> 04:41.530
All right.

04:41.570 --> 04:44.330
Let's now go and review the trace.

04:44.570 --> 04:48.890
So let me open up my browser and let me go to the Linux platform.

04:49.330 --> 04:54.770
And here I have the project link Smith project which I defined which is called search agent.

04:55.170 --> 04:56.850
And let's check out what we have here.

04:56.970 --> 04:59.490
So we can see here an agent executor run.

04:59.690 --> 05:01.330
Here we can see our input.

05:01.370 --> 05:02.890
Here we can see the output.

05:03.290 --> 05:06.210
And we can see we got here an answer.

05:06.250 --> 05:09.210
Let me go and click this URL here.

05:09.370 --> 05:12.570
Let me show you that this is a LinkedIn job posting.

05:12.570 --> 05:14.400
So we can see Um.

05:14.600 --> 05:16.240
Yeah, this is a job posting.

05:16.240 --> 05:17.520
Let's check out this one.

05:22.160 --> 05:22.440
Yeah.

05:22.480 --> 05:25.240
This is also a job posting for an AI engineer.

05:26.200 --> 05:28.560
And let me go and click on this one.

05:29.640 --> 05:30.000
Yeah.

05:30.040 --> 05:31.080
And this one also.

05:31.080 --> 05:33.200
And here you can see even LinkedIn in the title.

05:34.160 --> 05:36.120
All right let's go back to the traces.

05:36.120 --> 05:38.480
And let's try to break it down step by step.

05:38.720 --> 05:40.920
And this is the prompt template.

05:40.920 --> 05:43.400
So we can see this is the input for the prompt template.

05:43.400 --> 05:46.120
And the output is this text right over here.

05:46.480 --> 05:54.080
Now you can see that this is the prompt populated with all the details about our tools which are the

05:54.400 --> 05:54.840
search.

05:54.960 --> 05:58.240
So we have here the tool names and the tool descriptions.

05:58.240 --> 06:01.760
And this is what eventually is going to be passed to the LLM.

06:01.920 --> 06:08.320
And we can see here instead of the placeholder, we have the question that we gave as an input when

06:08.320 --> 06:09.480
we ran the agent.

06:10.120 --> 06:10.640
All right.

06:10.680 --> 06:12.840
And this is the LLM call.

06:12.840 --> 06:16.870
So we can see now here we simply sent that to the LM.

06:16.870 --> 06:19.710
And here we can see now the LM response.

06:20.310 --> 06:22.390
And after we get the LM response.

06:22.390 --> 06:27.230
And this is the part I didn't dive into, the engine is going to parse it.

06:27.510 --> 06:30.230
So it's going to take from this raw text here.

06:30.230 --> 06:35.230
And it's going to extract the tool name and the tool input that we need.

06:35.430 --> 06:38.350
And we can see here that the type is agent action.

06:38.350 --> 06:41.110
So this is the action that the agent needs to do.

06:41.150 --> 06:42.270
We have here log.

06:42.270 --> 06:47.030
So this is sort of the justification of why the agent did what it did.

06:47.350 --> 06:49.990
And everything here is very organized.

06:49.990 --> 06:51.430
And don't worry about this.

06:51.470 --> 06:55.270
In the next section we'll be diving deep into all of this and how this is working.

06:55.550 --> 06:55.990
All right.

06:55.990 --> 06:58.950
So then the agent executor ran the tool.

06:59.110 --> 07:02.510
So here we can see that this is the tool input.

07:02.510 --> 07:04.590
And here we get the tool output.

07:04.990 --> 07:06.350
So this is what we have here.

07:06.510 --> 07:10.870
And then we have another iteration of the reasoning.

07:11.070 --> 07:17.070
So this is now the second prompt which is sent to the LM which is kind of like the original one.

07:17.070 --> 07:23.020
But it also has the information about the tool call that we made and what is the tool result.

07:23.020 --> 07:29.940
And then the agent is going to sorry, the LM is going to respond with an answer that we can see right

07:29.940 --> 07:31.860
over here at the bottom here.

07:32.140 --> 07:34.540
And yeah, that's pretty much it.

07:34.580 --> 07:39.260
Link chain is going to go take it going to parse it going to do it very very nicely.

07:39.260 --> 07:41.900
And then it's going to output us the response here.

07:42.500 --> 07:46.620
Let me just go and commit this code now to the repository.

07:47.060 --> 07:49.100
So let's create a new commit.

07:50.420 --> 07:50.980
Sorry.

07:51.020 --> 07:52.180
Let's create the commit.

07:52.180 --> 07:56.740
And let me call it react search agent.

07:57.380 --> 07:59.260
And let me go and push it.

08:00.740 --> 08:01.140
Sorry.

08:01.140 --> 08:02.740
Let's go and fix that.

08:02.740 --> 08:04.740
I have a bit of configuration issue.

08:04.780 --> 08:05.980
Don't worry about it.

08:07.460 --> 08:14.860
And if you want to check out the exact code I was using, go to the branch project slash react agents

08:15.180 --> 08:16.940
go here to the commit list.

08:17.100 --> 08:19.500
And here is the commit I just pushed.

08:19.980 --> 08:21.740
Let me go and minimize this.

08:21.740 --> 08:28.020
And here you can see the exact code that I was using with everything I just showed you in the previous

08:28.020 --> 08:28.580
videos.

08:29.820 --> 08:31.740
Hey there Eden here popping up.

08:31.740 --> 08:34.060
And that was a lot.

08:34.300 --> 08:39.180
So we created and ran our first link chain agent.

08:39.700 --> 08:44.980
Now it was comprised of the reasoning part and the execution part.

08:45.180 --> 08:49.500
And we saw it all boils down to a very special react prompt.

08:49.580 --> 08:54.460
The entire goal of this section is simply to get you familiar with the interface.

08:54.500 --> 08:58.940
It's okay that you're not understanding every moving part here under the hood.

08:59.100 --> 09:01.340
This is what we're going to do in the next section.

09:01.340 --> 09:07.220
We're going to break this down one layer deeper, and we're going to understand all the chain components

09:07.220 --> 09:09.020
that are running together here.

09:09.020 --> 09:11.780
And then we'll truly appreciate all the heavy lifting.

09:12.140 --> 09:13.620
Link chain is doing for us.

09:13.860 --> 09:19.260
And the cool thing that we can see here is that the reasoning engine, it all boils down into a prompt

09:19.260 --> 09:20.380
we send to the LM.

09:20.420 --> 09:21.700
I mean, how cool is that?

09:21.740 --> 09:27.970
And this is the basis for all the genetic technology we're seeing right now, this is the core primitive.

09:28.010 --> 09:29.130
This is what was started.

09:29.490 --> 09:30.090
All right.

09:30.090 --> 09:33.730
So the answer we got from our agent is text.

09:33.770 --> 09:37.250
While text is nice, we can't really use it in software.

09:37.290 --> 09:41.330
What we really want to do is to get structured output.

09:41.370 --> 09:45.810
We want to get this kind of output into a Python object.

09:45.810 --> 09:52.650
We can go and we can maybe serialize, we can pass downstream to another application and something we

09:52.650 --> 09:54.410
can work with programmatically.

09:54.530 --> 10:00.970
So in the next couple videos we're going to introduce the idea of output parsers which are going to

10:01.010 --> 10:02.410
take the LLM response.

10:02.410 --> 10:07.050
And they're going to structure it as JSON objects as Pydantic objects.

10:07.050 --> 10:11.090
And they're going to help us use programmatically the output of agents.

10:11.290 --> 10:14.810
And this is very important when building robust software.

10:15.130 --> 10:17.330
Now I'm going to give you a quick hint.

10:17.890 --> 10:20.450
The answer to that is going to be a prompt as well.

10:20.770 --> 10:22.730
So everything boils down to a prompt.

10:22.730 --> 10:23.930
This is beautiful here.

10:24.050 --> 10:25.810
Anyways, let's go to the code.
