WEBVTT

00:00.360 --> 00:05.000
So look, you're here because you like getting hands on and building stuff.

00:05.000 --> 00:06.320
And that's why I'm here, too.

00:06.360 --> 00:07.920
And I got good news for both of us.

00:07.920 --> 00:09.480
That's what we're doing right now.

00:09.520 --> 00:16.960
Today we're going to be building our first OpenAI agents SDK project, building a sales development

00:16.960 --> 00:17.520
rep.

00:18.320 --> 00:22.360
And we're going to be building really three different pieces.

00:22.360 --> 00:26.280
We're going to be building three different layers of Agentic architecture where we do this.

00:26.280 --> 00:30.800
We're going to be starting with something quite simple, a workflow of agent calls.

00:30.800 --> 00:35.200
We're then going to spice it up by adding an agent that can use a tool.

00:35.440 --> 00:40.320
Remembering back to when we did this, the sort of manual way with the the JSON with the boilerplate

00:40.320 --> 00:41.160
in week one.

00:41.480 --> 00:46.360
And then we're going to have agents that can call on other agents, and you're going to discover there

00:46.400 --> 00:48.160
are two different ways of doing this.

00:48.160 --> 00:53.960
You can treat agents as tools, or you can use the thing called handoffs that I mentioned before.

00:54.200 --> 00:55.360
So keep this in mind.

00:55.360 --> 00:56.840
Keep this construct in mind.

00:56.840 --> 00:58.360
This is how we'll be approaching it.

00:58.360 --> 00:59.880
There's a lot of coding to do.

00:59.920 --> 01:00.960
Let's get started.

01:01.520 --> 01:05.080
And so here we are back in cursor ready for the day.

01:05.080 --> 01:07.200
To begin, we open the OpenAI folder.

01:07.200 --> 01:08.760
We go to lab two.

01:09.240 --> 01:10.640
Here we are at the start of week two.

01:10.640 --> 01:12.200
Lab two, day two.

01:12.240 --> 01:13.880
We're going to do an agent workflow.

01:13.880 --> 01:16.080
We're going to use tools to call functions.

01:16.080 --> 01:19.360
And then we're going to collaborate with tools and handoffs.

01:19.640 --> 01:23.200
So before we start we're going to be making use of a tool.

01:23.400 --> 01:24.960
It's called SendGrid.

01:24.960 --> 01:29.640
And it will allow you to send transactional emails from their servers.

01:29.640 --> 01:30.520
It is free.

01:30.520 --> 01:32.720
So it's going to be very easy to set up.

01:32.720 --> 01:34.160
It's actually owned by Twilio.

01:34.160 --> 01:35.760
So it's a very well known company.

01:35.800 --> 01:38.360
It's similar to something like Sparkpost if you've used that before.

01:38.360 --> 01:40.640
And of course you can use Sparkpost instead if you prefer.

01:41.080 --> 01:42.440
So there's a link here.

01:42.440 --> 01:48.120
If you visit SendGrid right there up, it will come and you can start for free by pressing this button

01:48.120 --> 01:49.040
right here.

01:49.240 --> 01:53.560
And once you do that and you've set up an account, I will switch to another window.

01:53.720 --> 01:54.240
Here we go.

01:54.280 --> 01:56.240
This is what I get once I've signed in.

01:56.280 --> 02:00.480
You can see that I've sent 1 or 2 emails, and there's just a few things for you to do.

02:00.480 --> 02:06.120
Once you've done this, you go to the settings menu down here and to the API keys section.

02:06.120 --> 02:10.110
That is where you will set up an API key and copy it to your clipboard.

02:10.350 --> 02:12.350
You can guess where that's going to go in just a second.

02:12.590 --> 02:17.430
The other thing to do is to go to this tab here Sender Authentication.

02:17.630 --> 02:21.390
And you're going to click this verify a single sender button.

02:21.390 --> 02:26.110
And what that's going to do is it's going to allow you to set up your your own email address.

02:26.110 --> 02:28.310
This is my email address right here.

02:28.310 --> 02:32.110
And do a verify email to confirm that you do own that email.

02:32.110 --> 02:36.510
And once you've done that, you'll be able to send emails from that email address.

02:36.670 --> 02:41.950
So that's a nice thing to do, just so that you'll be able to send emails via SendGrid from that email

02:41.950 --> 02:42.390
address.

02:42.390 --> 02:45.670
But don't worry, we're not actually going to be sending any cold emails out to the world.

02:45.670 --> 02:50.430
It will only be emails going back to you again, this would just be experimental, but you can always

02:50.430 --> 02:53.150
use it for more purposes in the future.

02:53.550 --> 02:55.150
So that is SendGrid.

02:55.190 --> 02:56.670
Please go ahead and get that set up.

02:56.670 --> 02:59.350
And shockingly, I'm sure you expected this.

02:59.390 --> 03:06.350
Once you've done that, you'll then edit your env file over there and you will add in a single row SendGrid

03:06.390 --> 03:07.990
API key equals.

03:07.990 --> 03:13.750
And of course you will paste in there the thing that you've copied from the API keys section.

03:13.790 --> 03:16.790
You created a key there in SendGrid itself.

03:16.830 --> 03:17.390
All right.

03:17.390 --> 03:19.710
So go ahead and do that and then we will proceed.

03:20.350 --> 03:20.910
Okay.

03:20.990 --> 03:24.070
And so now we have some imports.

03:24.070 --> 03:25.950
We're going to be doing some usual stuff.

03:25.950 --> 03:28.750
We've got a few more from agents.

03:28.750 --> 03:31.350
We're also importing this thing called function tool.

03:31.630 --> 03:34.830
We're importing something to help us stream back text.

03:34.990 --> 03:37.990
And we're importing some SendGrid stuff.

03:38.310 --> 03:42.430
We're going to load our environment variables as usual.

03:42.710 --> 03:49.270
And now let's do a simple workflow between agents without anything fancy.

03:49.310 --> 03:53.790
Here we're just going to have some agents calling other agents, and we're going to orchestrate it manually

03:53.790 --> 03:55.950
ourselves in Python code.

03:55.950 --> 03:57.670
And it's going to be super simple.

03:58.110 --> 04:00.750
So first of all three instructions.

04:01.350 --> 04:03.870
And these instructions again think of it in the back of your mind.

04:03.870 --> 04:06.110
These are basically system prompts.

04:06.110 --> 04:09.070
But they are the way that we are framing different agents.

04:09.390 --> 04:15.260
All three are about being sales agents working for a company that I'm calling.

04:15.260 --> 04:16.180
Comply.

04:16.500 --> 04:17.180
Comply.

04:17.340 --> 04:20.300
I are the wonderful naming.

04:20.300 --> 04:27.420
This is a Soc2 compliance company that is looking at helping companies prepare for Soc2 audits.

04:27.660 --> 04:31.300
So something to do with compliance if you're not familiar with this stuff.

04:31.300 --> 04:35.620
But, uh, yeah, it's a SaaS tool that will ensure soc2 compliance.

04:35.820 --> 04:38.460
So it's saying you're a sales agent working for this company.

04:38.700 --> 04:42.860
You write professional, serious cold emails.

04:42.900 --> 04:46.420
It's like a cold sales email or email to to get people interested.

04:46.780 --> 04:49.900
The second one is a humorous, engaging sales agent.

04:49.900 --> 04:54.820
You write witty, engaging, cold emails that are likely to get a response.

04:55.460 --> 05:02.100
And the third one is you're a busy sales agent and you write concise to the point cold emails.

05:02.220 --> 05:08.660
So, as you know from good prompting, you use a system prompt instructions to set the context, to

05:08.700 --> 05:10.780
give the tone to sort of set.

05:10.820 --> 05:16.380
Set the mood and the character and give as much background information as you can in a succinct, instructive

05:16.380 --> 05:16.820
way.

05:17.580 --> 05:20.300
Okay, so now we create three agents.

05:20.620 --> 05:22.740
Sales agent one, two and three.

05:22.780 --> 05:24.500
And this should be very simple.

05:24.500 --> 05:26.060
It should make complete sense to you.

05:26.100 --> 05:28.340
Each agent gets given a different name.

05:28.340 --> 05:31.580
They have the three instructions the three system prompts.

05:31.580 --> 05:34.820
And we're going to be using GPT four mini throughout.

05:34.860 --> 05:35.900
Keep it cheap.

05:36.100 --> 05:38.460
We've just created those three agents.

05:38.900 --> 05:39.220
All right.

05:39.220 --> 05:41.100
And now we're just going to start with the first one.

05:41.460 --> 05:43.380
And I just wanted to show you a different way.

05:43.420 --> 05:46.180
You remember we had runner run before.

05:46.300 --> 05:50.660
Well now I'm calling runner run streamed, which is a way that you can do it.

05:50.660 --> 05:53.540
That will allow us to stream back results.

05:53.580 --> 05:59.220
You may be familiar with streaming from from simpler OpenAI examples, but this is how you can do it

05:59.220 --> 06:00.940
with the agents SDK.

06:01.460 --> 06:07.340
So you may spot that there's no ace a wait word there which which may set off alarm bells, because

06:07.340 --> 06:09.940
that means that what we're getting here is not a response.

06:09.940 --> 06:11.820
We're getting a co-routine.

06:12.100 --> 06:13.860
And you can see what happens next.

06:13.900 --> 06:22.690
We use a special construct async for a special way of of then calling this, calling this in a way that

06:22.690 --> 06:27.330
will return a coroutine, and we will then iterate through those answers.

06:27.330 --> 06:32.650
And this is just a little bit of boilerplate code to make sure that what's coming back is some text

06:32.650 --> 06:33.650
that we can print.

06:33.650 --> 06:35.890
And if we get that, then we print it.

06:36.210 --> 06:39.810
And this just stops it printing on a separate line every time.

06:40.090 --> 06:44.010
So if I run this, it's just very similar to what we did last time.

06:44.010 --> 06:49.170
But you'll see that what comes back streams back bit by bit.

06:49.370 --> 06:54.290
And it's a very nice use of the streaming APIs and I show it to you.

06:54.290 --> 06:56.890
So you have an example of how to how to do this.

06:57.170 --> 07:02.130
And of course, just as you would expect, we see a great behavior from our agent.

07:02.330 --> 07:07.450
This is the professional one, I think, and we can see that it's come back with something nice and

07:07.450 --> 07:09.130
professional, nice and slick.

07:09.170 --> 07:11.610
To simplify your soc2 compliance efforts.

07:11.610 --> 07:17.090
And it's no surprise to to everyone that's worked with Llms for a bit that they are really good at this

07:17.130 --> 07:17.650
kind of thing.

07:17.650 --> 07:24.290
They can write great professional, realistic, reasonable sales outreach emails.

07:24.810 --> 07:26.130
So far, so good.
