WEBVTT

00:00.240 --> 00:00.600
Okay.

00:00.600 --> 00:05.200
Well, it remains for us to write the the main the run function in here.

00:05.200 --> 00:11.600
I deleted the default template one that's there usually, and I'm replacing it here with a simple run.

00:11.600 --> 00:16.440
The crew we're going to pass in the sector as technology.

00:16.480 --> 00:18.920
We don't actually need a current date in there at all.

00:18.960 --> 00:19.680
That will do fine.

00:19.680 --> 00:26.320
We don't use current dates and the result is Stockpicker kickoff passing in the inputs.

00:26.520 --> 00:30.200
And then we will print results at the end.

00:30.800 --> 00:32.440
So there we go.

00:32.480 --> 00:34.080
This is our starting point.

00:34.160 --> 00:37.280
I think we should give this a whirl okay here we go.

00:37.280 --> 00:42.240
So we're going to bring up our terminal as usual with control and the tick.

00:42.400 --> 00:44.760
And then we're going to go into our third folder.

00:44.760 --> 00:46.920
And we are going to go into the stock picker.

00:47.080 --> 00:48.520
And we're going to type crew.

00:48.560 --> 00:50.840
I run to kick it off.

00:51.400 --> 00:52.400
And now here's the thing.

00:52.680 --> 00:54.560
It's going to be interesting to watch this.

00:54.960 --> 01:01.040
The crew process is, by its very nature, a little bit less predictable than we might want.

01:01.200 --> 01:07.160
It is autonomous and it goes off and does its own thing, and that can involve all sorts of searching

01:07.160 --> 01:10.320
around and using multiple agents.

01:10.360 --> 01:15.440
It can sometimes go back to do some news and analysts and then using the researcher, and it can take

01:15.440 --> 01:18.080
quite a while as it goes through its processing.

01:18.200 --> 01:22.440
And my machine is chugging away like crazy, as will yours.

01:22.480 --> 01:23.000
And it's both.

01:23.040 --> 01:28.000
The great thing, and perhaps the downside of autonomous agentic AI, that we have a bit less control

01:28.000 --> 01:32.120
over how this process is followed, and so I will let it do its thing.

01:32.160 --> 01:35.880
I will break and come back when it completes its recommendation.

01:36.200 --> 01:36.920
And here we have it.

01:36.960 --> 01:40.240
It actually completed pretty much right as I was pausing there.

01:40.280 --> 01:41.280
So it was quite quick.

01:41.320 --> 01:46.480
It made a decision to recommend anthropic and it says, which was interesting because it was OpenAI

01:46.520 --> 01:52.680
that was doing this, this processing, which is and it turns down a couple of a security company,

01:52.720 --> 02:00.970
Peregrine and a crypto company, circle, and we can look in our outputs folder where we'll see that

02:00.970 --> 02:03.090
this decision is shown.

02:03.090 --> 02:06.930
And we'll also find a research list here.

02:07.170 --> 02:10.250
And also the trending companies list.

02:10.250 --> 02:15.210
And these of course are in the JSON format that conforms to our schema.

02:15.210 --> 02:22.450
So we are seeing here the proper formatted results because we required that by using structured outputs.

02:22.570 --> 02:26.970
And so despite my misgivings about the autonomous framework it actually performed really well.

02:26.970 --> 02:28.970
It did just go through the process.

02:28.970 --> 02:29.730
It should do.

02:29.970 --> 02:35.650
The manager that we'd set up had some autonomy in how it assigned out the tasks, but it did so well

02:35.650 --> 02:41.450
and as a result, we did indeed achieve a stock pick recommendation, which is not intended for real

02:41.450 --> 02:45.410
trading decisions, which is in this case for anthropic.

02:45.650 --> 02:50.010
All right, it's time to make our solution have a few more bells and whistles.

02:50.650 --> 02:52.410
First of all, we're going to add a tool.

02:52.650 --> 02:58.570
You'll see if you look in the source folder in the stock picker folder that's generated for you that

02:58.570 --> 03:03.810
there's already a folder called tools that the people at Cru have kindly made for us.

03:03.810 --> 03:10.530
And there's one in there called Custom Tool that has a kind of typical layout for these sorts of, of

03:10.570 --> 03:10.890
tools.

03:10.890 --> 03:16.250
And we are going to change the name of custom tool, and we're going to make it into push tool.

03:16.370 --> 03:19.210
So let's do rename and make this a push.

03:19.850 --> 03:21.650
Hang on click there.

03:21.690 --> 03:22.570
Try that again.

03:22.730 --> 03:27.690
Rename to push underscore tool dot pi.

03:28.290 --> 03:35.490
So the way that it works if we look in here is that you'll see that there is a when you set up a custom

03:35.490 --> 03:43.210
tool you have to first describe using a pedantic object, the schema of what will be passed in to your

03:43.210 --> 03:44.170
custom tool.

03:44.290 --> 03:51.290
And then you end up writing an underscore run method, which is going to take that schema as its parameters.

03:51.570 --> 03:56.330
So to make that feel more real, I'm going to, uh, actually implement that.

03:56.330 --> 04:01.090
And let's just start with a couple of, uh, imports here and now.

04:01.090 --> 04:07.970
So we're going to have a push notification input which will be a subclass of base model.

04:08.130 --> 04:13.330
And we're going to change the description that this is uh what is the meaning of this input.

04:13.330 --> 04:16.090
It's going to be a message to be sent.

04:16.890 --> 04:21.050
Sorry to be sent to the user okay.

04:21.690 --> 04:25.330
And now instead of an argument we're going to say message.

04:25.490 --> 04:26.770
That's what we're going to call it.

04:26.770 --> 04:31.610
And the description will be the message to be sent to the user.

04:31.890 --> 04:33.090
That seems pretty clear.

04:33.490 --> 04:33.850
Okay.

04:33.890 --> 04:38.370
So that is then defining the schema for our tool.

04:38.410 --> 04:44.090
It's in other words this here is actually going to be message to to correspond with that.

04:44.090 --> 04:47.850
That's what we will run when the tool is invoked.

04:48.290 --> 04:50.130
So or invoked rather than invoked.

04:50.370 --> 04:53.490
So uh we will um give it a name.

04:53.490 --> 04:56.820
So first of all we should change the class to be push notification tool.

04:56.860 --> 04:57.340
There we go.

04:57.340 --> 04:57.660
Thank you.

04:57.700 --> 04:58.180
Cursor.

04:58.380 --> 05:08.260
The name let's say is going to be send a push notification and the description is going to be this tool

05:08.820 --> 05:11.460
is used to send a push notification to the user.

05:11.460 --> 05:12.940
That seems pretty decent to me.

05:13.140 --> 05:13.820
Okay.

05:14.140 --> 05:16.540
And the schema for the args.

05:16.580 --> 05:20.220
This is where we say what kind of arguments do we need you to pass in.

05:20.380 --> 05:23.940
Well, that's exactly the schema that we've just defined right here.

05:24.100 --> 05:28.220
So it is something which just has a single argument message.

05:28.380 --> 05:29.140
And there you go.

05:29.180 --> 05:34.660
You see we've written a run method with a single input message.

05:34.980 --> 05:39.620
And that is going to actually send a push notification.

05:39.820 --> 05:41.940
And how do we send a push notification.

05:41.940 --> 05:45.420
We use the fabulous Pushover tool.

05:45.420 --> 05:52.140
And hopefully in your environment you have Pushover user and Pushover token set in your env file from

05:52.140 --> 05:57.860
prior week and then I just used I've just pasted in exactly the same code we have from the prior week,

05:58.020 --> 06:03.780
and we will push this message to the user and then return that that was okay.

06:04.220 --> 06:07.460
So that is our push notification tool.

06:07.460 --> 06:08.860
Now we have to put it to good use.

06:09.580 --> 06:11.260
Well this should be pretty easy actually.

06:11.300 --> 06:18.580
We're back in the crew.py module and we add in an import to import in the push notification tool.

06:18.900 --> 06:22.020
Now which of our agents do we want to be able to do this.

06:22.180 --> 06:29.380
We want the stock picker agent to be the one that will have this power the stock picker.

06:29.980 --> 06:33.340
You can see cursor of course already tells us that's exactly what we want.

06:33.380 --> 06:36.820
We want the stock picker to be able to call the push notification tool.

06:36.820 --> 06:38.060
That's as simple as that.

06:38.380 --> 06:38.940
All right.

06:38.940 --> 06:40.860
With that, let's go and run this.

06:40.900 --> 06:42.300
We'll do that right away.

06:42.300 --> 06:44.540
We will bring up this.

06:44.780 --> 06:47.140
We will clear what we have here.

06:47.380 --> 06:52.260
And we will just call, cry, run and give it a whirl.

06:52.300 --> 06:53.620
Let's see what happens.

06:53.980 --> 06:56.460
I will let this run and I'll be right back.

06:56.980 --> 06:58.020
And here we go.

06:58.060 --> 06:59.180
It's completed.

06:59.180 --> 07:04.180
It's this time recommending circle, which was one of the runners up last time.

07:04.380 --> 07:11.420
And I can assure you, you can see it right here that I did indeed get a push notification about the,

07:11.420 --> 07:14.180
the the opportunity, which is great.

07:14.180 --> 07:15.420
So it is working.

07:15.660 --> 07:19.620
And that then is the extra piece that we've added into this.

07:19.620 --> 07:25.620
So just to recap, we built this agent framework and the three things that are different than the way

07:25.620 --> 07:26.460
we've done it before.

07:26.580 --> 07:29.060
First of all we've used structured outputs.

07:29.060 --> 07:34.380
So we've required that tasks respond conforming to a JSON schema that we set.

07:34.780 --> 07:40.220
Secondly, instead of using the sequential process, we use the hierarchical process, which means that

07:40.220 --> 07:46.500
we can either pass in an LLM by model name or by passing in an agent that will take care of assigning

07:46.500 --> 07:47.980
the tasks to the agents.

07:47.980 --> 07:48.700
And we did that.

07:48.700 --> 07:52.030
And we saw, I think, both the good and the bad of doing so.

07:52.310 --> 07:57.670
And then thirdly, we added a custom tool, a tool that we wrote ourselves.

07:57.670 --> 07:58.870
And it's a familiar one.

07:58.870 --> 08:00.670
It was to send a push notification.

08:00.670 --> 08:05.790
And we armed an agent with that ability and it pulled it off successfully.

08:06.190 --> 08:10.150
And so that then is wraps up this week's project.

08:10.150 --> 08:11.430
And I'll see you for the wrap up.

08:11.910 --> 08:13.110
I think I might have just said that.

08:13.110 --> 08:14.430
That wraps up this week's project.

08:14.470 --> 08:16.270
Of course, it wraps up this day's project.

08:16.270 --> 08:17.430
We've got lots more to go.

08:17.470 --> 08:21.830
And in fact, tomorrow and in the next day before we move on to the next project, I do want to add

08:21.830 --> 08:24.670
one more bell and whistle to this project too.

08:24.710 --> 08:29.870
So we're not completely through with the stock picker either, so stay tuned for that.

08:29.870 --> 08:34.550
But again, to recap, we just did structured outputs, custom tools and hierarchical process.

08:34.750 --> 08:40.670
And tomorrow we're going to we are going to add a little bit extra to stock picker but then also work

08:40.670 --> 08:44.150
on the next project, the developer agent.

08:44.150 --> 08:45.990
And I'm really excited about that one.

08:46.030 --> 08:48.550
Good old crew is coming through strong.

08:48.590 --> 08:49.310
See you then.
