Our managing agents holds other agents. 我们的管理代理持有其他代理。
It holds the solution architect the back end. 它将解决方案架构师作为后端。
If you build a front end agent, whatever you want to build in, it will hold any agents that implement 如果您构建了一个前端代理，无论您想要在其中构建什么，它都将包含实现
the special functions. 特殊功能。
But the managing agent itself does not implement special functions. 但管理代理本身并不实现特殊功能。
So we are going to write a more simple implementation for managing agent. 因此，我们将编写一个更简单的代理管理实现。
But to do that, we're going to need some crates. 但要做到这一点，我们需要一些板条箱。
So the first thing here is it's I function is convert user input to goal. 这里的第一件事是，它的函数是将用户输入转换为目标。
That means if I request build me a website that flies pink elephants, it will go and convert that into 这意味着如果我请求建立一个会飞粉色大象的网站，它会把它转换成
a goal that it can give to the team and the team. 一个它可以给球队和球队的进球。
For example, right now the solution architect agent will go and do that. 例如，现在解决方案架构师代理将去做这件事。
So to go and actually pass that into an AI task request, we need those two crates there. 因此，要真正将其传递到人工智能任务请求中，我们需要那里的两个板条箱。
And also we're going to need potentially here our message crates as well. 此外，我们还可能需要我们的信息箱。
So let's go and actually write out the implementation here for our managing agent because that is going 所以让我们在这里实际写出我们的管理代理的实现，因为这是
to hold the functions that does all this. 拥有完成所有这些任务的功能。
And so the first implementation here is going to be public async new. 因此，这里的第一个实现将是公共异步新的。
And so that will be a function new and that's going to take in a user. 这将是一项新功能，将吸引用户。
Underscore request like such, and that'll be in the format of a string. 下划线这样的请求，它将是一个字符串的格式。
And that is going to also return result. 这也将返回结果。
And it will return self otherwise, because it's making asynchronous requests, it might return an error. 否则它将返回self，因为它正在进行异步请求，它可能会返回一个错误。
So here we're going to just use box with dynamic and that will be standard error. 所以在这里，我们将使用带有动态的框，这将是标准误差。
Error as follows. 错误如下。
Great. 太棒了。
And so why is this an asynchronous function over here for new? 那么，为什么这里的new是一个异步函数呢？
Well, because when we create a new managing agent, its task is going to be once we create it, to 嗯，因为当我们创建一个新的管理代理时，它的任务是一旦我们创建它，
immediately get started and just go and convert, use the large language model to go and convert the 立即开始，只需进行转换，使用大型语言模型即可将
user request into an instruction for the team, which will be our project description. 将用户要求转化为对团队的说明，这将是我们的项目描述。
But remember it also holds attributes and a fact sheets as well. 但请记住，它也包含属性和情况说明书。
So let's actually go and get all of that built. 所以让我们实际去把所有的东西都建好。
The fact sheet is what holds the project description which we'll need to get from the large language 情况说明书包含我们需要从大型语言中获得的项目描述
model. 模特。
So let's first get our attributes. 因此，让我们首先获得我们的属性。
So we'll say let attributes here and in fact, we can go over to our solution architect here and we 所以我们会说，让属性在这里，事实上，我们可以转到我们的解决方案架构师那里，我们
can see up here we had get attributes. 可以看到在这上面我们有属性。
So let's go where we've done this all before. 所以让我们回到我们以前做过的地方。
We can just copy this because that's going to be, you know, the same sort of code. 我们可以复制这个，因为这将是，你知道，相同类型的代码。
So we can literally just copy this here to save us typing. 所以我们可以直接把它复制到这里，免去打字的麻烦。
And this is going to be our objective, which is going to be manage agents who are building an. 这将是我们的目标，这将是正在建立一个。
Excellent website for the user and we're not really using this objective very much, by the way. 对于用户来说，这是一个很好的网站，顺便说一句，我们并没有真正使用这个目标。
We're just not doing that right now. 我们只是现在不会这么做。
And so that's okay. 所以这没问题。
But it's just there in case you want it and you want to use it as context for any large language model 但它就在那里，以防您需要它，并且想要将其用作任何大型语言模型的上下文
requests. 请求。
I thought it's useful to have it there. 我认为把它放在那里是很有用的。
Position is project manager. 职位是项目经理。
As such. 就其本身而言。
So we'll just call them project manager. 所以我们就叫他们项目经理吧。
They'll be defaulted to Discovery and again, with nothing in memory. 它们将被默认为Discovery，并再次在内存中没有任何内容。
Now, I'm just going to comment this out for the time being, because it's giving us errors here when 现在，我暂时把它注释掉，因为它给我们带来了错误，当
I'm just trying to write the code and there we go. 我只是在试着写代码，然后就开始了。
So now what we need to do is actually go and call the AI function to convert user input to goal. 因此，现在我们需要做的实际上是调用AI函数，将用户输入转换为目标。
So how do we do that? 那么我们如何做到这一点呢？
Well, we've done it before, so we can just go and do that here. 嗯，我们以前做过，所以我们可以在这里做。
We can copy this AI response from the solution Architect Agent where we went to call Project Scope, 我们可以从我们调用项目范围的解决方案架构师代理复制此AI响应，
for example, and we can just go and do the same here so we can say let AI response. 例如，我们可以在这里做同样的事情，所以我们可以说让AI响应。
And now it's not project scope, because what we're really going to be getting out here is now just 现在它不是项目范围，因为我们真正要做的是
a string and it's not AI task request decoded. 一个字符串，它不是解码的AI任务请求。
It's just going to be a simple task request so it can get rid of this generic we're passing in. 这只是一个简单的任务请求，这样它就可以去掉我们传递的这个泛型。
And so because we're just getting a string returned from the large language model, we're going to need 因此，因为我们只是从大型语言模型返回一个字符串，所以我们需要
some message context to pass in. 要传入的一些消息上下文。
Well, that's actually just going to be the user request. 实际上，这只是用户的要求。
So the user request is going to get passed in over there. 因此，用户请求将在那里传递。
The position here is just going to be the project manager position. 这里的职位只是项目经理的职位。
So here what I could actually do, for example, is I can just say let position and that will be equal 所以我实际上可以做的是，例如，我可以说让位置，这将是相等的
to project manager dot two string like such over there and that's a string. 项目经理在那里点两根这样的线，这就是一根线。
So that will now be our position. 因此，这将是我们现在的立场。
And there we can just put in agent position here as well. 在那里，我们也可以把特工的位置放在这里。
So that's fine. 所以这很好。
That's going to be our position. 这将是我们的立场。
And actually this position here, because we're passing the ownership over there, what I could do is 实际上，这个位置，因为我们将所有权转移到那里，我能做的是
just make position equal to a reference to position like follows. 只需使位置等于对位置的引用，如下所示。
But that's going to now bring up an error because it's saying, hey, you know, consider removing the 但这现在会带来一个错误，因为它说，嘿，你知道，考虑删除
burrow because this is actually just meant to be a string. 洞穴，因为这实际上只是一根绳子。
So the way I'm going to deal with it here is just say dot clone. 所以我在这里要处理的方法就是点克隆。
Like such. 就像这样。
So position dot clone. 因此，定位点克隆。
That's fine. 那很好。
And then in here, we're going to pass in our position. 然后在这里，我们将通过我们的位置。
So now it's expecting a string reference over here. 所以现在它在这里需要一个字符串引用。
So what I'm going to do is just make this a reference here to position and that solves that problem 所以我要做的就是在这里引用这个位置，这样就解决了这个问题
and then get function string isn't print project scope anymore, it's convert user input to goal and 然后Get函数字符串不再是打印项目范围，它将用户输入转换为Goal和
convert user input to goal. 将用户输入转换为目标。
And remember, this is just a string. 记住，这只是一根线。
It's not decoding to any structs or vectors of any types et, etcetera. 它不会解码成任何类型的结构或向量，等等。
It's just a string. 这只是一根线。
And so if we look at this I task request that returns a string. 所以如果我们看一下这个返回字符串的I任务请求。
So that's absolutely fine just to use it as it is over here. 所以，就像在这里一样使用它是绝对没有问题的。
And so that's going to actually be our project description. 这实际上将是我们的项目描述。
So instead of I response, we can call that project description as such brilliant. 因此，我们可以称这个项目描述为如此出色，而不是我的回应。
So that'll go and get that from the large language model. 所以这是从大型语言模型中得到的。
And then what we need to actually do here as well is just initialize our agent. 然后，我们在这里实际需要做的就是初始化我们的代理。
So here what we're going to do is say, let agents, which here will be a vector to what, a box of 所以我们要做的是，让代理人，这将是什么的一个载体，一箱
dynamic. 活力四射。
And that will be special functions, including the special functions trait over here, and that will 这将是特殊的功能，包括这里的特殊功能特性，这将是
be equal to an empty vector. 等于一个空矢量。
As follows. 具体如下。
So that will initialize our agents. 这将会初始化我们的特工。
And now that we have all of that, we can initialize our factsheet so we can say let factsheet. 现在我们有了所有这些，我们可以初始化我们的factSheet，这样我们就可以说let factSheet。
And that's going to be of type factsheet equal to factsheet like such. 这将是一种类型的FactSheet，就像这样。
And that will include the project description, which we've already now got from our large language 这将包括项目描述，我们现在已经从我们的大型语言中获得了这些描述
model up here. 模特在这上面。
It's going to include project scope, so that will be none. 它将包括项目范围，因此不会有任何项目。
It's cetera. 这是其他的。
And in fact, again, we can go down here to our test code with the solution architect. 事实上，同样，我们可以在这里向解决方案架构师介绍我们的测试代码。
Just copy that because it's the same code. 只需复制它，因为它是相同的代码。
We don't need to just rewrite it. 我们不需要仅仅重写它。
We'll just create it over there as such. 我们就这样在那里创建它。
Brilliant. 非常出色。
Now that we have our factsheet, we can go and return that as self. 现在我们有了我们的情况说明书，我们可以去把它还给自己了。
So return self as follows. 因此，如下所示返回SELF。
And in fact, we don't need to write that here because it's fairly obvious what we're going to be doing. 事实上，我们不需要在这里写，因为我们要做的事情很明显。
We'll write okay self and that is going to here be our attributes, which we've now got our factsheet, 我们会写好自己，这将是我们的属性，我们现在已经得到了我们的情况说明书，
which we've now got and our agents which we've now got as well. 我们现在有了我们的特工，我们现在也有了。
So that's what we're going to return and we need to tell our function to expect that now. 所以这就是我们要返回的内容，我们需要告诉我们的函数，现在要期待这一点。
So let's go and take that comment away, put that back in and there we go. 所以让我们去掉这个评论，把它放回去，然后我们就可以开始了。
That is going to create a nice new agent for us. 这将为我们创造一个很好的新经纪人。
And so now what we need to do is actually create some private functions to create agents or add an agent 因此，现在我们需要做的实际上是创建一些私有函数来创建代理或添加代理
and also to execute the project overall. 并从整体上执行该项目。
So to execute the project overall, we're going to want it to create agents. 因此，为了从整体上执行该项目，我们将希望它创建代理。
And then for each of those agents, make the agents do what they need to do. 然后，对于每个代理，让代理执行他们需要做的事情。
So we'll do that in the next session. 所以我们将在下一节课上做这件事。