Okay. 好的。
Well, it remains for us to write the the main the run function in here. 好吧，我们仍然需要在这里编写主要的 run 函数。
I deleted the default template one that's there usually, and I'm replacing it here with a simple run. 我删除了通常存在的默认模板，并在此处通过简单的运行替换了它。
The crew we're going to pass in the sector as technology. 我们将在该领域传递技术人员。
We don't actually need a current date in there at all. 实际上我们根本不需要当前日期。
That will do fine. 这样就可以了。
We don't use current dates and the result is Stockpicker kickoff passing in the inputs. 我们不使用当前日期，结果是 Stockpicker 开始传递输入。
And then we will print results at the end. 然后我们将在最后打印结果。
So there we go. 我们就这样吧。
This is our starting point. 这是我们的出发点。
I think we should give this a whirl okay here we go. 我想我们应该尝试一下，好吧，我们开始吧。
So we're going to bring up our terminal as usual with control and the tick. 因此，我们将像往常一样通过 Control 和勾号打开终端。
And then we're going to go into our third folder. 然后我们将进入第三个文件夹。
And we are going to go into the stock picker. 我们将进入选股器。
And we're going to type crew. 我们要输入船员。
I run to kick it off. 我跑去把它踢开。
And now here's the thing. 现在事情是这样的。
It's going to be interesting to watch this. 观看这个将会很有趣。
The crew process is, by its very nature, a little bit less predictable than we might want. 就其本质而言，船员流程比我们想象的要难预测一些。
It is autonomous and it goes off and does its own thing, and that can involve all sorts of searching 它是自主的，它会开始做自己的事情，这可能涉及各种搜索
around and using multiple agents. 周围并使用多个代理。
It can sometimes go back to do some news and analysts and then using the researcher, and it can take 有时可以回去做一些新闻和分析师，然后使用研究人员，这可能需要
quite a while as it goes through its processing. 处理过程需要相当长的时间。
And my machine is chugging away like crazy, as will yours. 我的机器正在疯狂地运转，你的也是如此。
And it's both. 两者都是。
The great thing, and perhaps the downside of autonomous agentic AI, that we have a bit less control 自主代理人工智能的伟大之处，也许也是它的缺点，是我们的控制力有点少
over how this process is followed, and so I will let it do its thing. 关于如何遵循这个过程，所以我会让它做它的事情。
I will break and come back when it completes its recommendation. 当它完成推荐时我会休息并回来。
And here we have it. 现在我们有了它。
It actually completed pretty much right as I was pausing there. 当我停在那里时，它实际上已经完成了。
So it was quite quick. 所以速度很快。
It made a decision to recommend anthropic and it says, which was interesting because it was OpenAI 它决定推荐人类，它说，这很有趣，因为它是 OpenAI
that was doing this, this processing, which is and it turns down a couple of a security company, 就是这样做，这个处理，它拒绝了几家安全公司，
Peregrine and a crypto company, circle, and we can look in our outputs folder where we'll see that Peregrine 和一家加密货币公司，圈起来，我们可以在输出文件夹中看到
this decision is shown. 显示此决定。
And we'll also find a research list here. 我们还将在这里找到一份研究列表。
And also the trending companies list. 还有热门公司名单。
And these of course are in the JSON format that conforms to our schema. 当然，这些都是符合我们模式的 JSON 格式。
So we are seeing here the proper formatted results because we required that by using structured outputs. 因此，我们在这里看到了正确格式化的结果，因为我们需要使用结构化输出。
And so despite my misgivings about the autonomous framework it actually performed really well. 因此，尽管我对自主框架心存疑虑，但它实际上表现得非常好。
It did just go through the process. 它确实只是经历了这个过程。
It should do. 应该可以。
The manager that we'd set up had some autonomy in how it assigned out the tasks, but it did so well 我们设立的经理在如何分配任务方面拥有一定的自主权，但它做得很好
and as a result, we did indeed achieve a stock pick recommendation, which is not intended for real 结果，我们确实实现了选股推荐，但并不是真正的目的
trading decisions, which is in this case for anthropic. 交易决策，在这种情况下是人为的。
All right, it's time to make our solution have a few more bells and whistles. 好吧，是时候让我们的解决方案增加一些附加功能了。
First of all, we're going to add a tool. 首先，我们要添加一个工具。
You'll see if you look in the source folder in the stock picker folder that's generated for you that 您会看到，如果您查看为您生成的股票选择器文件夹中的源文件夹，
there's already a folder called tools that the people at Cru have kindly made for us. Cru 的工作人员已经为我们制作了一个名为“tools”的文件夹。
And there's one in there called Custom Tool that has a kind of typical layout for these sorts of, of 那里有一个叫做“自定义工具”的工具，它具有一种针对此类的典型布局，
tools. 工具。
And we are going to change the name of custom tool, and we're going to make it into push tool. 我们将更改自定义工具的名称，并将其变成推送工具。
So let's do rename and make this a push. 因此，让我们重命名并推动它。
Hang on click there. 等一下，点击那里。
Try that again. 再试一次。
Rename to push underscore tool dot pi. 重命名为推送下划线工具点 pi。
So the way that it works if we look in here is that you'll see that there is a when you set up a custom 因此，如果我们查看这里，您会发现当您设置自定义时，它的工作方式是
tool you have to first describe using a pedantic object, the schema of what will be passed in to your 您必须首先使用迂腐的对象来描述工具，即将传递给您的工具的模式
custom tool. 自定义工具。
And then you end up writing an underscore run method, which is going to take that schema as its parameters. 然后您最终编写了一个下划线运行方法，该方法将采用该模式作为其参数。
So to make that feel more real, I'm going to, uh, actually implement that. 因此，为了让这种感觉更加真实，我将，呃，实际实施它。
And let's just start with a couple of, uh, imports here and now. 现在让我们从一些，呃，导入开始。
So we're going to have a push notification input which will be a subclass of base model. 因此，我们将有一个推送通知输入，它将成为基本模型的子类。
And we're going to change the description that this is uh what is the meaning of this input. 我们将更改描述，即这个输入的含义是什么。
It's going to be a message to be sent. 这将是一条要发送的消息。
Sorry to be sent to the user okay. 抱歉发送给用户好吗。
And now instead of an argument we're going to say message. 现在我们不再说争论，而是说消息。
That's what we're going to call it. 这就是我们所说的。
And the description will be the message to be sent to the user. 描述将是要发送给用户的消息。
That seems pretty clear. 这看起来很清楚。
Okay. 好的。
So that is then defining the schema for our tool. 这就是为我们的工具定义架构。
It's in other words this here is actually going to be message to to correspond with that. 换句话说，这里实际上是与此相对应的消息。
That's what we will run when the tool is invoked. 这就是我们在调用该工具时将运行的内容。
So or invoked rather than invoked. 所以还是调用而不是调用。
So uh we will um give it a name. 所以呃我们会给它一个名字。
So first of all we should change the class to be push notification tool. 所以首先我们应该将类更改为推送通知工具。
There we go. 我们开始吧。
Thank you. 谢谢。
Cursor. 光标。
The name let's say is going to be send a push notification and the description is going to be this tool 假设名称将发送推送通知，描述将是此工具
is used to send a push notification to the user. 用于向用户发送推送通知。
That seems pretty decent to me. 这对我来说似乎相当不错。
Okay. 好的。
And the schema for the args. 以及参数的架构。
This is where we say what kind of arguments do we need you to pass in. 这就是我们需要你传入什么样的参数的地方。
Well, that's exactly the schema that we've just defined right here. 嗯，这正是我们刚刚在这里定义的模式。
So it is something which just has a single argument message. 所以它只有一个参数消息。
And there you go. 就这样吧。
You see we've written a run method with a single input message. 您会看到我们编写了一个带有单个输入消息的运行方法。
And that is going to actually send a push notification. 这实际上会发送推送通知。
And how do we send a push notification. 以及我们如何发送推送通知。
We use the fabulous Pushover tool. 我们使用神奇的 Pushover 工具。
And hopefully in your environment you have Pushover user and Pushover token set in your env file from 希望在您的环境中您的 env 文件中设置了 Pushover 用户和 Pushover 令牌
prior week and then I just used I've just pasted in exactly the same code we have from the prior week, 前一周，然后我刚刚粘贴了与前一周完全相同的代码，
and we will push this message to the user and then return that that was okay. 我们会将此消息推送给用户，然后返回表示没问题。
So that is our push notification tool. 这就是我们的推送通知工具。
Now we have to put it to good use. 现在我们必须好好利用它。
Well this should be pretty easy actually. 嗯，这实际上应该很容易。
We're back in the crew.py module and we add in an import to import in the push notification tool. 我们回到crew.py模块，并添加一个导入以导入到推送通知工具中。
Now which of our agents do we want to be able to do this. 现在我们希望我们的哪些代理能够做到这一点。
We want the stock picker agent to be the one that will have this power the stock picker. 我们希望选股代理人成为拥有选股权力的人。
You can see cursor of course already tells us that's exactly what we want. 当然你可以看到光标已经告诉我们这正是我们想要的。
We want the stock picker to be able to call the push notification tool. 我们希望选股器能够调用推送通知工具。
That's as simple as that. 就这么简单。
All right. 好的。
With that, let's go and run this. 有了这个，让我们开始运行它。
We'll do that right away. 我们会立即这样做。
We will bring up this. 我们会提出这一点。
We will clear what we have here. 我们会清理这里的东西。
And we will just call, cry, run and give it a whirl. 我们只会打电话、哭泣、奔跑并尝试一下。
Let's see what happens. 让我们看看会发生什么。
I will let this run and I'll be right back. 我会让这件事继续下去，我很快就会回来。
And here we go. 我们开始吧。
It's completed. 完成了。
It's this time recommending circle, which was one of the runners up last time. 这次推荐的是上次的亚军之一的circle。
And I can assure you, you can see it right here that I did indeed get a push notification about the, 我可以向您保证，您可以在这里看到我确实收到了有关以下内容的推送通知：
the the opportunity, which is great. 机会，这真是太好了。
So it is working. 所以它正在发挥作用。
And that then is the extra piece that we've added into this. 这就是我们添加到其中的额外部分。
So just to recap, we built this agent framework and the three things that are different than the way 回顾一下，我们构建了这个代理框架以及与方式不同的三件事
we've done it before. 我们以前已经做到了。
First of all we've used structured outputs. 首先，我们使用了结构化输出。
So we've required that tasks respond conforming to a JSON schema that we set. 因此，我们要求任务响应符合我们设置的 JSON 模式。
Secondly, instead of using the sequential process, we use the hierarchical process, which means that 其次，我们不使用顺序过程，而是使用分层过程，这意味着
we can either pass in an LLM by model name or by passing in an agent that will take care of assigning 我们可以通过模型名称传递 LLM，也可以传递负责分配的代理
the tasks to the agents. 给代理的任务。
And we did that. 我们做到了。
And we saw, I think, both the good and the bad of doing so. 我认为，我们看到了这样做的好处和坏处。
And then thirdly, we added a custom tool, a tool that we wrote ourselves. 第三，我们添加了一个自定义工具，一个我们自己编写的工具。
And it's a familiar one. 这是一个熟悉的。
It was to send a push notification. 是为了发送推送通知。
And we armed an agent with that ability and it pulled it off successfully. 我们为特工配备了这种能力，并且成功地完成了任务。
And so that then is wraps up this week's project. 本周的项目就到此结束。
And I'll see you for the wrap up. 总结会见。
I think I might have just said that. 我想我刚才可能已经说过了。
That wraps up this week's project. 本周的项目就这样结束了。
Of course, it wraps up this day's project. 当然，今天的项目就到此结束了。
We've got lots more to go. 我们还有很多事情要做。
And in fact, tomorrow and in the next day before we move on to the next project, I do want to add 事实上，明天和后天，在我们继续下一个项目之前，我确实想补充一点
one more bell and whistle to this project too. 这个项目还有一个附加功能。
So we're not completely through with the stock picker either, so stay tuned for that. 因此，我们还没有完全完成股票选择器的工作，所以请继续关注。
But again, to recap, we just did structured outputs, custom tools and hierarchical process. 但再次回顾一下，我们只是做了结构化输出、定制工具和分层流程。
And tomorrow we're going to we are going to add a little bit extra to stock picker but then also work 明天我们将为选股器添加一点额外的内容，然后也可以工作
on the next project, the developer agent. 在下一个项目上，开发商代理。
And I'm really excited about that one. 我对此感到非常兴奋。
Good old crew is coming through strong. 优秀的老船员正在坚强地度过。
See you then. 到时候见。