WEBVTT

00:00.280 --> 00:05.120
So that concludes our very first foray into OpenAI agents SDK.

00:05.600 --> 00:11.880
But before we wrap up week two, day one, I did want to have a second sidebar with you.

00:12.000 --> 00:19.240
And this time, it's on the entertaining topic of vibe coding, which is a term coined by the the legendary

00:19.280 --> 00:28.200
Andrej Karpathy, who described this in I think it was an ex post that went viral about the way that

00:28.240 --> 00:35.200
he was enjoying coding with Llms and getting so much done in a way that you would sort of let the LLM

00:35.200 --> 00:40.440
generate some code and sort of go with it, tweak it a bit, generate some more, and just make so much

00:40.440 --> 00:48.840
progress in this sort of mode of working this, this ad hoc vibe coding way of navigating around things

00:48.840 --> 00:50.160
like new frameworks.

00:50.560 --> 00:56.680
So I think this is wonderful and I strongly encourage vibe coding, and I imagine that most of you are

00:56.680 --> 00:57.560
very good at it.

00:57.600 --> 01:04.220
I did want to give a few tips that I think are important to do it well, because I think it's easy to

01:04.260 --> 01:11.220
do vibe coding and to get led astray by LMS and get yourself in trouble and get stuck, which is very

01:11.220 --> 01:12.100
unpleasant.

01:12.260 --> 01:14.900
So I have five tips to leave you with.

01:14.940 --> 01:19.060
But before we get into more detail with OpenAI agents SDK and here they are.

01:19.460 --> 01:21.500
First of all, good vibes.

01:21.740 --> 01:27.460
It's important to spend time getting your prompt to the LLM to be really good that you can reuse.

01:27.460 --> 01:31.260
Lots of times you should ask for short answers.

01:31.300 --> 01:37.580
Llms tend to be quite verbose in the way that in their code that they generate, they like packaging

01:37.580 --> 01:42.060
everything with lots of exception handlers, and they tend to do things in quite long winded way.

01:42.260 --> 01:50.940
Try and ask it to come up with concise, clean code and also mention today's date and say, please make

01:50.980 --> 01:54.700
sure that you use APIs that are current as of this date.

01:54.900 --> 02:01.520
Otherwise, llms have a nasty tendency to use older APIs because that was in a lot of their training

02:01.520 --> 02:07.480
data, so explicitly prompt for that vibe, but verify.

02:07.520 --> 02:12.400
My second tip don't just ask an LLM a question and go with it.

02:12.400 --> 02:13.840
Ask a couple of llms.

02:13.880 --> 02:19.400
So I often ask the same question to ChatGPT and to Claude and have them both up.

02:19.400 --> 02:23.280
I asked the question because I'll learn from both of the answers.

02:23.320 --> 02:28.920
Often one of them is too long winded or is missing the point a bit, and one of them will be spot on.

02:28.920 --> 02:34.360
And so asking a couple or maybe even three so that you're verifying what answers you're getting is a

02:34.360 --> 02:35.880
really good technique.

02:37.000 --> 02:38.240
Step up the vibe.

02:38.240 --> 02:42.360
So this is saying I think this is such a great one.

02:42.920 --> 02:48.760
This is because I sometimes get students sending me problems.

02:48.760 --> 02:55.600
They're saying I'm stuck with this and they'll send me some code and it will be like 200 lines of code

02:55.600 --> 02:56.840
and they'll say, it's not working.

02:56.840 --> 02:57.760
I don't know why.

02:57.800 --> 03:02.260
And when I look through the code, it's immediately obvious to me that this is they've been vibe coding.

03:02.460 --> 03:08.380
You can tell there are telltale signs that a lot of this was generated by an LLM, and it's it's unwieldy,

03:08.380 --> 03:11.420
and I can sometimes see a bunch of different bugs in it.

03:11.420 --> 03:13.220
And I come back and I say, it's no good.

03:13.220 --> 03:18.140
It's no good generating 200 lines of code and then saying it's broken.

03:18.340 --> 03:19.900
That's not the way to do it.

03:20.140 --> 03:24.940
Rather, you should always try and get llms to do things a little piece at a time.

03:24.940 --> 03:26.860
Generate function by function.

03:26.860 --> 03:32.900
Generate small pieces that are independently testable, like ten lines of code at a time.

03:32.900 --> 03:39.100
So you should think of dividing your problem down into small bite sized chunks and have an LLM do each

03:39.100 --> 03:39.820
piece of it.

03:40.260 --> 03:45.380
And here's the trick if you can't think about how you would divide your problem down into ten smaller

03:45.380 --> 03:50.020
steps or whatever, you don't need to because you can ask an LLM to do that.

03:50.020 --> 03:52.700
But be very clear, you don't want it to generate code.

03:52.740 --> 03:58.210
You say, look, I'm trying to solve the following problem and you tell it and say, what I want you

03:58.210 --> 04:07.650
to do is tell me what would be the 4 or 5 steps in a solution where each step is simple and simple,

04:07.690 --> 04:13.650
bite sized chunk that could be tested and verified independently and get it to come up with those,

04:13.690 --> 04:14.530
those chunks.

04:14.730 --> 04:21.490
And then you can ask again llms to generate code for each one in turn, along with the way to test it,

04:21.490 --> 04:24.770
so that you can make sure that ten lines of code at a time.

04:24.770 --> 04:29.090
You have a working solution, and you've convinced yourself that when you've got each of these, you'll

04:29.090 --> 04:33.130
be able to put it together and have 200 perfect lines of code.

04:33.850 --> 04:34.210
Okay.

04:34.250 --> 04:37.290
And then the fourth one, vibe and validate.

04:37.290 --> 04:38.890
Similar to vibe, but verify.

04:38.930 --> 04:42.450
But Vibe and validate is saying you can ask a question to an LLM.

04:42.490 --> 04:47.290
And then when it gives you the answer, you can go to another LLM or even the same one, but better

04:47.290 --> 04:51.770
to be another one and say, I asked this question, I've got this answer.

04:52.090 --> 04:57.990
Please confirm that that is an appropriate answer and that it's you can't do anything that's more concise

04:58.230 --> 05:02.630
or better structured or clearer, or there are no bugs in this.

05:02.630 --> 05:08.990
And by having another LLM go through and validate, it will often detect problems or make it be cleaner

05:08.990 --> 05:09.910
and simpler.

05:09.910 --> 05:11.510
So it's just a nice trick.

05:11.510 --> 05:18.310
And in many ways this this mirrors this echoes the common agentic design pattern of the evaluator optimizer.

05:18.310 --> 05:20.430
But you can just do that manually yourself.

05:20.430 --> 05:25.910
So taking a leaf out of Agentic design patterns and using it as part of vibe coding.

05:26.710 --> 05:33.030
And then my final one vibe with the variety, which is don't just say, can you generate code for this?

05:33.030 --> 05:37.550
But particularly if you're only talking about ten lines of code, say, can you give me three different

05:37.550 --> 05:42.870
solutions to this three, approach it three different ways, and maybe the response will be that there

05:42.870 --> 05:43.990
aren't three different ways of doing it.

05:43.990 --> 05:47.030
There's only one clear way, but you might get three different solutions.

05:47.070 --> 05:52.830
And and that will force the model into a mode where it's contemplating different ways of approaching

05:52.830 --> 05:53.790
the same problem.

05:53.790 --> 05:56.930
And as a result, you might get better solutions.

05:57.330 --> 06:03.170
As part of that, you can also ask it to explain itself, explain the rationale so that you'll get something

06:03.170 --> 06:07.530
that will that will also force it to think through why it's approaching it differently.

06:07.610 --> 06:12.610
Plus, as an added benefit, it will explain to you what's going on so that you can really understand

06:12.610 --> 06:13.050
this.

06:13.450 --> 06:18.290
And that does sort of lead to an obvious point, which I've not put here, which is that when you do

06:18.330 --> 06:23.930
vibe coding, you should always then go back and ask an LLM to explain it clearly.

06:23.930 --> 06:29.050
If it's not immediately clear to you, get to a point where you understand every single thing that's

06:29.050 --> 06:29.770
going on.

06:29.810 --> 06:35.450
Vibe coding is super fun and productive and powerful, but if you're not following what's actually happening,

06:35.450 --> 06:39.130
it's going to become painful and frustrating when something goes wrong.

06:39.250 --> 06:42.330
So it is important to stay in touch with what's going on.

06:42.730 --> 06:43.210
All right.

06:43.210 --> 06:49.050
And that is my survival guide to vibe coding and I hope you'll find that helpful.

06:49.050 --> 06:51.970
But other than that you should definitely do it.

06:52.010 --> 06:54.570
It's it's great fun and it's super productive.
