1
00:00:00,160 --> 00:00:08,240
Okay, so here we are back in Cursa going to the fifth directory where there are a few things for me
好的，我们回到 Cursa，进入第五个目录，那里有一些适合我的东西

2
00:00:08,240 --> 00:00:09,240
to show you.
向您展示。

3
00:00:09,840 --> 00:00:13,080
So, uh, where to begin?
那么，呃，从哪里开始呢？

4
00:00:13,440 --> 00:00:18,400
I am going to begin by telling you about Agent Pi.
我将首先向您介绍 Pi 特工。

5
00:00:19,200 --> 00:00:22,480
So Agent Pi is like our template.
所以 Pi 特工就像我们的模板。

6
00:00:22,640 --> 00:00:29,160
This is a file that we are going to give another agent and ask it to use this as its model, as its
这是一个文件，我们将提供给另一个代理并要求它使用这个作为它的模型，作为它的模型。

7
00:00:29,160 --> 00:00:34,480
example, and to take this as a template and to make other agents like this.
并以此为模板，制作其他类似的代理。

8
00:00:34,840 --> 00:00:37,480
So it is quite simply, it's like a prototype.
所以它很简单，就像一个原型。

9
00:00:37,480 --> 00:00:39,680
It is our the prototype that will be used.
这是我们将使用的原型。

10
00:00:39,720 --> 00:00:43,000
We will clone it and make various versions of it or we won't.
我们将克隆它并制作它的各种版本，否则我们不会。

11
00:00:43,040 --> 00:00:43,880
An agent will.
代理会的。

12
00:00:44,120 --> 00:00:46,160
So it does some some imports.
所以它做了一些导入。

13
00:00:46,480 --> 00:00:47,840
It has a system message.
它有一条系统消息。

14
00:00:47,840 --> 00:00:49,280
You are a creative entrepreneur.
你是一位富有创造力的企业家。

15
00:00:49,320 --> 00:00:55,120
Your task is to come up with a new business idea using a genetic I or refine an existing idea.
你的任务是利用基因 I 提出一个新的商业想法或完善现有的想法。

16
00:00:55,160 --> 00:00:59,970
Your personal interests are in these sectors and there's a couple of sectors you're drawn to ideas that
您的个人兴趣在于这些领域，并且您对某些领域的想法感兴趣

17
00:00:59,970 --> 00:01:01,170
involve disruption.
涉及破坏。

18
00:01:01,490 --> 00:01:04,530
You are less interested in ideas that are purely automation.
您对纯粹自动化的想法不太感兴趣。

19
00:01:04,730 --> 00:01:07,410
You are optimistic, adventurous, and have risk appetite.
你乐观、有冒险精神、有风险偏好。

20
00:01:07,450 --> 00:01:08,290
You're imaginative.
你很有想象力。

21
00:01:08,330 --> 00:01:09,690
Sometimes too much so.
有时太过分了。

22
00:01:09,930 --> 00:01:10,850
Your weaknesses.
你的弱点。

23
00:01:10,970 --> 00:01:12,970
You're not patient, can be impulsive.
你没有耐心，可能很冲动。

24
00:01:13,250 --> 00:01:16,570
You should respond with your business ideas and engaging in a clear way.
您应该以清晰的方式回应您的商业想法并参与其中。

25
00:01:16,970 --> 00:01:19,530
And you can see at the top here there's a comment.
您可以在顶部看到一条评论。

26
00:01:19,610 --> 00:01:24,490
Change the system message to reflect the unique characteristics of this agent.
更改系统消息以反映该代理的独特特征。

27
00:01:25,090 --> 00:01:31,530
And then here, this constant chances that I bounce idea off another is 0.5.
然后在这里，我从另一个人那里得到想法的恒定机会是 0.5。

28
00:01:32,250 --> 00:01:35,570
And here it says you can also change the code to make the behavior different.
这里它说你还可以更改代码以使行为不同。

29
00:01:35,570 --> 00:01:38,250
But be careful to keep the method signatures the same.
但要小心保持方法签名相同。

30
00:01:38,930 --> 00:01:41,170
Okay, so far so good.
好的，到目前为止一切顺利。

31
00:01:41,170 --> 00:01:43,450
And this agent that is going to be cloned.
还有这个即将被克隆的特工。

32
00:01:43,490 --> 00:01:48,970
It has an init method which just simply sets GPT for a mini with a temperature.
它有一个 init 方法，它只是简单地为 mini 设置 GPT 和温度。

33
00:01:48,970 --> 00:01:51,570
Make it a bit a bit random 0.7.
让它有点随机0.7。

34
00:01:52,090 --> 00:01:57,130
And of course it creates a delegate which is an assistant using that model client.
当然，它会创建一个委托，它是使用该模型客户端的助手。

35
00:01:57,130 --> 00:01:59,430
And with this system message.
还有这个系统消息。

36
00:01:59,990 --> 00:02:00,670
Okay.
好的。

37
00:02:01,190 --> 00:02:03,030
And here we have our handle.
在这里我们有我们的句柄。

38
00:02:03,070 --> 00:02:03,990
My message.
我的留言。

39
00:02:04,310 --> 00:02:05,950
Uh, and it's a message handler.
呃，它是一个消息处理程序。

40
00:02:06,270 --> 00:02:14,350
And, uh, it's, um, got, um, uh, maybe it would be clearer if I just call this handle message
而且，呃，它是，嗯，得到了，嗯，呃，如果我直接调用这个句柄消息，也许会更清楚

41
00:02:14,350 --> 00:02:15,630
rather than handle my message type.
而不是处理我的消息类型。

42
00:02:15,670 --> 00:02:17,310
Fewer tokens is always good.
更少的代币总是好的。

43
00:02:17,910 --> 00:02:21,990
Uh, so, um, it takes, uh, of course, the message.
呃，所以，嗯，它需要，呃，当然，消息。

44
00:02:22,030 --> 00:02:27,390
And now this message is using our messages object, the thing that we always create.
现在这个消息正在使用我们的消息对象，这是我们总是创建的东西。

45
00:02:27,510 --> 00:02:32,030
And I have separated that out into its own package, because I want to put as little code in here as
我已将其分离到自己的包中，因为我想在此处放置尽可能少的代码

46
00:02:32,030 --> 00:02:33,990
possible to avoid mistakes.
可能避免错误。

47
00:02:34,150 --> 00:02:36,270
So I've got our message object in here.
所以我在这里得到了我们的消息对象。

48
00:02:36,270 --> 00:02:37,550
We'll look at that in a minute.
我们稍后会讨论这个问题。

49
00:02:38,030 --> 00:02:43,470
And it so it takes a messages message and it returns a messages dot message.
它接受一条 messages 消息并返回一条 messages 点消息。

50
00:02:43,950 --> 00:02:47,310
It prints that this message with this type.
它以这种类型打印此消息。

51
00:02:47,550 --> 00:02:49,910
Remember the type is like the agent's name.
请记住，类型就像代理的名字。

52
00:02:50,070 --> 00:02:51,750
It's going to say received a message.
会说收到消息了。

53
00:02:51,750 --> 00:02:54,390
So we will see as agents receive messages.
因此，我们将看到代理收到消息。

54
00:02:54,830 --> 00:02:56,710
It then makes a.
然后它会产生一个。

55
00:02:57,840 --> 00:03:07,680
text message, um, and, uh, it, uh, then it takes, takes this, this message that it was sent
短信，嗯，然后，呃，它，呃，然后它需要，需要这个，这条发送的消息

56
00:03:08,160 --> 00:03:13,520
and it, uh, sends that to the, its underlying lm.
它，呃，将其发送到其底层的 lm。

57
00:03:13,520 --> 00:03:15,920
So, so it sends on the message that it got.
所以，它发送它收到的消息。

58
00:03:16,200 --> 00:03:20,160
And that will of course, also have the system prompt as part of it because that's set right here.
当然，系统提示符也将作为其中的一部分，因为它就在这里设置。

59
00:03:20,680 --> 00:03:24,960
Uh, and it then says it waits until it gets back.
呃，然后它说等待它回来。

60
00:03:25,000 --> 00:03:31,280
The response it gets, it takes from the, the the response it makes that its business idea because
它得到的反应，它从它做出的反应中获取它的商业理念，因为

61
00:03:31,280 --> 00:03:33,120
it's asked to come up with a business idea.
它被要求提出一个商业想法。

62
00:03:33,120 --> 00:03:36,920
So what comes back from the delegate will be a business idea.
因此，从代表返回的将是一个商业想法。

63
00:03:37,280 --> 00:03:43,720
And now it picks a random number and sees it basically figures out if in this case, this random, not
现在它选择一个随机数，然后它基本上可以判断出在这种情况下，这个随机数，而不是

64
00:03:43,720 --> 00:03:46,200
random gives you a number between 0 and 1.
random 给你一个 0 到 1 之间的数字。

65
00:03:46,200 --> 00:03:51,840
And so if it's a 50% chance, if it's if it's a, there's a 50% chance it'll be less than 0.5.
因此，如果有 50% 的机会，如果是 a，则有 50% 的机会会小于 0.5。

66
00:03:52,120 --> 00:04:00,010
So uh, that this, this logic works If there's in a 50% chance it will use a little utility function,
所以呃，这个逻辑是有效的如果有 50% 的机会它会使用一点实用函数，

67
00:04:00,010 --> 00:04:05,890
find recipient that's going to find some other recipient, and then it will say, here is my business
找到收件人，它将找到其他收件人，然后它会说，这是我的事

68
00:04:05,890 --> 00:04:06,530
idea.
主意。

69
00:04:06,530 --> 00:04:10,690
This might not be your specialty, but please refine it and make this business idea better.
这可能不是你的专长，但请改进它，使这个商业理念变得更好。

70
00:04:10,890 --> 00:04:15,370
And it sends this business idea as a message to the recipient.
它将这个商业想法作为消息发送给收件人。

71
00:04:15,570 --> 00:04:19,130
So some randomly picked recipient, how's it going to pick a random recipient?
那么一些随机挑选的收件人，如何挑选随机收件人呢？

72
00:04:19,130 --> 00:04:26,690
We will see a random recipient is going to get the request to refine this business idea that this agent
我们将看到随机接收者将收到改进该代理的业务理念的请求

73
00:04:26,690 --> 00:04:27,730
just came up with.
刚刚想出来的。

74
00:04:28,010 --> 00:04:32,410
And then and only if the probability is is is within this.
然后且仅当概率在该范围内时。

75
00:04:32,770 --> 00:04:37,170
And if so, then it will take the refined business idea.
如果是这样，那么就需要完善的商业理念。

76
00:04:37,170 --> 00:04:42,930
It will do self dot send message, which means it uses the runtime that it's associated with to send
它将执行自我点发送消息，这意味着它使用与其关联的运行时来发送

77
00:04:42,930 --> 00:04:45,050
a message to the recipient.
给收件人的消息。

78
00:04:45,050 --> 00:04:49,410
And it gets back the idea and that is what it then returns.
它返回了这个想法，这就是它返回的内容。

79
00:04:49,410 --> 00:04:56,350
So it either returns its own idea or there's some probability that it will return a refined version
所以它要么返回自己的想法，要么有可能返回一个改进的版本

80
00:04:56,350 --> 00:04:59,350
of its own idea refined by another agent.
由另一个代理人改进的自己的想法。

81
00:05:00,190 --> 00:05:02,750
Okay, a lot to talk through.
好吧，有很多话要讲。

82
00:05:02,750 --> 00:05:03,590
I hope that made sense.
我希望这是有道理的。

83
00:05:03,590 --> 00:05:08,230
This is the template, the clone that's going to be used to create more agents.
这是模板，将用于创建更多代理的克隆。

84
00:05:08,270 --> 00:05:09,110
Let's see how.
让我们看看如何。

85
00:05:09,150 --> 00:05:10,070
And I'm going to speed up.
我要加快速度。

86
00:05:10,070 --> 00:05:13,030
But but hang on in there because it's going to be great when you see this running.
但是请坚持下去，因为当你看到这个运行时，它会很棒。

87
00:05:13,030 --> 00:05:13,990
So wait for it.
所以等等吧。

88
00:05:14,070 --> 00:05:15,910
Don't don't don't lose me.
别别别失去我。

89
00:05:16,270 --> 00:05:18,590
Uh, I'll just quickly show you the messages.
呃，我会快速向您展示消息。

90
00:05:18,590 --> 00:05:24,230
This is the messages package, and it has that same data class that we know of.
这是消息包，它具有我们所知的相同数据类。

91
00:05:24,630 --> 00:05:30,070
Uh, and then it has some code to deal this, find recipient, find another agent that will message.
呃，然后它有一些代码来处理这个问题，找到收件人，找到另一个将发送消息的代理。

92
00:05:30,070 --> 00:05:31,270
And how does it do that?
它是如何做到的？

93
00:05:31,310 --> 00:05:37,230
Well, it's super hacky, but basically, as the clones start appearing, the clones are going to be
嗯，这是超级黑客，但基本上，随着克隆开始出现，克隆将会

94
00:05:37,230 --> 00:05:40,590
named agent one, agent two, agent three, agent four.
分别命名为特工一、特工二、特工三、特工四。

95
00:05:40,990 --> 00:05:45,950
And so it basically just looks in this directory to see what other agents have already existed.
所以它基本上只是在这个目录中查找以查看已经存在的其他代理。

96
00:05:45,950 --> 00:05:51,590
And if it finds one, it returns a randomly selected other agent, and there's some chance that we'll
如果它找到一个，它会返回一个随机选择的其他代理，并且我们有机会

97
00:05:51,590 --> 00:05:52,630
return the agent itself.
返回代理本身。

98
00:05:52,720 --> 00:05:57,320
The agent might talk to itself that maybe I should should, uh, solve I should should fix that and
代理可能会自言自语，也许我应该，呃，解决这个问题，我应该解决这个问题，然后

99
00:05:57,320 --> 00:05:58,320
not let it talk to itself.
不要让它自言自语。

100
00:05:58,320 --> 00:06:00,200
But I thought, whatever, it doesn't matter.
但我想，无论如何，没关系。

101
00:06:00,200 --> 00:06:00,440
So.
所以。

102
00:06:00,440 --> 00:06:02,640
So right now it might talk to itself as well.
所以现在它也可能会自言自语。

103
00:06:03,600 --> 00:06:04,120
Okay.
好的。

104
00:06:04,280 --> 00:06:07,840
So then the, uh, where life gets interesting is creator.
那么，呃，生活变得有趣的地方就是创造者。

105
00:06:08,400 --> 00:06:12,320
Creator is the agent that creates and spawns agents.
创建者是创建和产生代理的代理。

106
00:06:12,600 --> 00:06:14,600
And I'll let you look through this.
我会让你看看这个。

107
00:06:14,600 --> 00:06:17,680
But basically the system message says just what you would think.
但基本上系统消息所表达的正是您的想法。

108
00:06:17,840 --> 00:06:20,720
You're an agent that can create other agents.
你是一个可以创建其他代理的代理。

109
00:06:20,840 --> 00:06:28,080
You receive Python code and you create the user's Autogen core and Autogen agent chat.
您收到 Python 代码并创建用户的 Autogen 核心和 Autogen 代理聊天。

110
00:06:28,280 --> 00:06:32,640
You should use this template to create a new agent with a unique system message.
您应该使用此模板创建具有唯一系统消息的新代理。

111
00:06:32,920 --> 00:06:35,800
You can choose to keep the overall goal the same or change it.
您可以选择保持总体目标不变或更改它。

112
00:06:35,800 --> 00:06:39,680
You can choose to take this agent in a completely different direction.
您可以选择将该代理带向完全不同的方向。

113
00:06:39,680 --> 00:06:42,640
This is the part that's both edgy and risky haha.
这是既急躁又危险的部分哈哈。

114
00:06:43,160 --> 00:06:49,000
The only requirement is that the class must be named agent, and it must inherit from from rooted agent
唯一的要求是该类必须命名为agent，并且必须继承自rootagent

115
00:06:49,000 --> 00:06:50,800
and and it must have an init method.
并且它必须有一个 init 方法。

116
00:06:51,380 --> 00:06:53,060
Respond only with Python code.
仅使用 Python 代码进行响应。

117
00:06:53,260 --> 00:06:54,900
So, look, this is this is cool.
所以，看，这很酷。

118
00:06:54,900 --> 00:06:58,020
There's no doubt we're building something that we're saying.
毫无疑问，我们正在构建我们所说的东西。

119
00:06:58,020 --> 00:07:00,460
You have a free reign to do what you want.
你可以自由地做你想做的事。

120
00:07:00,500 --> 00:07:03,820
And I've only tried this with GPT four and mini, which is a bit safe with this stuff.
我只尝试过使用 GPT 4 和 mini，这对这个东西来说有点安全。

121
00:07:03,820 --> 00:07:09,620
It hasn't actually gone off the rails in an interesting way, and I am tempted to try it with Deep Sea.
它实际上并没有以一种有趣的方式偏离轨道，我很想在《深海》中尝试一下。

122
00:07:09,660 --> 00:07:14,980
I'm slightly nervous with and with more creative agents, and maybe with Claude, because Claude is
我对更多有创意的经纪人感到有点紧张，也许还有克劳德，因为克劳德是

123
00:07:15,020 --> 00:07:22,180
known for being more creative and see whether they look to include different logic in there to give
以更具创造力而闻名，看看他们是否希望在其中包含不同的逻辑来赋予

124
00:07:22,180 --> 00:07:24,540
this agent more smarts.
这个代理比较聪明。

125
00:07:24,860 --> 00:07:29,780
But so far, whilst GPT four mini has definitely taken it in different directions, it hasn't done anything
但到目前为止，虽然 GPT 4 mini 确实朝着不同的方向发展，但它还没有做任何事情

126
00:07:29,820 --> 00:07:30,460
out there.
在那里。

127
00:07:30,780 --> 00:07:34,780
Okay, so the user prompt says much, much the same thing.
好的，用户提示说了很多很多同样的事情。

128
00:07:34,940 --> 00:07:37,340
And then, uh, you can you can trace through it.
然后，呃，你可以追踪它。

129
00:07:37,340 --> 00:07:39,940
But this is pretty simple and it prints what it's doing.
但这非常简单，它会打印它正在做什么。

130
00:07:39,940 --> 00:07:49,380
But it basically opens this file, name it, it then uh, calls uh the delegate to, to take this action
但它基本上打开这个文件，命名它，然后呃，调用呃代表，采取这个行动

131
00:07:49,380 --> 00:07:58,550
to basically given this python file in agent py, make a new version of it, and then and then it saves
基本上在代理 py 中给出这个 python 文件，制作它的新版本，然后保存

132
00:07:58,550 --> 00:08:02,790
that as like agent one, agent two, agent three, agent four.
就像一号特工、二号特工、三号特工、四号特工一样。

133
00:08:02,790 --> 00:08:09,270
So it was save it as each of the different, uh, agent numbers, it's, it's called with an agent number.
所以它被保存为每个不同的，呃，代理号码，它是用代理号码来调用的。

134
00:08:09,270 --> 00:08:12,110
And it will, uh, it will save it with that agent number.
它会，呃，它会用那个代理号码来保存它。

135
00:08:12,550 --> 00:08:18,150
And then it does something that is super, uh, like, uh, out there.
然后它做了一些超级的事情，呃，就像，呃，在那里。

136
00:08:18,630 --> 00:08:27,550
I use this Python feature, um, import lib to import the Python module that it just wrote.
我使用这个Python功能，嗯，导入lib来导入它刚刚编写的Python模块。

137
00:08:27,550 --> 00:08:33,430
I import it here so that this creator agent imports that module, that it just wrote it effectively.
我在这里导入它，以便该创建者代理导入该模块，它只是有效地编写了它。

138
00:08:33,430 --> 00:08:42,470
If it just wrote a file called uh agent 5.py and the word agent five will have actually have come in
如果它只是写了一个名为 uh agent 5.py 的文件，那么“agent 5”这个词实际上已经出现了

139
00:08:42,590 --> 00:08:43,870
in this message right here.
在此消息中。

140
00:08:43,910 --> 00:08:46,630
So agent five is what will have been sent to the creator.
所以第五号特工将被发送给创作者。

141
00:08:46,630 --> 00:08:49,120
And that's how it knows that that's the agent it's making.
这就是它如何知道这就是它正在制造的代理。

142
00:08:49,280 --> 00:08:56,120
So in that case, what this will do is it will effectively be the same as saying import agent five pi.
因此，在这种情况下，这实际上与导入代理 5 个 pi 相同。

143
00:08:56,320 --> 00:08:58,360
That's what that does dynamically.
这就是动态执行的操作。

144
00:08:58,360 --> 00:08:59,520
Programmatically.
以编程方式。

145
00:08:59,560 --> 00:09:01,280
It imports it on the fly.
它会即时导入它。

146
00:09:01,760 --> 00:09:08,840
And then I take that module that we've just imported on the on the fly and I register it, I call agent
然后我获取我们刚刚动态导入的模块并注册它，然后致电代理

147
00:09:08,840 --> 00:09:18,120
dot register with my runtime with the agent's name and using the lambda that will spawn a new instance,
点使用代理名称并使用将生成新实例的 lambda 向我的运行时注册，

148
00:09:18,160 --> 00:09:22,880
a factory method that will create a new instance of that agent on demand.
一个工厂方法，将根据需要创建该代理的新实例。

149
00:09:23,400 --> 00:09:29,760
And then it says it prints agent whatever is live and and it means not just the kind of live that we
然后它说它会打印代理任何现场直播，这意味着不仅仅是我们所看到的那种现场直播

150
00:09:29,760 --> 00:09:31,080
say when we deploy software.
当我们部署软件时说。

151
00:09:31,440 --> 00:09:33,680
It means that the agent is running.
这意味着代理正在运行。

152
00:09:34,000 --> 00:09:39,160
Um, and it will then send a message to that agent saying, give me an idea.
嗯，然后它会向该代理发送一条消息说，给我一个想法。

153
00:09:39,400 --> 00:09:42,520
And that will then trigger that agent will then get that message.
然后这将触发该代理收到该消息。

154
00:09:42,520 --> 00:09:48,780
It will process it, it will work on an idea and potentially if the probability meets that criteria,
它会处理它，它会研究一个想法，如果概率满足该标准，

155
00:09:48,780 --> 00:09:54,220
it will then send on its idea to another agent that it will find in the directory, and ask that other
然后，它会将其想法发送给在目录中找到的另一个代理，并询问其他代理

156
00:09:54,220 --> 00:09:56,900
agents to add feedback to it.
代理向其添加反馈。

157
00:09:57,060 --> 00:10:00,780
And that's that's how it would all fit together, if you can believe it.
如果你相信的话，这就是一切的结合方式。

158
00:10:00,780 --> 00:10:02,380
That's what this does.
这就是这个的作用。

159
00:10:02,380 --> 00:10:03,660
So it's imaginative.
所以这是富有想象力的。

160
00:10:03,700 --> 00:10:05,180
It's a kind of crazy.
这是一种疯狂。

161
00:10:05,460 --> 00:10:11,220
And uh, as I say, the main the learning point here is that it is educational to step through it and
呃，正如我所说，这里的主要学习点是逐步完成它是有教育意义的，并且

162
00:10:11,220 --> 00:10:11,900
see what's happening.
看看发生了什么。

163
00:10:11,900 --> 00:10:14,540
And we've got something important about async Python coming up.
我们即将迎来一些关于异步 Python 的重要内容。

164
00:10:14,700 --> 00:10:20,780
Um, but this is definitely, uh, something to have you thinking about what it means to have agents
嗯，但这绝对是，呃，让你思考拥有代理意味着什么

165
00:10:20,780 --> 00:10:26,700
interacting, messaging each other, and how this really demonstrates Autogen cause power as a pure
互动、互相传递信息，以及这如何真正证明 Autogen 事业力量是一种纯粹的力量

166
00:10:26,740 --> 00:10:28,900
agent messaging platform.
代理消息平台。

167
00:10:28,900 --> 00:10:37,060
We're able to to single out an agent, we are able just to get a recipient's agent ID and send it a
我们能够挑选出一个代理，我们只需获取收件人的代理 ID 并向其发送

168
00:10:37,060 --> 00:10:37,740
message.
信息。

169
00:10:37,860 --> 00:10:44,300
So it allows for this kind of inter-process communication, uh, without without having to worry about
所以它允许这种进程间通信，呃，不用担心

170
00:10:44,300 --> 00:10:46,660
the details of how that's actually strung together.
它实际上是如何串联在一起的细节。
