1
00:00:00,080 --> 00:00:02,960
Wait, did you spot that intentional little hiccup there?
等等，你发现那里故意打嗝了吗？

2
00:00:03,000 --> 00:00:05,080
I was it was just after I stopped recording.
我是在我停止录音之后。

3
00:00:05,080 --> 00:00:08,320
I was thinking, and I'm like, hang on a second, hang on a second.
我在想，我想，等一下，等一下。

4
00:00:08,360 --> 00:00:14,680
We saw that that, uh, in the traces that it bought Tesla stock and it didn't report that it bought
我们看到，呃，在它购买特斯拉股票的痕迹中，但它没有报告它购买了

5
00:00:14,720 --> 00:00:15,360
Tesla stock.
特斯拉股票。

6
00:00:15,360 --> 00:00:17,880
And we didn't see that in our holdings at the end.
我们最终没有在我们的持股中看到这一点。

7
00:00:18,120 --> 00:00:20,040
So let's go back and see what happened there.
那么让我们回去看看那里发生了什么。

8
00:00:20,080 --> 00:00:26,280
So I went back into the trace and I took a look and I scrolled down load more.
所以我回到跟踪中看了一下，然后向下滚动加载更多内容。

9
00:00:26,880 --> 00:00:33,560
Uh, and uh uh, sure enough, if we get down to the bottom here, you will see that there were indeed
呃呃呃呃,果然,如果我们深入到这里的话,你会发现确实有

10
00:00:33,560 --> 00:00:35,360
these two buying shares.
这两次购买股票。

11
00:00:35,400 --> 00:00:38,120
First of all, it bought 50 Disney shares.
首先，它购买了50股迪士尼股票。

12
00:00:38,160 --> 00:00:41,760
And then as I remember it, bought 30 Tesla shares.
然后我记得，我买了 30 股特斯拉股票。

13
00:00:41,760 --> 00:00:42,760
What's going on?
这是怎么回事？

14
00:00:42,800 --> 00:00:49,080
Well, then I scrolled down and saw that it got an error back from this error executing tool.
好吧，然后我向下滚动，发现这个错误执行工具返回了一个错误。

15
00:00:49,080 --> 00:00:51,440
Insufficient funds to buy shares.
资金不足，无法购买股票。

16
00:00:51,480 --> 00:00:56,560
And what's kind of brilliant about this is that that error message is an error message that was written
这个错误消息的精彩之处在于该错误消息是被写入的错误消息

17
00:00:56,560 --> 00:00:59,200
by our crew agents in week three.
由我们的机组人员在第三周进行。

18
00:00:59,240 --> 00:01:04,010
We asked it one of our business requirements is that it should put something in there that prevents
我们要求它的业务要求之一是它应该放一些东西来防止

19
00:01:04,010 --> 00:01:06,810
the person from buying more shares than they can afford.
该人购买的股票超出了他们的承受能力。

20
00:01:06,810 --> 00:01:08,050
And so that error message.
错误信息也是如此。

21
00:01:08,170 --> 00:01:11,890
Insufficient funds to buy shares was written by those crew agents.
资金不足买股是那些船员经纪人写的。

22
00:01:11,890 --> 00:01:14,050
That's what's been surfaced back here.
这就是这里出现的情况。

23
00:01:14,050 --> 00:01:16,810
And that is why those shares weren't bought.
这就是为什么这些股票没有被购买的原因。

24
00:01:16,810 --> 00:01:19,410
And that's why it didn't include that on its summary.
这就是为什么它没有将其包含在摘要中。

25
00:01:19,570 --> 00:01:25,250
And indeed why why, although it does mention that it should be monitored in the next steps.
确实为什么为什么，尽管它确实提到应该在接下来的步骤中对其进行监控。

26
00:01:25,250 --> 00:01:29,450
And that's why, of course, it isn't in the holdings at the bottom.
当然，这就是为什么它不在底部的持仓中。

27
00:01:29,450 --> 00:01:31,250
So there's a great explanation.
所以有一个很好的解释。

28
00:01:31,250 --> 00:01:33,330
And it's everything is working perfectly.
一切都运转良好。

29
00:01:33,330 --> 00:01:36,770
So we're now going to go and look at some Python modules, some Python code.
所以我们现在要去看看一些 Python 模块，一些 Python 代码。

30
00:01:36,770 --> 00:01:43,450
And this really brings again this very important point that a great way to work with building a genetic
这确实再次提出了这一非常重要的观点，即构建遗传基因的好方法

31
00:01:43,450 --> 00:01:43,930
framework.
框架。

32
00:01:43,930 --> 00:01:48,690
So building a genetic solutions to business problems is to start in the lab.
因此，构建商业问题的基因解决方案要从实验室开始。

33
00:01:48,850 --> 00:01:54,170
Start in a notebook like this experimenting with prompts and different agent configurations.
从这样的笔记本开始尝试提示和不同的代理配置。

34
00:01:54,170 --> 00:01:57,970
And don't move to Python modules until you've done your experiments.
在完成实验之前，不要转向 Python 模块。

35
00:01:57,970 --> 00:02:03,150
I do get a lot of people asking me, how am I going to go about building this agent solution to the
确实有很多人问我，我该如何构建这个代理解决方案？

36
00:02:03,150 --> 00:02:04,350
following commercial problem.
以下商业问题。

37
00:02:04,350 --> 00:02:08,990
And they want to dive straight into code and building lots of agents, and they want to build a diagram
他们想要直接深入代码并构建大量代理，并且他们想要构建一个图表

38
00:02:08,990 --> 00:02:11,430
that shows boxes with agents all talking to each other.
这显示了盒子里的代理都在互相交谈。

39
00:02:11,670 --> 00:02:17,750
And I say to them, look, it's super important to begin by experimenting where that data science hat
我对他们说，看，从实验数据科学帽子的位置开始是非常重要的

40
00:02:17,790 --> 00:02:23,430
start in the lab, start by experimenting with prompts, understand what are the capabilities that you
从实验室开始，从尝试提示开始，了解您可以使用哪些功能

41
00:02:23,430 --> 00:02:28,230
can give an agent, that it can stay coherent and it can follow instructions.
可以让代理保持连贯性并且可以遵循指令。

42
00:02:28,230 --> 00:02:33,390
And how can you give the right balance between autonomy and coherence and these kinds of decisions?
如何在自主性和一致性以及此类决策之间取得适当的平衡？

43
00:02:33,430 --> 00:02:38,830
They come through practice, and it doesn't come from designing a big picture and then coding for a
他们是通过实践得来的，而不是来自设计一个大局然后编码

44
00:02:38,830 --> 00:02:43,310
long time, and then kicking it off and then complaining when it doesn't do what you want it to do because
很长一段时间，然后把它踢掉，然后在它没有做你想做的事情时抱怨，因为

45
00:02:43,310 --> 00:02:45,270
it won't the first time if you do it that way.
如果你这样做的话，这将不是第一次。

46
00:02:45,310 --> 00:02:51,670
And that's why the right way to approach this is little by little, starting small in the lab.
这就是为什么解决这个问题的正确方法是一点一点地、从实验室的小规模开始。

47
00:02:51,670 --> 00:02:52,750
So that's what we've done here.
这就是我们在这里所做的。

48
00:02:52,750 --> 00:02:53,350
We've done that.
我们已经做到了。

49
00:02:53,350 --> 00:02:58,470
We've been in the lab, we've built something, and it's now time for us to turn this into code.
我们已经在实验室中构建了一些东西，现在是时候将其转化为代码了。

50
00:02:58,470 --> 00:02:59,750
And we're going to do that.
我们将会这么做。

51
00:02:59,750 --> 00:03:06,240
And I'm going to show you, piece by piece, three different files MCP servers, templates and traders.
我将逐步向您展示三个不同的文件 MCP 服务器、模板和交易者。

52
00:03:06,320 --> 00:03:10,920
So first of all MCP servers is where we define our MCP servers.
首先，MCP 服务器是我们定义 MCP 服务器的地方。

53
00:03:11,040 --> 00:03:11,720
So here we go.
那么我们开始吧。

54
00:03:11,760 --> 00:03:13,120
We're looking for.
我们正在寻找。

55
00:03:13,160 --> 00:03:13,840
It's actually sorry.
其实是很遗憾。

56
00:03:13,880 --> 00:03:15,480
It's it says MCP servers.
它说的是 MCP 服务器。

57
00:03:15,480 --> 00:03:17,240
It's MCP params dot pi.
它是 MCP 参数点 pi。

58
00:03:17,440 --> 00:03:26,320
Change that right now MCP params dot pi is where the MCP servers are specified.
现在更改 MCP 参数点 pi 是指定 MCP 服务器的位置。

59
00:03:26,320 --> 00:03:27,000
So here we go.
那么我们开始吧。

60
00:03:27,040 --> 00:03:29,120
We're in MCP params dot pi.
我们位于 MCP 参数 dot pi 中。

61
00:03:29,280 --> 00:03:35,280
Now you don't need to have your MCP parameters specified in a python module separate to your other code,
现在，您不需要在与其他代码分开的 python 模块中指定 MCP 参数，

62
00:03:35,280 --> 00:03:40,240
but I think this is an organized, tidy way of doing it to keep things nicely.
但我认为这是一种有组织、整洁的方式，可以让事情保持良好状态。

63
00:03:40,280 --> 00:03:42,320
The right concerns in the right file.
正确的关注点存在于正确的文件中。

64
00:03:42,480 --> 00:03:49,520
So in this file, I'm setting up my different MCP parameters that I'll use later when I'm creating the
因此，在这个文件中，我设置了不同的 MCP 参数，稍后在创建

65
00:03:49,520 --> 00:03:50,440
MCP servers.
MCP 服务器。

66
00:03:50,640 --> 00:03:58,560
So first of all, for market data I choose to either use the official polygon MCP server or I use the
因此，首先，对于市场数据，我选择使用官方的 Polygon MCP 服务器，或者使用

67
00:03:58,560 --> 00:04:05,650
little sneaky one that we made market servers that caches results and makes sure that you can use free
我们制作了一个小鬼祟的市场服务器来缓存结果并确保您可以免费使用

68
00:04:05,650 --> 00:04:08,210
polygon IO without exceeding your limits.
多边形 IO 不会超出您的限制。

69
00:04:08,330 --> 00:04:12,690
So we pick one or the other depending on how your EMV is set up.
因此，我们根据您的 EMV 设置方式选择其中之一。

70
00:04:13,090 --> 00:04:13,490
Okay.
好的。

71
00:04:13,530 --> 00:04:22,450
And then the full set of MCP servers for our trader is the accounts server, our homegrown MCP server
然后我们交易者的全套MCP服务器就是账户服务器，我们自己开发的MCP服务器

72
00:04:22,450 --> 00:04:27,250
for accounts, the push server, another little homegrown server sending push notifications because
对于帐户，推送服务器，另一个发送推送通知的本土小型服务器，因为

73
00:04:27,250 --> 00:04:28,010
you know I love them.
你知道我爱他们。

74
00:04:28,330 --> 00:04:31,850
And then the server for the market data.
然后是市场数据的服务器。

75
00:04:32,570 --> 00:04:33,130
Okay.
好的。

76
00:04:33,410 --> 00:04:37,770
And now we've got a separate set of MCP servers for our researcher.
现在我们为我们的研究人员提供了一组单独的 MCP 服务器。

77
00:04:37,970 --> 00:04:39,130
There are three of them.
他们一共有三个。

78
00:04:39,170 --> 00:04:44,610
First of all fetch the ability to fetch a page using playwright browser behind the scenes.
首先，获取在幕后使用剧作家浏览器获取页面的能力。

79
00:04:45,450 --> 00:04:53,090
Then we're using the brave search again, our free brave search API for web searches.
然后我们再次使用brave search，我们的免费brave search API 用于网络搜索。

80
00:04:53,650 --> 00:04:56,130
And then this the return of the memory.
然后这就是记忆的回归。

81
00:04:56,170 --> 00:04:57,490
We're using our memory.
我们正在使用我们的记忆。

82
00:04:57,490 --> 00:04:59,970
We're using the SQL based memory.
我们正在使用基于 SQL 的内存。

83
00:04:59,970 --> 00:05:05,980
And you can see I'm actually going to try and have a separate memory file for each trader based on its
你可以看到我实际上会尝试根据每个交易者的交易情况建立一个单独的内存文件

84
00:05:05,980 --> 00:05:06,540
name.
姓名。

85
00:05:06,540 --> 00:05:08,340
So the name will be passed in.
所以名字会被传入。

86
00:05:08,540 --> 00:05:14,980
And that's what we will use here as the, the name of the of the memory file, so that every trader,
这就是我们在这里使用的内存文件的名称，以便每个交易者，

87
00:05:15,020 --> 00:05:18,700
every researcher has a separate set of memory.
每个研究人员都有一套单独的记忆。

88
00:05:19,460 --> 00:05:19,860
Okay.
好的。

89
00:05:19,900 --> 00:05:22,460
That is the MCP params module.
那是 MCP 参数模块。

90
00:05:22,460 --> 00:05:25,820
So the second module I wanted to show you is called templates.
所以我想向您展示的第二个模块称为模板。

91
00:05:26,740 --> 00:05:35,380
And here's the thing templates.py is just where I have put any function which is returning like a prompt
这就是 templates.py ，我放置了像提示一样返回的任何函数

92
00:05:35,380 --> 00:05:37,980
instruction or a string or something like that.
指令或字符串或类似的东西。

93
00:05:38,020 --> 00:05:44,980
And I've done this to be organized so that I don't have tons of text coded within the body of my functionality.
我这样做是为了进行组织，这样我就不会在我的功能体内编码大量文本。

94
00:05:45,060 --> 00:05:47,260
And again, this is just a nice, good practice.
再说一次，这只是一个很好的做法。

95
00:05:47,300 --> 00:05:49,580
It's good to separate concerns this way.
以这种方式分离关注点是很好的。

96
00:05:49,780 --> 00:05:53,300
It means that if I need to edit my prompts, I've got one place to go and do it.
这意味着如果我需要编辑提示，我可以去一个地方进行编辑。

97
00:05:53,340 --> 00:05:55,820
I've got effectively my my prompt templates.
我已经有效地获得了我的提示模板。

98
00:05:56,180 --> 00:06:02,460
Uh, in many ways, if you if you think of some of the more opinionated frameworks like Lang chain or
呃，在很多方面，如果你想到一些比较固执己见的框架，比如 Lang chain 或

99
00:06:02,500 --> 00:06:07,400
like crew I for for an agent framework, they sort of force you to separate stuff like this?
就像我为代理框架工作的人员一样，他们有点强迫你将这样的东西分开？

100
00:06:07,640 --> 00:06:08,680
Uh, well, they don't force you.
呃，好吧，他们不会强迫你。

101
00:06:08,720 --> 00:06:09,840
But there are ways around it.
但有一些方法可以解决这个问题。

102
00:06:09,840 --> 00:06:15,160
But but, uh, crew, for example, of course, has the YAML files, which, uh, specifically takes
但是，呃，例如，船员，当然有 YAML 文件，其中，呃，专门采用

103
00:06:15,160 --> 00:06:17,400
away takes to one side your text.
离开将您的文字移至一侧。

104
00:06:17,400 --> 00:06:22,320
But we're not we're not using those kinds of frameworks, but there's nothing stopping us from, uh,
但我们并不是不使用这类框架，但是没有什么可以阻止我们，呃，

105
00:06:22,440 --> 00:06:28,080
putting us through the discipline of putting all of our texts like this into a separate module.
让我们经历将所有像这样的文本放入一个单独的模块的纪律。

106
00:06:28,080 --> 00:06:30,120
And that's why I've got it here.
这就是我把它放在这里的原因。

107
00:06:30,120 --> 00:06:37,720
So I've got, uh, my researcher instructions, my research tool definitions, my trader instructions,
所以我有，呃，我的研究人员指示，我的研究工具定义，我的交易者指示，

108
00:06:37,720 --> 00:06:42,440
and my prompts all here in these different functions.
我的提示都在这些不同的功能中。

109
00:06:42,440 --> 00:06:48,080
And you'll see I do things like inserting the current date in the prompts, which I said before was
你会看到我做了一些事情，比如在提示中插入当前日期，我之前说过

110
00:06:48,120 --> 00:06:53,400
a was a very good practice, uh, to avoid having to equip it with the tool that it needs to call.
a 是一个非常好的实践，呃，可以避免为其配备需要调用的工具。

111
00:06:53,440 --> 00:06:59,160
Just put the date in the prompt, and you'll also see how I'm putting the strategy and the account details
只需在提示中输入日期，您还将看到我如何设置策略和帐户详细信息

112
00:06:59,200 --> 00:07:01,120
straight in there in the prompt.
直接在提示中输入。

113
00:07:01,440 --> 00:07:07,880
So that's templates.py that separates out our uh text into its own module.
这就是 templates.py 将我们的 uh 文本分离到它自己的模块中。
