- [Narrator] Let's give our agent access to a second tool.
The goal is simple.
Our agent should be able to calculate a price
for a given booth request.
Now, if we look into the conference details
in the knowledge documents,
you can see that there are plenty of options
to book a booth with us.
You have one-side open inline booths,
or two-side open corner booths,
or three-side open Peninsula booth types,
and each of them has a different minimum size,
and also different price per square foot.
Also, there's a different registration fee
attached to each one.
Now, how can we calculate, if someone wants to say,
get a quote for 150 square feet inline booth?
Well, we don't want the large language model to do the math
because it wouldn't be 100% reliable.
And LLM is a text generator, not a calculator at heart.
So, instead, we'll give it a tool,
and that tool will be a simple JavaScript function
that takes inputs and returns a calculated price.
Let's take a look at this function.
If you go to tools and then calculator,
you can see a little JavaScript snippet in here.
Now, this might look intimidating at first,
but it's pretty straightforward.
What this script is doing is simple.
It just takes two inputs,
the type of the booth and the size of the requested booth,
and then it has the prices and registration fees
and minimum prices hard coded in here.
And the rest of the script is then actually
just running the calculations,
or giving an error message if, for example,
the requested booth size is too small
for this particular type.
This has nothing to do with AI.
It's just a simple script.
It takes two inputs,
and returns in the end, an array of information
that contains the booth type, the requested size, the price,
the registration fee, the subtotal, and the total,
which you can then later on put into a quotation.
Now, how do we give our agent access to this code?
Well, it's probably simpler than you think.
Let's copy this code
and head over to our AI agent.
In here, click this little plus icon to add a new tool,
select code tool from the right side.
And first, let's give this tool a name
so we can easily recognize it.
Let's call it calculator tool. (typing loudly)
And also give it a simple description.
Remember, this description will be used by the agent
to identify what this tool can do
and when it should be used.
In our case, it could be as simple as saying,
(typing loudly)
call this tool to calculate a price for a requested booth.
Now this will be sufficient.
What I still recommend is providing
a little bit more context,
especially about the minimum sizes of the booths.
Because what would happen is if the LLM requests,
let's say a peninsula booth with just 100 square feet,
it'll get the error message back that this is too small.
It could now call the knowledge tool to figure out
what the minimum size is for that,
but to make the whole process a little bit easier
for the model to understand,
I would include the minimum sizes here for each booth.
So the model doesn't have to actually call the tool
and get the error message or call the knowledge tool
because this is such an important requirement
for all of the different options.
So let's put it in here as a text.
We just say, available booth types
and simply list them here. (typing loudly)
Inline minimum, 100 square feet, then corner
with minimum 200 square feet
and peninsula with minimum 400 square feet.
Again, this is just to make sure that our agent doesn't have
to do that much back and forth, requesting different prices
and then getting error messages if the requested space
was too small.
Now in here, we just select all
and then paste the code that we just copied from before.
The way this script works is
that it expects a variable called exhibit type
and size square feet from the current query.
Now, whether we define these variables, well,
you just scroll down and then add them here
under specify input schema.
And there we can define how the input should look.
So in our case, these are two variables, the exhibit type,
and that should be for example, inline
and the size and square feet.
And again, this is just an example of the schema, the type
of data that is requested here.
It's not the actual data that is being passed.
We just provide this example to an end.
So it can infer the schema.
Of course, you could also specify the schema here manually,
but we'll leave it like this for now
and make sure that this fits.
So you see exhibit type and square feet.
These are the same ones as here,
exhibit type and square feet.
Perfect.
So that's all we have to do.
And now, our agent already has access to this tool.
So let's try it out.
Let's close this one and make sure you clear
the execution from before.
So we start at the blank page.
So delete this one, also reset the chat session,
tidy up this workflow so everything is neat and clean.
And then we can go ahead and ask our agent a few questions.
So let's start the conversation with "Hi."
And then we ask a a question like, "When is the exhibition?"
(typing loudly)
You see, it queried the knowledge tool.
And now we want to ask it a question
that should trigger the calculator tool.
So let's ask for example,
"How much is a 150 square meter booth?"
And you can see here, instead
of giving us an answer right away, it correctly asks us
what kind of booth type we are looking for.
So it could be inline corner or peninsula.
And here's what I meant before,
it already gives us the information of
what the minimal size is for each booth type.
So let's say we want an inline booth.
So you can see the agent now called the calculator tool
to actually get the price for the inline booth.
And the query it used in this case
was the exhibit-type inline.
And then the size and square feet, here, it used 1615
because in this case, it actually translated
my original request, 150 square meter
into 1,615 square feet,
which is okay for this exercise, but you get the point.
So we have 1,615 square feet here.
And what we get now as a quote for this is $89,000.
And where is this coming from?
Well, you can see it here from the response
of the calculator tool.
So this is the size of the requested space.
This is the price per square feet,
and that's the booth type, the registration fee associated
with that, the subtotal, and the total.
So that works.
But let's say that booth is maybe a little large
for our budget.
So we could ask it now a more advanced question, like
for example, "What's the cheapest booth you have?"
And you can see that it correctly returns 100 square feet,
which would cost around $6,300.
And this is also the request that we send
to this calculator tool here.
So inline will be the cheapest booth type,
and then 100 square feet will be the minimum size for that.
And this is the data that was returned,
and this data was then used by the agent
to actually formulate this response here.
So feel free to try this out.
Our agent now already has two tools.
It can access the knowledge,
which we actually didn't use here in this case.
And it has access to the calculator tool.
Feel free to ask a different questions
and see in which case which tool gets triggered.
And in the next video, we'll even add one more tool
to our agent so it can effectively guide potential clients
through a pre-sales process.