1
00:00:00,440 --> 00:00:06,880
Okay, now there's something a bit confusing now, which I'll have to get your head around, which is
好吧，现在有些事情有点令人困惑，我得让你明白，那就是

2
00:00:06,880 --> 00:00:12,240
that you can, as we've just done, turn a function into a tool.
您可以像我们刚刚所做的那样，将函数变成工具。

3
00:00:12,600 --> 00:00:15,240
There's something else you can turn into a tool as well.
您还可以将其他东西变成工具。

4
00:00:15,480 --> 00:00:18,640
You can turn a whole agent into a tool.
您可以将整个代理变成一个工具。

5
00:00:18,920 --> 00:00:24,840
You can say, we've got this sales agent, something that can write a sales email.
你可以说，我们有这个销售代理，可以写销售电子邮件。

6
00:00:25,040 --> 00:00:30,400
Well, that whole thing, that whole process of calling that LM with that prompt, that can just be
嗯，整个事情，用那个提示调用 LM 的整个过程，可以是

7
00:00:30,400 --> 00:00:32,560
considered itself to be a tool.
认为自己是一个工具。

8
00:00:32,560 --> 00:00:35,720
We can think of it as a sales agent tool.
我们可以将其视为一种销售代理工具。

9
00:00:36,240 --> 00:00:42,040
And doing that might sound like there's a fair amount of work to be done to package an LM call into
这样做听起来可能需要做大量的工作才能将 LM 调用打包到

10
00:00:42,040 --> 00:00:42,640
a tool.
一个工具。

11
00:00:43,000 --> 00:00:51,200
But no, all you have to do is call as tool on the agent, and you will convert the agent into a tool.
但不，你所要做的就是在代理上调用作为工具，然后你就会将代理转换为工具。

12
00:00:51,680 --> 00:00:54,600
What does it mean to convert an agent into a tool?
将代理转变为工具意味着什么？

13
00:00:54,800 --> 00:00:58,200
All it means is it's going to create a new tool.
这意味着它将创建一个新工具。

14
00:00:58,200 --> 00:01:02,040
It's going to have all of the JSON gunk that describes what that tool can do.
它将包含所有描述该工具功能的 JSON 内容。

15
00:01:02,240 --> 00:01:07,520
And if that tool is called it's going to actually call the agent and make the agent make the call to
如果调用该工具，它将实际调用代理并让代理进行调用

16
00:01:07,560 --> 00:01:08,160
the LM.
LM。

17
00:01:08,280 --> 00:01:09,400
So it's a wrapper.
所以它是一个包装器。

18
00:01:09,440 --> 00:01:13,880
A wrapper around the agent that turns the agent into a tool.
代理的包装器，将代理变成工具。

19
00:01:14,160 --> 00:01:15,280
That's all it is.
仅此而已。

20
00:01:15,320 --> 00:01:18,600
So let's look at this sales agent one as tool.
那么让我们看看这个销售代理作为一种工具。

21
00:01:18,640 --> 00:01:25,280
We're going to give it a tool name sales agent one still and write a cold sales email is our description
我们将给它一个工具名称销售代理一仍然并写一封冷销售电子邮件是我们的描述

22
00:01:25,280 --> 00:01:26,640
of what that tool can do.
该工具可以做什么。

23
00:01:26,680 --> 00:01:30,520
And now if we look at tool one you can see it's a function tool just like this one.
现在，如果我们看一下工具一，您会发现它是一个功能工具，就像这个工具一样。

24
00:01:30,520 --> 00:01:31,760
Just like send email.
就像发送电子邮件一样。

25
00:01:32,040 --> 00:01:33,040
It's got a different name.
它有一个不同的名字。

26
00:01:33,080 --> 00:01:35,120
Its description is this description here.
它的描述就是这里的描述。

27
00:01:35,160 --> 00:01:40,160
Now it's got the same parameters, the JSON blob that we would expect.
现在它具有相同的参数，即我们期望的 JSON blob。

28
00:01:40,520 --> 00:01:46,200
And it's got a special function to tell it what to do when the tool is actually called.
它有一个特殊的函数来告诉它在实际调用该工具时要做什么。

29
00:01:46,200 --> 00:01:49,200
And that of course is actually going to call our agent.
当然，这实际上是要打电话给我们的代理人。

30
00:01:49,640 --> 00:01:51,760
So hopefully that makes sense.
希望这是有道理的。

31
00:01:51,760 --> 00:01:55,400
We're now going to package our agents into tools and use them.
我们现在将把我们的代理打包成工具并使用它们。

32
00:01:56,080 --> 00:01:57,960
All right here we go.
好吧，我们开始吧。

33
00:01:58,360 --> 00:02:03,360
So this I could have done this with a fancy loop, but I thought, you know what?
所以我可以用一个奇特的循环来完成这个，但我想，你知道吗？

34
00:02:03,360 --> 00:02:07,280
I'll just spell it out so that you're crystal clear on what's happening here.
我只是将其拼写出来，以便您清楚地了解这里发生的事情。

35
00:02:07,960 --> 00:02:09,650
We're going to have three tools.
我们将拥有三个工具。

36
00:02:09,690 --> 00:02:12,250
Tool one, tool two, and tool three.
工具一、工具二、工具三。

37
00:02:12,450 --> 00:02:14,970
And it is just taking the three agents.
而且只是拿了三个特工而已。

38
00:02:15,010 --> 00:02:17,650
Sales agent one, two and three.
销售代理一、二、三级。

39
00:02:17,810 --> 00:02:20,450
And calling as tool on each of them.
并作为每个工具的调用。

40
00:02:20,770 --> 00:02:26,970
And for each one we just give it a tool name and a tool description which is the same tool description.
对于每一个，我们只需给它一个工具名称和一个工具描述，这是相同的工具描述。

41
00:02:27,570 --> 00:02:28,810
That is it.
就是这样。

42
00:02:28,850 --> 00:02:34,130
Now if you if you feel up to it, just rewrite that as a nice little loop so that we don't have a silliness
现在，如果你愿意的话，只需将其重写为一个漂亮的小循环，这样我们就不会犯傻了

43
00:02:34,370 --> 00:02:36,250
with repetition like this.
像这样重复。

44
00:02:36,250 --> 00:02:38,170
But but I wanted to spell it out.
但我想把它说出来。

45
00:02:38,210 --> 00:02:45,450
And now I'm giving myself a list called tools and tools has tool one, tool two, tool three.
现在我给自己一个名为工具的列表，工具有工具一、工具二、工具三。

46
00:02:45,450 --> 00:02:48,450
And these are like the agents wrapped as tools.
这些就像被包裹成工具的代理。

47
00:02:48,450 --> 00:02:54,810
They're tools that would simply call the agents and then send email is the real tool that is just a
它们是简单地呼叫代理然后发送电子邮件的工具，这是真正的工具，只是一个

48
00:02:54,810 --> 00:02:55,490
function.
功能。

49
00:02:55,490 --> 00:02:58,770
Send email that calls SendGrid the email program.
发送电子邮件，调用电子邮件程序 SendGrid。

50
00:02:59,130 --> 00:03:01,530
And let's have a look at what we get if we run this.
让我们看看运行这个程序会得到什么。

51
00:03:01,530 --> 00:03:03,210
So now this is our list of tools.
现在这是我们的工具列表。

52
00:03:03,210 --> 00:03:09,170
And it is indeed four function tools sales agent one, sales agent two, salesperson three and send
确实是四功能工具销售代理一、销售代理二、销售员三、发送

53
00:03:09,210 --> 00:03:12,130
email all in a list of tools.
通过电子邮件发送工具列表中的所有内容。

54
00:03:12,850 --> 00:03:18,610
Okay, now it's time to put all of that into a sales manager.
好的，现在是时候将所有这些都交给销售经理了。

55
00:03:18,970 --> 00:03:20,530
Our planning agent.
我们的策划代理。

56
00:03:20,770 --> 00:03:27,770
So now it's a bit like we did before, except we're giving an agent the ability to choose what to run
所以现在有点像我们之前做的，只是我们让代理能够选择运行什么

57
00:03:27,770 --> 00:03:28,290
when.
什么时候。

58
00:03:28,330 --> 00:03:33,370
It's not like we're just writing Python code to say, do this, this, this, and then send email.
这不像我们只是编写 Python 代码来说，做这个，这个，这个，然后发送电子邮件。

59
00:03:33,410 --> 00:03:36,170
But rather, we're letting the agent decide.
相反，我们让代理人来决定。

60
00:03:36,810 --> 00:03:40,730
You are a sales manager working for comply.
您是一名为Compliance 工作的销售经理。

61
00:03:41,090 --> 00:03:45,410
You use the tools given to you to generate cold sales emails.
您可以使用提供给您的工具来生成冷销售电子邮件。

62
00:03:45,530 --> 00:03:47,490
You never generate sales emails yourself.
您永远不会自己生成销售电子邮件。

63
00:03:47,490 --> 00:03:48,970
You always use the tools.
你总是使用这些工具。

64
00:03:49,290 --> 00:03:52,890
You try all three tools once before choosing the best.
在选择最好的工具之前，您需要尝试所有三种工具一次。

65
00:03:52,930 --> 00:04:00,810
You pick the single best email and use the Send Email tool to send the best email and only the best
您选择最好的一封电子邮件，然后使用发送电子邮件工具发送最好的电子邮件，并且仅发送最好的电子邮件

66
00:04:00,810 --> 00:04:02,250
email to the user.
发送电子邮件给用户。

67
00:04:02,290 --> 00:04:04,410
Now, I'm probably over spelling it out here.
现在，我可能已经把它拼写完了。

68
00:04:04,410 --> 00:04:05,330
You can experiment.
你可以尝试一下。

69
00:04:05,330 --> 00:04:10,250
It's not always required to be so pedantic, but I'm also doing it to show you what's going on.
并不总是需要如此迂腐，但我这样做也是为了向你展示发生了什么。

70
00:04:10,610 --> 00:04:14,810
And it's never a bad thing to be very precise and instructive with your prompts.
非常精确且具有启发性的提示绝不是一件坏事。

71
00:04:15,490 --> 00:04:20,890
Okay, so with that, we want to create a new sales manager agent.
好的，我们想创建一个新的销售经理代理。

72
00:04:20,930 --> 00:04:21,770
There it is.
就在那里。

73
00:04:21,810 --> 00:04:24,130
We want to give it these instructions.
我们想给它这些指示。

74
00:04:24,170 --> 00:04:25,290
It's system prompt.
是系统提示。

75
00:04:25,290 --> 00:04:28,930
We want to pass in all four tools, all these tools right here.
我们想要传递所有四个工具，所有这些工具都在这里。

76
00:04:29,290 --> 00:04:30,850
And we give it a model.
我们给它一个模型。

77
00:04:31,690 --> 00:04:36,210
And then we say send a cold sales email addressed to dear CEO.
然后我们说向亲爱的首席执行官发送一封冷冰冰的销售电子邮件。

78
00:04:36,730 --> 00:04:42,130
And we start this going and off it runs.
我们开始这个过程并开始运行。

79
00:04:42,330 --> 00:04:44,690
And this will take about 30s.
这大约需要 30 秒。

80
00:04:44,690 --> 00:04:46,370
So I will see you in a sec.
所以我很快就会见到你。

81
00:04:46,890 --> 00:04:48,330
Well actually it didn't take 30s.
好吧，实际上并没有花费30秒。

82
00:04:48,330 --> 00:04:49,330
It took 18 seconds.
花了18秒。

83
00:04:49,330 --> 00:04:55,650
So it's quite quick and it finished and we can first let's look look in my email I did in fact just
所以它很快就完成了，我们可以先看看我的电子邮件，事实上我只是这样做了

84
00:04:55,650 --> 00:04:57,810
receive an email and here it is.
收到一封电子邮件，就在这里。

85
00:04:58,170 --> 00:04:59,570
And very good.
而且非常好。

86
00:04:59,810 --> 00:05:03,010
It does indeed do things quite nicely.
它确实做得很好。

87
00:05:03,010 --> 00:05:08,930
You'll see it's put like like a template CEO's name not dear CEO you can improve the prompting to stop
你会看到它像模板一样放置首席执行官的名字不是亲爱的首席执行官你可以改进提示停止

88
00:05:08,930 --> 00:05:13,370
it doing that if you wish, but there's an exercise at the end to incorporate mail merge.
如果您愿意，它可以这样做，但最后有一个合并邮件合并的练习。

89
00:05:13,370 --> 00:05:16,410
So it actually would put in real people's names here.
所以它实际上会在这里输入真实的人名。

90
00:05:16,650 --> 00:05:17,850
But but very nice.
但是但是非常好。

91
00:05:17,850 --> 00:05:24,340
We got the email, it came through to me and it came from the verified email sender as expected.
我们收到了电子邮件，它发送给我，并且按预期来自经过验证的电子邮件发件人。

92
00:05:24,660 --> 00:05:27,500
The other thing to do, of course, is to go and have a look at the trace.
当然，另一件事就是去看看踪迹。

93
00:05:27,540 --> 00:05:28,820
Let's go and do that now.
我们现在就去做吧。

94
00:05:29,100 --> 00:05:29,780
So here it is.
所以就是这样。

95
00:05:29,780 --> 00:05:31,940
Sales manager is what we called it for.
销售经理就是我们所说的。

96
00:05:31,940 --> 00:05:33,140
Tools were used.
使用了工具。

97
00:05:33,180 --> 00:05:34,300
It took 18 seconds.
花了18秒。

98
00:05:34,300 --> 00:05:35,460
Let's go in and have a look.
我们进去看看吧。

99
00:05:35,700 --> 00:05:37,260
So it called Sales Agent one.
所以它被称为销售代理一。

100
00:05:37,260 --> 00:05:38,620
It called sales agent two.
它打电话给销售代理二号。

101
00:05:38,740 --> 00:05:39,940
Sales agent three.
销售代理三．

102
00:05:39,940 --> 00:05:42,420
And then it called Send Email.
然后它调用发送电子邮件。

103
00:05:42,420 --> 00:05:45,300
That's the the the tool that is just a tool.
这就是工具，它只是一个工具。

104
00:05:45,620 --> 00:05:51,580
If you look at each of these sales agents tools representing by this this sort of green thing, you'll
如果您查看由此类绿色事物代表的每个销售代理工具，您会

105
00:05:51,580 --> 00:05:54,100
see that underneath that was an agent.
看到下面是一个特工。

106
00:05:54,100 --> 00:05:59,300
So this hopefully makes it crystal clear for you that we had an agent, the professional sales agent
因此，希望这能让您清楚地知道我们有一个代理，专业的销售代理

107
00:05:59,300 --> 00:06:02,740
that was wrapped in the tool, sales agent one.
那是包裹在工具里的，销售代理之一。

108
00:06:02,740 --> 00:06:04,980
And you can see that again for this one and for this one.
您可以再次看到这一点和这一点。

109
00:06:04,980 --> 00:06:10,900
But in the case of send email, it was simply a function that was called with a body.
但在发送电子邮件的情况下，它只是一个用主体调用的函数。

110
00:06:10,900 --> 00:06:16,140
But you can look through the trace and you should look through the trace and understand the interactions
但是你可以查看跟踪，并且应该查看跟踪并理解交互

111
00:06:16,140 --> 00:06:24,020
between tools and agents to allow the sales manager to carry out its full activity, allowing itself
工具和代理之间的联系，使销售经理能够开展其全部活动，让自己

112
00:06:24,020 --> 00:06:26,940
to make its decisions about what it does, in what order.
做出关于做什么、按什么顺序的决定。
