WEBVTT

00:00.160 --> 00:03.680
So here's the core idea behind Autogen core.

00:04.120 --> 00:10.920
And I've already alluded to this idea, and it's that it's all about decoupling the logic of an agent,

00:11.160 --> 00:17.200
what it actually does from how messages get delivered to it, from the interplay between them.

00:17.640 --> 00:21.640
The framework deals with creating and communicating.

00:22.040 --> 00:27.080
It deals with creating agents, the whole life cycle of an agent, and the messages, the communication

00:27.080 --> 00:31.880
between them and the agents themselves or us as the people coding the agents.

00:31.880 --> 00:33.560
We're responsible for the logic.

00:33.600 --> 00:36.360
It's not the mandate of Autogen core.

00:36.400 --> 00:38.920
It just deals with with letting them play.

00:39.760 --> 00:43.560
And there's two ways that it lets them play.

00:43.600 --> 00:45.440
Two types of runtime.

00:45.440 --> 00:51.160
The runtime is the kind of world in which agents interact and the two types.

00:51.160 --> 00:56.320
One of them is called standalone, which basically essentially means it sort of runs on your box in

00:56.320 --> 00:57.160
a simple way.

00:57.320 --> 01:04.120
And the other distributed is that it runs in a way that could allow remote agents to interact with each

01:04.120 --> 01:04.400
other.

01:04.440 --> 01:08.440
So these are the two kinds, and you code them both a bit differently.

01:08.440 --> 01:13.440
We are going to look at the standalone one today, and we're going to go to the distributed one tomorrow.

01:13.720 --> 01:16.800
And look, I have to tell you, I'm only going to do this at a high level.

01:16.800 --> 01:21.720
We're going to breeze through this quite quickly and the examples will be somewhat superficial.

01:21.880 --> 01:23.080
And there's a reason for this.

01:23.080 --> 01:28.040
I feel like we've done enough detail on lots of frameworks and actually building agents.

01:28.200 --> 01:31.920
I'm not sure how applicable this is going to be to your use case.

01:31.920 --> 01:36.800
I think it's good for you to get a feel for it, and to get a good sense of how this is positioned and

01:36.800 --> 01:38.080
where it might be useful.

01:38.400 --> 01:39.280
And that's my goal.

01:39.320 --> 01:44.400
Give you a flavor, give you, give you that kind of sense of where it fits in the ecosystem and if

01:44.400 --> 01:48.800
it's relevant for you, if this is something that you do want to put into practice, then you should

01:48.840 --> 01:52.040
carry out more R&amp;D and work on this a bit more yourself.

01:52.040 --> 01:54.400
And I'll give you plenty of starting points for that.

01:54.400 --> 01:59.480
But I'm not going to go so deep into this as some of the other frameworks as like Landgraf last time,

01:59.920 --> 02:01.720
but enough so you get a feel for it.

02:01.720 --> 02:06.640
And then and then we, uh, we, we move on because I know you're anxious to get to MCP.

02:07.080 --> 02:07.440
All right.

02:07.440 --> 02:08.840
Let's let's do a lab.

02:08.840 --> 02:17.350
So here we are in good old cursor going to the fifth folder for Autogen, and we are going to lab three

02:17.390 --> 02:18.870
Autogen core.

02:19.390 --> 02:22.510
Uh, so this this is where we begin.

02:22.550 --> 02:24.990
Uh, there's, there's, as I say, something a little different.

02:24.990 --> 02:27.950
This is going to be different to anything we've looked at before.

02:28.310 --> 02:29.590
Um, okay.

02:29.630 --> 02:33.630
So there's a bunch of, uh, imports, including a good old, uh, load dot env.

02:34.030 --> 02:36.190
Let me just restart this, make sure it's fresh.

02:36.470 --> 02:38.230
Do, uh, do the load dot env.

02:38.670 --> 02:39.350
All right.

02:39.550 --> 02:47.790
So the first thing we do is we define our own object which is going to be used for passing information

02:47.790 --> 02:50.750
around the place, our own message object.

02:50.750 --> 02:57.030
And it is a type of, uh, I don't know if it's if this is required, but a data class means it's a

02:57.030 --> 02:59.950
class that's not going to have any feel any, any methods.

03:00.230 --> 03:05.830
All it is, is something that holds data in, uh, and that makes sense because the message is not going

03:05.830 --> 03:07.190
to be something with functionality.

03:07.230 --> 03:12.030
It's going to be used to transport transport information between our agents.

03:12.390 --> 03:17.710
And in a way, like doing this is sort of analogous to when we were in Landgraaf.

03:17.710 --> 03:20.110
We started by defining a state.

03:20.150 --> 03:21.830
Landgraaf is a state machine.

03:21.830 --> 03:26.390
It's very focused on what is the state and making sure that that's something that you can move backwards

03:26.390 --> 03:27.310
and forwards in.

03:27.310 --> 03:33.270
And it's interesting that, you know, auto Jens auto gen core fundamental idea is all about messaging.

03:33.270 --> 03:37.310
And so the thing that you start by defining is your message.

03:37.590 --> 03:41.510
And in our case, we're going to have a very simple one that just has one field which is content, which

03:41.510 --> 03:42.390
is a string.

03:42.390 --> 03:47.110
But you can experiment with what you pass between your agents being something much more sophisticated

03:47.110 --> 03:49.270
with all sorts of different bits of information.

03:49.470 --> 03:50.910
So there we have it.

03:50.950 --> 03:55.350
We have a message with a string, and that's all the message we'll be using for today.

03:55.710 --> 04:01.590
So now we get to define our agent in Autogen core.

04:01.590 --> 04:07.070
And it's important to bear in mind that the agent that we're about to create in Autogen core is different

04:07.070 --> 04:11.270
to the agent that we just created in Agent Chat.

04:12.070 --> 04:12.590
It's different.

04:12.590 --> 04:14.190
It's like a tongue twister to say all of this.

04:14.190 --> 04:15.710
It's hard to keep your mind on it.

04:15.830 --> 04:16.510
You're like, what?

04:16.510 --> 04:17.550
How is it different?

04:17.590 --> 04:23.350
Well, look, the agent that you define in Autoencoder is just like a wrapper.

04:23.350 --> 04:28.830
It's like saying this is a thing that can be messaged, it can be created, it can be managed, it can

04:28.830 --> 04:30.830
be referred to and it can be messaged.

04:30.830 --> 04:35.910
But what you do with this is your responsibility and you're going to have to delegate to something.

04:35.910 --> 04:40.790
But this, this, this is like a management object, if you will, a management object which you're

04:40.790 --> 04:41.550
going to use.

04:41.630 --> 04:49.190
And it has amongst other things, it has an agent ID and every agent has a unique ID, and that ID has

04:49.190 --> 04:52.230
two, two parts to it, a type and a key.

04:52.550 --> 04:55.150
So every single agent has a type and a key.

04:55.150 --> 04:59.950
And that combination of type and key is then unique and can uniquely identify it.

04:59.950 --> 05:04.830
So if you imagine when we in the future look at a distributed runtime in that runtime, there could

05:04.830 --> 05:10.070
be agents from from all over the world collaborating in this distributed runtime, but every one of

05:10.070 --> 05:16.190
them will have a unique type plus ID that that identifies it precisely, and any agent will be able

05:16.190 --> 05:20.950
to talk to another one if it knows it's its name and its ID, or its key and its ID.

05:21.350 --> 05:28.670
So this gives you a sort of good sense of the fabric of it, and that an agent class that you make is

05:28.670 --> 05:29.790
not actually an LLM.

05:29.790 --> 05:32.630
It's not an Autogen agent chat agent.

05:32.670 --> 05:37.950
It's just this management holder object, something which has a type and a key.

05:38.070 --> 05:41.510
So here is our first Autogen core agent.

05:42.190 --> 05:43.670
It's called Simple Agent.

05:44.190 --> 05:50.070
As you will see it is a subclass of something called rooted agent, which is the typical the thing that

05:50.110 --> 05:52.990
you that you have as your as your parent as your superclass.

05:53.630 --> 05:55.910
And it only has two, two methods.

05:56.110 --> 05:59.070
One of them is the init that the constructor.

05:59.390 --> 06:04.630
And all it does is it calls its its parents passing in its name.

06:04.630 --> 06:05.110
Simple.

06:05.630 --> 06:06.630
That's all it does.

06:06.950 --> 06:13.430
Then it has another, uh, method called on my message, which is an async.

06:13.830 --> 06:15.990
Uh, so it's a coroutine.

06:16.030 --> 06:16.910
It's an async method.

06:16.910 --> 06:18.390
It is an async coroutine.

06:18.470 --> 06:19.350
It is a coroutine.

06:19.670 --> 06:23.910
Uh, and it's decorated with message handler.

06:24.350 --> 06:25.910
And that's what matters.

06:26.150 --> 06:32.220
Any method that you decorate with message handler means that potentially this is something that will

06:32.220 --> 06:36.620
receive messages and Autogen core handles.

06:36.620 --> 06:41.100
The fact that you'll be able to register this, and a runtime is going to manage this.

06:41.140 --> 06:47.660
And if someone sends a message to something with my name and my ID, then it's going to end up here.

06:47.900 --> 06:49.780
At least it's going to end up here.

06:49.780 --> 06:54.620
If what they dispatch is a message of this class.

06:54.940 --> 07:00.660
So this is a bit of a pro thing, but you can have multiple different classes and you can use that to

07:00.660 --> 07:02.980
be able to handle different types of message.

07:03.220 --> 07:07.140
Uh this may be more detail than you need, but you you could, for example, have a text message and

07:07.140 --> 07:10.540
an image message and have two separate handlers.

07:10.540 --> 07:15.860
And just by virtue of the different signatures, the different method signatures, Autogen core will

07:15.860 --> 07:21.580
automatically dispatch the right message to the right method, the right coroutine.

07:22.100 --> 07:23.220
That's that's what it does.

07:23.220 --> 07:25.780
It's all about dispatching messages properly.

07:26.140 --> 07:32.620
Uh, and so this, this simple, uh, agent is going to return a, it's going to receive a message and

07:32.620 --> 07:40.060
it's going to return a message is now that I said it is a bit like this idea that in Landgraf we, uh,

07:40.060 --> 07:42.620
took in our nodes, took a state and returned a state.

07:42.620 --> 07:44.860
But this is just like a parallel thing.

07:44.860 --> 07:46.420
But it's all about messages.

07:46.420 --> 07:47.940
It receives a message, and it.

07:47.940 --> 07:49.340
And it returns a message.

07:49.700 --> 07:51.180
Um, and it's an async.

07:51.900 --> 07:53.060
It's a coroutine, as I said.

07:53.140 --> 07:54.620
So it receives a message.

07:54.860 --> 07:58.220
And this one isn't going to do anything with the message it receives.

07:58.220 --> 08:00.260
There's no lm, there's nothing here.

08:00.260 --> 08:06.820
It simply returns, uh, a message which has this is and gives my ID and my key.

08:07.020 --> 08:10.020
So it's sort of identifying itself as saying this is blah, blah, blah.

08:10.340 --> 08:15.180
You said and I'm going to I'm going to replay back what what the person said.

08:15.180 --> 08:17.500
So I do actually I do, I do use this.

08:17.740 --> 08:20.540
You said blah blah blah and I disagree.

08:22.900 --> 08:24.460
Uh, so that is simple, agent.

08:24.860 --> 08:27.500
Maybe I should call it a disagreeable agent.

08:27.860 --> 08:29.660
Uh, that's that's what it does.

08:29.660 --> 08:33.420
There's no lm there's no AI involved in this at all.

08:33.620 --> 08:39.540
It's, uh, you know, it's just a piece of code, but that that doesn't matter to auto gen core.

08:39.580 --> 08:43.140
Auto gen core just cares about the handling of messages.
