WEBVTT

00:00.320 --> 00:02.360
So here we are, back in cursor.

00:02.400 --> 00:03.680
A great place to be.

00:03.960 --> 00:06.560
So on the left is our directory structure.

00:06.560 --> 00:12.800
I open up the foundations folder and I'm going to go to lab two which is what we're doing right now.

00:12.800 --> 00:14.360
Welcome to the second lab week one.

00:14.360 --> 00:15.160
Day three.

00:15.440 --> 00:17.720
We're going to work with a lot of models.

00:18.080 --> 00:20.920
Now let me start with just some quick points.

00:21.280 --> 00:26.000
First of all, I want to mention that the way that I like to do this, the way that that I collaborate

00:26.000 --> 00:29.360
with you may be different to some other courses that you've taken.

00:29.360 --> 00:31.200
And it's something that is a bit controversial.

00:31.200 --> 00:36.600
Some people like it, some people don't like it, and I hope that you'll get used to it.

00:36.960 --> 00:42.800
Typically, I don't like to just sit here typing code because I feel like that slows down the momentum.

00:43.000 --> 00:49.840
Rather, I look at cells, I explain what they do, I run them, I inspect them, I print them, and

00:49.840 --> 00:51.760
that's what I recommend you do as well.

00:52.080 --> 00:57.280
Watch while I go through this and explain it, and then come back afterwards and run it yourself.

00:57.280 --> 00:58.920
And then add in print statements.

00:58.960 --> 00:59.940
Change things.

00:59.940 --> 01:01.020
Experiment.

01:01.020 --> 01:04.140
It's all about experimentation and that's what you should be doing.

01:04.140 --> 01:09.460
So for people that would prefer it if I, if I sat here typing, I'm sorry, I will try and do it from

01:09.460 --> 01:09.820
time to time.

01:09.820 --> 01:10.940
I'm going to do it right here.

01:10.940 --> 01:15.300
I will do it occasionally, but most of the time I'm going to explain what I'm doing and I hope you'll

01:15.300 --> 01:15.940
get used to that.

01:15.940 --> 01:19.620
And you'll see that there are pros and cons of everything, but that's the way I like to do it.

01:19.980 --> 01:25.260
Now, one thing I will really, really encourage you is written here that that once you've gone through

01:25.260 --> 01:30.980
this and made some changes, done the exercises, perhaps it would be fabulous if you were willing to

01:31.020 --> 01:38.220
save your changes in the folder called Community Contributions and raise a PR or a pull request for

01:38.220 --> 01:43.100
me to merge that into the repo so that other students get to benefit from this as well.

01:43.140 --> 01:47.580
To my great joy for my other course, there have been hundreds of PRS.

01:47.620 --> 01:53.300
There are tons of examples from people like you taking the course and submitting what they do with all

01:53.340 --> 01:57.180
sorts of fun and interesting examples, and it's been a real joy to see.

01:57.220 --> 02:02.640
And it's also been valuable for other students to experiment with, with people's contributions.

02:02.640 --> 02:04.520
So it's a fabulous thing to do.

02:04.560 --> 02:05.960
I really encourage it.

02:06.200 --> 02:11.880
In addition to that, something which is a good career thing to try is it's good if you have your own

02:11.880 --> 02:17.240
GitHub repo, and as you work on different projects, put some of your own stuff there as well.

02:17.280 --> 02:19.480
Showcase the work that you're doing.

02:19.600 --> 02:24.240
And if you put a post on LinkedIn to talk about some of the projects that you've worked on or some of

02:24.280 --> 02:28.600
the things you've done or what you've learned from it, and you tag me on it so that I get a notification

02:28.600 --> 02:29.480
in LinkedIn.

02:29.520 --> 02:34.040
Then when I see that, I'll come in and I'll weigh in and I'll make sure that I post something there

02:34.040 --> 02:34.760
as well.

02:34.800 --> 02:36.840
And that amplifies what you're doing.

02:36.840 --> 02:41.080
It means that it goes out to all the other people I'm connected with on this course, and people can

02:41.120 --> 02:42.760
then weigh in with their thoughts too.

02:42.800 --> 02:48.520
And it helps to draw attention to this, the skills you're acquiring, your expertise and your examples.

02:48.520 --> 02:52.960
And that's the kind of thing that that might attract the attention, perhaps, of a future client of

02:52.960 --> 02:58.580
yours, someone that might contact you for some business and potentially even a future employer as well.

02:58.580 --> 02:59.980
So it's a great thing to do.

02:59.980 --> 03:04.060
I strongly encourage it, and I'll be here to amplify the work that you do.

03:04.980 --> 03:06.180
Okay, let's get on with it.

03:06.180 --> 03:11.220
So it begins, of course, with some inputs and I press shift Enter to run these inputs.

03:11.260 --> 03:13.820
Be sure to run the inputs or you will get name errors.

03:14.140 --> 03:14.660
Okay.

03:14.780 --> 03:17.540
So always remember to do this as the comment what is that.

03:17.580 --> 03:22.820
Well it is of course doing a load to bring in the environment variables.

03:22.820 --> 03:28.780
And you remember that I like to have override is true to avoid any existing environment variables taking

03:28.780 --> 03:29.500
priority.

03:29.500 --> 03:30.660
So that has happened.

03:30.780 --> 03:35.940
So now that that's run, what we should find is that we've got a bunch of environment variables.

03:35.980 --> 03:40.900
Now I've been I've been quite greedy and I've set up a bunch of different APIs.

03:40.900 --> 03:45.940
And I don't expect you to do the same, but should you wish to, here are all of the APIs that you could

03:45.980 --> 03:46.620
set up.

03:46.620 --> 03:48.340
And I have done so and I have enjoyed it.

03:48.620 --> 03:53.580
Open AI, anthropic, Google's Gemini, Deep Seek, and grok.

03:53.940 --> 03:59.520
It's worth mentioning grok as when I did it at least doesn't have like an upfront a minimum.

03:59.520 --> 04:03.960
You only pay for what you use and it's really cheap, so this is a good one to try.

04:04.160 --> 04:06.760
Deep seek has a $2 upfront.

04:06.800 --> 04:08.160
At least it did for me.

04:08.200 --> 04:12.080
And then you draw down against that $2 and I haven't been able to spend $2.

04:12.720 --> 04:16.680
Gemini is free for within certain tiering.

04:17.000 --> 04:22.800
And anthropic and OpenAI both require an upfront, which I believe is $5 in the US for both.

04:22.800 --> 04:26.920
Although OpenAI appears to have a new deal right now, which I don't know how long that will last for,

04:26.920 --> 04:28.360
but you could always go and check it out.

04:28.840 --> 04:34.200
So this code here will load in the environment variables and just check that these keys look right if

04:34.240 --> 04:35.080
you're using them.

04:35.080 --> 04:38.120
And when I run this it gets this print here.

04:38.120 --> 04:43.360
And you can see that I've got keys that look like they should look or with the right kinds of prefixes.

04:43.520 --> 04:47.560
And if you run this cell and you haven't set up some of these keys, you'll get you'll get some sort

04:47.560 --> 04:48.800
of not set.

04:48.800 --> 04:50.360
But don't worry about that.

04:50.360 --> 04:53.760
Just don't don't call that particular model okay.

04:54.210 --> 04:58.530
And now to get started, we're going to make a bunch of different calls to LMS.

04:58.690 --> 05:00.890
And there's two objectives for this.

05:00.890 --> 05:06.370
One of them is just to show you the different kinds of API's, the different style of messaging that

05:06.370 --> 05:08.490
we have with with different LMS.

05:08.490 --> 05:13.090
So you get a sense of it, because we'll be talking to lots of LMS over the next few weeks, and the

05:13.090 --> 05:17.170
other is to do some orchestration between models.

05:17.290 --> 05:21.810
A few of the design patterns that we talked about last time to see how that works out.

05:22.050 --> 05:25.290
So the first thing we're going to do here is we have a question.

05:25.330 --> 05:26.890
We're going to have a request.

05:26.930 --> 05:32.970
Please come up with a challenging, nuanced question that I can ask a number of LMS to evaluate their

05:32.970 --> 05:34.010
intelligence.

05:34.330 --> 05:36.130
Please answer only with the question.

05:36.170 --> 05:37.650
No explanation.

05:37.650 --> 05:41.850
So that's going in a variable called request and into a variable called messages.

05:41.850 --> 05:46.970
We're going to have this standard OpenAI construct role is user.

05:47.130 --> 05:51.410
The content is going to be this request that we have right here.

05:51.690 --> 05:55.790
So in fact what I'm going to do is I'm going to add another code cell here.

05:55.790 --> 05:56.910
Let's run this.

05:57.590 --> 05:59.390
And I'm just going to print messages.

05:59.390 --> 06:03.150
Just so you see this, just in case it's not completely clear to you.

06:03.150 --> 06:06.510
It's a list of dictionaries role user content.

06:06.510 --> 06:07.710
And there's the content.

06:07.950 --> 06:11.590
Now, people who've been on my prior course or generally know about these things might be wondering

06:11.590 --> 06:13.230
why there isn't a system message.

06:13.270 --> 06:17.830
Well, we often do do talk about the need for a system message and a user message, but system messages

06:17.870 --> 06:18.910
are optional.

06:18.910 --> 06:21.750
You don't need one, particularly if it is a kind of standard.

06:21.790 --> 06:23.470
You are a helpful assistant then.

06:23.470 --> 06:24.430
Then you don't need to say it.

06:24.430 --> 06:27.710
It will work perfectly well without it, as you will see.

06:28.110 --> 06:29.190
Let's give it a try.

06:29.230 --> 06:35.790
We're going to to use the same API structure that we did last time that hopefully most of you are pretty

06:35.790 --> 06:39.030
familiar with, and that cursor will just fill in for you if you start typing this.

06:39.030 --> 06:48.470
Anyway, we create a new instance of the OpenAI Python client library and we call OpenAI create.

06:48.510 --> 06:52.810
We pass in the model, we're going to use the cheap GPT four mini.

06:52.850 --> 07:00.570
We pass in this list of dicts, and we get back and we ask for the choices zero message content, and

07:00.570 --> 07:03.650
we'll print it, and we're putting it in a variable called question.

07:03.650 --> 07:05.330
Let's see what we get.

07:05.930 --> 07:14.010
So how would you analyze the ethical implications of using AI in predictive policing?

07:14.250 --> 07:14.530
Wow.

07:14.570 --> 07:18.970
Considering factors such as bias, accountability and societal impact that is a good question.

07:19.010 --> 07:19.810
Goodness.

07:19.850 --> 07:20.290
Wow.

07:20.410 --> 07:23.050
Okay, that's a hard question for sure.

07:23.210 --> 07:25.290
This is going to be an interesting challenge.

07:25.290 --> 07:28.650
We will see what happens next okay.

07:28.970 --> 07:36.970
So what I'm going to do next is I'm going to first set up an empty list called Competitors List that

07:36.970 --> 07:39.810
we will be filling up with different names of competitors.

07:39.810 --> 07:42.890
And I'm then going to have another list which I'm going to call answers.

07:43.210 --> 07:49.450
And that's going to be where we will fill up different answers from different llms answering this question.

07:49.910 --> 07:54.270
and then we will put together the, the messages that we're going to to, to say to them.

07:54.510 --> 07:57.830
And I love the way Castor does this, but this is exactly what we want.

07:57.870 --> 08:00.270
We want a list of Dick's role is user.

08:00.310 --> 08:06.670
The content will be this question, the exact question that GPT four mini just asked us.

08:07.270 --> 08:11.390
Okay, we're now going to go through and I need to remember to run that cell.

08:11.750 --> 08:15.470
We'll run that cell and we will go through and ask some models.

08:15.590 --> 08:18.590
And why not start with the same model that came up with the question?

08:18.590 --> 08:22.710
We will start by asking GPT four or mini its own question.

08:22.710 --> 08:23.790
So this is what we do.

08:23.790 --> 08:27.790
We're going to have a variable model name which we will put GPT four or mini in.

08:27.950 --> 08:33.870
And then we will say response is OpenAI create that standard API.

08:34.030 --> 08:35.270
We pass in the model name.

08:35.270 --> 08:37.590
We pass in the messages that we've got right here.

08:37.910 --> 08:41.590
And then we take back the answer choice is zero message content.

08:41.710 --> 08:43.670
We will print that answer.

08:43.710 --> 08:45.270
Let's do better than than print it.

08:45.270 --> 08:47.350
Let's use markdown instead.

08:47.350 --> 08:52.010
So we'll say display markdown answer so that we get to see it in a nice format.

08:52.010 --> 08:54.370
Because, you know, these models love to respond in markdown.

08:54.690 --> 08:58.730
And then we will add GPT four or mini to our competitors.

08:58.730 --> 09:02.330
And we will add that answer to our list of answers.

09:03.050 --> 09:03.690
Sound good?

09:03.930 --> 09:04.970
Let's give this a try.

09:05.490 --> 09:07.210
So it's running while it's running.

09:07.490 --> 09:08.290
Take a look.

09:08.330 --> 09:14.610
And and whilst you should never need to memorize these APIs because it will always fill it in for you,

09:14.610 --> 09:18.330
it's good to have an instinct for what this API looks like.

09:18.330 --> 09:19.770
The chat completions API.

09:20.410 --> 09:22.610
All right, so here came the response.

09:22.650 --> 09:25.370
It was of course in beautiful markdown.

09:25.370 --> 09:28.250
And you can see it's a I am not going to read it through now.

09:28.290 --> 09:29.010
Live with you.

09:29.010 --> 09:35.050
But it looks like it's a pretty robust answer that has good categories and a bunch of different sections

09:35.050 --> 09:36.130
and a conclusion.

09:36.370 --> 09:40.050
The ethical implications are complex and multifaceted.

09:40.250 --> 09:40.890
Okay.

09:41.090 --> 09:42.010
Fair enough.

09:42.250 --> 09:42.810
That's good.

09:42.810 --> 09:44.970
That's GPT four mini.

09:45.010 --> 09:47.330
We will now move on to another API.
