1 00:00:00,01 --> 00:00:03,03 - [Narrator] Let's give our agent access to a second tool. 2 00:00:03,03 --> 00:00:04,03 The goal is simple. 3 00:00:04,03 --> 00:00:07,01 Our agent should be able to calculate a price 4 00:00:07,01 --> 00:00:08,05 for a given booth request. 5 00:00:08,05 --> 00:00:11,00 Now, if we look into the conference details 6 00:00:11,00 --> 00:00:12,00 in the knowledge documents, 7 00:00:12,00 --> 00:00:14,09 you can see that there are plenty of options 8 00:00:14,09 --> 00:00:17,04 to book a booth with us. 9 00:00:17,04 --> 00:00:19,05 You have one-side open inline booths, 10 00:00:19,05 --> 00:00:21,03 or two-side open corner booths, 11 00:00:21,03 --> 00:00:23,02 or three-side open Peninsula booth types, 12 00:00:23,02 --> 00:00:26,00 and each of them has a different minimum size, 13 00:00:26,00 --> 00:00:28,04 and also different price per square foot. 14 00:00:28,04 --> 00:00:30,09 Also, there's a different registration fee 15 00:00:30,09 --> 00:00:32,02 attached to each one. 16 00:00:32,02 --> 00:00:34,07 Now, how can we calculate, if someone wants to say, 17 00:00:34,07 --> 00:00:38,00 get a quote for 150 square feet inline booth? 18 00:00:38,00 --> 00:00:41,03 Well, we don't want the large language model to do the math 19 00:00:41,03 --> 00:00:44,03 because it wouldn't be 100% reliable. 20 00:00:44,03 --> 00:00:47,09 And LLM is a text generator, not a calculator at heart. 21 00:00:47,09 --> 00:00:51,02 So, instead, we'll give it a tool, 22 00:00:51,02 --> 00:00:54,03 and that tool will be a simple JavaScript function 23 00:00:54,03 --> 00:00:57,04 that takes inputs and returns a calculated price. 24 00:00:57,04 --> 00:00:59,04 Let's take a look at this function. 25 00:00:59,04 --> 00:01:02,09 If you go to tools and then calculator, 26 00:01:02,09 --> 00:01:05,02 you can see a little JavaScript snippet in here. 27 00:01:05,02 --> 00:01:08,04 Now, this might look intimidating at first, 28 00:01:08,04 --> 00:01:10,04 but it's pretty straightforward. 29 00:01:10,04 --> 00:01:12,01 What this script is doing is simple. 30 00:01:12,01 --> 00:01:13,06 It just takes two inputs, 31 00:01:13,06 --> 00:01:16,09 the type of the booth and the size of the requested booth, 32 00:01:16,09 --> 00:01:20,01 and then it has the prices and registration fees 33 00:01:20,01 --> 00:01:23,00 and minimum prices hard coded in here. 34 00:01:23,00 --> 00:01:24,08 And the rest of the script is then actually 35 00:01:24,08 --> 00:01:26,04 just running the calculations, 36 00:01:26,04 --> 00:01:29,08 or giving an error message if, for example, 37 00:01:29,08 --> 00:01:31,04 the requested booth size is too small 38 00:01:31,04 --> 00:01:33,06 for this particular type. 39 00:01:33,06 --> 00:01:34,08 This has nothing to do with AI. 40 00:01:34,08 --> 00:01:36,00 It's just a simple script. 41 00:01:36,00 --> 00:01:37,02 It takes two inputs, 42 00:01:37,02 --> 00:01:40,06 and returns in the end, an array of information 43 00:01:40,06 --> 00:01:43,08 that contains the booth type, the requested size, the price, 44 00:01:43,08 --> 00:01:46,05 the registration fee, the subtotal, and the total, 45 00:01:46,05 --> 00:01:48,07 which you can then later on put into a quotation. 46 00:01:48,07 --> 00:01:51,09 Now, how do we give our agent access to this code? 47 00:01:51,09 --> 00:01:54,05 Well, it's probably simpler than you think. 48 00:01:54,05 --> 00:01:56,03 Let's copy this code 49 00:01:56,03 --> 00:01:58,05 and head over to our AI agent. 50 00:01:58,05 --> 00:02:04,02 In here, click this little plus icon to add a new tool, 51 00:02:04,02 --> 00:02:07,00 select code tool from the right side. 52 00:02:07,00 --> 00:02:09,00 And first, let's give this tool a name 53 00:02:09,00 --> 00:02:11,00 so we can easily recognize it. 54 00:02:11,00 --> 00:02:16,01 Let's call it calculator tool. (typing loudly) 55 00:02:16,01 --> 00:02:18,03 And also give it a simple description. 56 00:02:18,03 --> 00:02:21,00 Remember, this description will be used by the agent 57 00:02:21,00 --> 00:02:22,09 to identify what this tool can do 58 00:02:22,09 --> 00:02:24,07 and when it should be used. 59 00:02:24,07 --> 00:02:27,02 In our case, it could be as simple as saying, 60 00:02:27,02 --> 00:02:29,08 (typing loudly) 61 00:02:29,08 --> 00:02:33,06 call this tool to calculate a price for a requested booth. 62 00:02:33,06 --> 00:02:35,07 Now this will be sufficient. 63 00:02:35,07 --> 00:02:37,02 What I still recommend is providing 64 00:02:37,02 --> 00:02:38,05 a little bit more context, 65 00:02:38,05 --> 00:02:40,06 especially about the minimum sizes of the booths. 66 00:02:40,06 --> 00:02:43,09 Because what would happen is if the LLM requests, 67 00:02:43,09 --> 00:02:47,01 let's say a peninsula booth with just 100 square feet, 68 00:02:47,01 --> 00:02:51,05 it'll get the error message back that this is too small. 69 00:02:51,05 --> 00:02:54,02 It could now call the knowledge tool to figure out 70 00:02:54,02 --> 00:02:55,07 what the minimum size is for that, 71 00:02:55,07 --> 00:02:58,05 but to make the whole process a little bit easier 72 00:02:58,05 --> 00:02:59,09 for the model to understand, 73 00:02:59,09 --> 00:03:03,04 I would include the minimum sizes here for each booth. 74 00:03:03,04 --> 00:03:06,00 So the model doesn't have to actually call the tool 75 00:03:06,00 --> 00:03:08,06 and get the error message or call the knowledge tool 76 00:03:08,06 --> 00:03:10,06 because this is such an important requirement 77 00:03:10,06 --> 00:03:12,00 for all of the different options. 78 00:03:12,00 --> 00:03:14,00 So let's put it in here as a text. 79 00:03:14,00 --> 00:03:18,09 We just say, available booth types 80 00:03:18,09 --> 00:03:22,01 and simply list them here. (typing loudly) 81 00:03:22,01 --> 00:03:27,03 Inline minimum, 100 square feet, then corner 82 00:03:27,03 --> 00:03:34,02 with minimum 200 square feet 83 00:03:34,02 --> 00:03:40,09 and peninsula with minimum 400 square feet. 84 00:03:40,09 --> 00:03:43,09 Again, this is just to make sure that our agent doesn't have 85 00:03:43,09 --> 00:03:47,04 to do that much back and forth, requesting different prices 86 00:03:47,04 --> 00:03:49,09 and then getting error messages if the requested space 87 00:03:49,09 --> 00:03:50,09 was too small. 88 00:03:50,09 --> 00:03:53,08 Now in here, we just select all 89 00:03:53,08 --> 00:03:57,08 and then paste the code that we just copied from before. 90 00:03:57,08 --> 00:03:59,04 The way this script works is 91 00:03:59,04 --> 00:04:02,01 that it expects a variable called exhibit type 92 00:04:02,01 --> 00:04:04,09 and size square feet from the current query. 93 00:04:04,09 --> 00:04:07,08 Now, whether we define these variables, well, 94 00:04:07,08 --> 00:04:10,00 you just scroll down and then add them here 95 00:04:10,00 --> 00:04:12,02 under specify input schema. 96 00:04:12,02 --> 00:04:15,05 And there we can define how the input should look. 97 00:04:15,05 --> 00:04:24,03 So in our case, these are two variables, the exhibit type, 98 00:04:24,03 --> 00:04:27,06 and that should be for example, inline 99 00:04:27,06 --> 00:04:30,07 and the size and square feet. 100 00:04:30,07 --> 00:04:33,08 And again, this is just an example of the schema, the type 101 00:04:33,08 --> 00:04:35,09 of data that is requested here. 102 00:04:35,09 --> 00:04:38,07 It's not the actual data that is being passed. 103 00:04:38,07 --> 00:04:40,06 We just provide this example to an end. 104 00:04:40,06 --> 00:04:42,03 So it can infer the schema. 105 00:04:42,03 --> 00:04:44,06 Of course, you could also specify the schema here manually, 106 00:04:44,06 --> 00:04:46,03 but we'll leave it like this for now 107 00:04:46,03 --> 00:04:48,09 and make sure that this fits. 108 00:04:48,09 --> 00:04:51,04 So you see exhibit type and square feet. 109 00:04:51,04 --> 00:04:52,09 These are the same ones as here, 110 00:04:52,09 --> 00:04:54,07 exhibit type and square feet. 111 00:04:54,07 --> 00:04:55,05 Perfect. 112 00:04:55,05 --> 00:04:56,07 So that's all we have to do. 113 00:04:56,07 --> 00:04:59,05 And now, our agent already has access to this tool. 114 00:04:59,05 --> 00:05:01,02 So let's try it out. 115 00:05:01,02 --> 00:05:03,06 Let's close this one and make sure you clear 116 00:05:03,06 --> 00:05:05,03 the execution from before. 117 00:05:05,03 --> 00:05:07,04 So we start at the blank page. 118 00:05:07,04 --> 00:05:11,04 So delete this one, also reset the chat session, 119 00:05:11,04 --> 00:05:14,07 tidy up this workflow so everything is neat and clean. 120 00:05:14,07 --> 00:05:18,03 And then we can go ahead and ask our agent a few questions. 121 00:05:18,03 --> 00:05:22,05 So let's start the conversation with "Hi." 122 00:05:22,05 --> 00:05:27,04 And then we ask a a question like, "When is the exhibition?" 123 00:05:27,04 --> 00:05:31,06 (typing loudly) 124 00:05:31,06 --> 00:05:33,09 You see, it queried the knowledge tool. 125 00:05:33,09 --> 00:05:35,06 And now we want to ask it a question 126 00:05:35,06 --> 00:05:37,08 that should trigger the calculator tool. 127 00:05:37,08 --> 00:05:39,08 So let's ask for example, 128 00:05:39,08 --> 00:05:44,07 "How much is a 150 square meter booth?" 129 00:05:44,07 --> 00:05:46,08 And you can see here, instead 130 00:05:46,08 --> 00:05:50,03 of giving us an answer right away, it correctly asks us 131 00:05:50,03 --> 00:05:52,09 what kind of booth type we are looking for. 132 00:05:52,09 --> 00:05:55,02 So it could be inline corner or peninsula. 133 00:05:55,02 --> 00:05:56,04 And here's what I meant before, 134 00:05:56,04 --> 00:05:58,04 it already gives us the information of 135 00:05:58,04 --> 00:06:00,07 what the minimal size is for each booth type. 136 00:06:00,07 --> 00:06:04,00 So let's say we want an inline booth. 137 00:06:04,00 --> 00:06:07,09 So you can see the agent now called the calculator tool 138 00:06:07,09 --> 00:06:11,04 to actually get the price for the inline booth. 139 00:06:11,04 --> 00:06:13,04 And the query it used in this case 140 00:06:13,04 --> 00:06:15,02 was the exhibit-type inline. 141 00:06:15,02 --> 00:06:19,05 And then the size and square feet, here, it used 1615 142 00:06:19,05 --> 00:06:22,00 because in this case, it actually translated 143 00:06:22,00 --> 00:06:24,04 my original request, 150 square meter 144 00:06:24,04 --> 00:06:27,02 into 1,615 square feet, 145 00:06:27,02 --> 00:06:30,05 which is okay for this exercise, but you get the point. 146 00:06:30,05 --> 00:06:33,09 So we have 1,615 square feet here. 147 00:06:33,09 --> 00:06:39,00 And what we get now as a quote for this is $89,000. 148 00:06:39,00 --> 00:06:40,08 And where is this coming from? 149 00:06:40,08 --> 00:06:42,04 Well, you can see it here from the response 150 00:06:42,04 --> 00:06:43,08 of the calculator tool. 151 00:06:43,08 --> 00:06:47,07 So this is the size of the requested space. 152 00:06:47,07 --> 00:06:50,00 This is the price per square feet, 153 00:06:50,00 --> 00:06:53,01 and that's the booth type, the registration fee associated 154 00:06:53,01 --> 00:06:55,07 with that, the subtotal, and the total. 155 00:06:55,07 --> 00:06:56,06 So that works. 156 00:06:56,06 --> 00:06:58,08 But let's say that booth is maybe a little large 157 00:06:58,08 --> 00:06:59,09 for our budget. 158 00:06:59,09 --> 00:07:02,09 So we could ask it now a more advanced question, like 159 00:07:02,09 --> 00:07:08,09 for example, "What's the cheapest booth you have?" 160 00:07:08,09 --> 00:07:12,09 And you can see that it correctly returns 100 square feet, 161 00:07:12,09 --> 00:07:16,04 which would cost around $6,300. 162 00:07:16,04 --> 00:07:18,03 And this is also the request that we send 163 00:07:18,03 --> 00:07:20,01 to this calculator tool here. 164 00:07:20,01 --> 00:07:22,02 So inline will be the cheapest booth type, 165 00:07:22,02 --> 00:07:25,02 and then 100 square feet will be the minimum size for that. 166 00:07:25,02 --> 00:07:27,01 And this is the data that was returned, 167 00:07:27,01 --> 00:07:28,09 and this data was then used by the agent 168 00:07:28,09 --> 00:07:32,08 to actually formulate this response here. 169 00:07:32,08 --> 00:07:34,04 So feel free to try this out. 170 00:07:34,04 --> 00:07:36,08 Our agent now already has two tools. 171 00:07:36,08 --> 00:07:38,02 It can access the knowledge, 172 00:07:38,02 --> 00:07:40,05 which we actually didn't use here in this case. 173 00:07:40,05 --> 00:07:42,09 And it has access to the calculator tool. 174 00:07:42,09 --> 00:07:44,08 Feel free to ask a different questions 175 00:07:44,08 --> 00:07:47,07 and see in which case which tool gets triggered. 176 00:07:47,07 --> 00:07:50,09 And in the next video, we'll even add one more tool 177 00:07:50,09 --> 00:07:53,08 to our agent so it can effectively guide potential clients 178 00:07:53,08 --> 00:07:56,00 through a pre-sales process.