0:00
In this episode of AI dev tools today we
0:02
In this episode of AI dev tools today we
0:02
In this episode of AI dev tools today we are going to learn on how you can build
0:04
are going to learn on how you can build
0:04
are going to learn on how you can build AI agents using Google's AI agent
0:06
AI agents using Google's AI agent
0:06
AI agents using Google's AI agent development kit along with MongoDB's
0:09
development kit along with MongoDB's
0:09
development kit along with MongoDB's vector search and to talk about that we
0:11
vector search and to talk about that we
0:11
vector search and to talk about that we have Mira who's a senior dev kit of
0:14
have Mira who's a senior dev kit of
0:14
have Mira who's a senior dev kit of MongoDB and also a Google GDP.
0:18
MongoDB and also a Google GDP.
0:18
MongoDB and also a Google GDP. [Music]
0:21
[Music] Hi Mira and welcome to the AI dev tools
0:24
Hi Mira and welcome to the AI dev tools
0:24
Hi Mira and welcome to the AI dev tools today's show.
0:25
today's show. >> Hi thanks for having me. Happy to be
0:27
>> Hi thanks for having me. Happy to be
0:27
>> Hi thanks for having me. Happy to be here. All right, M. Thank you so much. I
0:29
here. All right, M. Thank you so much. I
0:30
here. All right, M. Thank you so much. I know you have a lot of things loaded, so
0:32
know you have a lot of things loaded, so
0:32
know you have a lot of things loaded, so I won't take much of your time. So, I'm
0:34
I won't take much of your time. So, I'm
0:34
I won't take much of your time. So, I'm going to add your screen to the stream
0:35
going to add your screen to the stream
0:35
going to add your screen to the stream now and then we can learn on how we can
0:38
now and then we can learn on how we can
0:38
now and then we can learn on how we can build AI agents uh using Google's AI
0:41
build AI agents uh using Google's AI
0:41
build AI agents uh using Google's AI agent development kit.
0:42
agent development kit.
0:42
agent development kit. >> Yeah, let's jump right into it. So, I'm
0:45
>> Yeah, let's jump right into it. So, I'm
0:45
>> Yeah, let's jump right into it. So, I'm going to take just 15 minutes and we're
0:47
going to take just 15 minutes and we're
0:47
going to take just 15 minutes and we're going to build an agent together. So to
0:49
going to build an agent together. So to
0:49
going to build an agent together. So to summarize what an agent is very shortly,
0:52
summarize what an agent is very shortly,
0:52
summarize what an agent is very shortly, it is an AI system that um uses a large
0:55
it is an AI system that um uses a large
0:55
it is an AI system that um uses a large language model to reason through a
0:57
language model to reason through a
0:57
language model to reason through a problem, create a plan to solve this
0:59
problem, create a plan to solve this
0:59
problem, create a plan to solve this problem, and then execute and iterate on
1:02
problem, and then execute and iterate on
1:02
problem, and then execute and iterate on the plan with the help of a set of
1:04
the plan with the help of a set of
1:04
the plan with the help of a set of tools. And for you developers, when I
1:07
tools. And for you developers, when I
1:07
tools. And for you developers, when I say a set of tools, I just mean some
1:09
say a set of tools, I just mean some
1:09
say a set of tools, I just mean some external APIs, some external functions
1:12
external APIs, some external functions
1:12
external APIs, some external functions calling something outside of the scope
1:14
calling something outside of the scope
1:14
calling something outside of the scope of the L&M. And I was thinking of a good
1:18
of the L&M. And I was thinking of a good
1:18
of the L&M. And I was thinking of a good use case for building kind of a agent.
1:20
use case for building kind of a agent.
1:20
use case for building kind of a agent. And I thought that maybe I want to
1:22
And I thought that maybe I want to
1:22
And I thought that maybe I want to optimize or um take away the pain from
1:25
optimize or um take away the pain from
1:25
optimize or um take away the pain from some mundane mundane everyday task. And
1:29
some mundane mundane everyday task. And
1:29
some mundane mundane everyday task. And I do grocery shopping online, but it's
1:31
I do grocery shopping online, but it's
1:31
I do grocery shopping online, but it's still quite repetitive and I do the same
1:32
still quite repetitive and I do the same
1:32
still quite repetitive and I do the same thing every week. So I decided to build
1:35
thing every week. So I decided to build
1:35
thing every week. So I decided to build a Yep. So I decided to build a grocery
1:39
a Yep. So I decided to build a grocery
1:39
a Yep. So I decided to build a grocery shopping agent. So together we'll
1:42
shopping agent. So together we'll
1:42
shopping agent. So together we'll rebuild this very simple agent. Of
1:44
rebuild this very simple agent. Of
1:44
rebuild this very simple agent. Of course, it's not going to interact with
1:45
course, it's not going to interact with
1:45
course, it's not going to interact with the real e-commerce, but they have the
1:48
the real e-commerce, but they have the
1:48
the real e-commerce, but they have the database for an e-commerce. They have
1:49
database for an e-commerce. They have
1:49
database for an e-commerce. They have the inventory. So, we will simulate this
1:52
the inventory. So, we will simulate this
1:52
the inventory. So, we will simulate this um this marketplace.
1:55
um this marketplace. So, the objectives for our agent will be
1:57
So, the objectives for our agent will be
1:57
So, the objectives for our agent will be to understand and execute natural
1:59
to understand and execute natural
1:59
to understand and execute natural language tasks. I want to interact with
2:01
language tasks. I want to interact with
2:01
language tasks. I want to interact with it as though it is a chatbot. So, it
2:04
it as though it is a chatbot. So, it
2:04
it as though it is a chatbot. So, it should understand it when I say add
2:06
should understand it when I say add
2:06
should understand it when I say add milk, eggs, and flour to my cart. I want
2:09
milk, eggs, and flour to my cart. I want
2:09
milk, eggs, and flour to my cart. I want to bake a cake. So when I say that it
2:11
to bake a cake. So when I say that it
2:11
to bake a cake. So when I say that it should be able to find the appropriate
2:12
should be able to find the appropriate
2:12
should be able to find the appropriate ingredients in the product in the
2:15
ingredients in the product in the
2:15
ingredients in the product in the inventory of the uh shop and add them to
2:17
inventory of the uh shop and add them to
2:17
inventory of the uh shop and add them to the cart.
2:19
the cart. Also um I should be able to have access
2:21
Also um I should be able to have access
2:21
Also um I should be able to have access to my past orders. So if I say add my
2:25
to my past orders. So if I say add my
2:25
to my past orders. So if I say add my usual weekly groceries to the cart, it
2:27
usual weekly groceries to the cart, it
2:27
usual weekly groceries to the cart, it should fetch my previous orders and
2:30
should fetch my previous orders and
2:30
should fetch my previous orders and replicate this uh this order.
2:34
replicate this uh this order.
2:34
replicate this uh this order. And there will be a bunch of data that
2:36
And there will be a bunch of data that
2:36
And there will be a bunch of data that will be um collected over time as I use
2:40
will be um collected over time as I use
2:40
will be um collected over time as I use this agent and as I make groceries
2:43
this agent and as I make groceries
2:43
this agent and as I make groceries online. So if I say how much they spend
2:45
online. So if I say how much they spend
2:45
online. So if I say how much they spend on x last month, I want the agent to be
2:47
on x last month, I want the agent to be
2:47
on x last month, I want the agent to be able to access this data and analyze it
2:50
able to access this data and analyze it
2:50
able to access this data and analyze it for me. Of course, these are all tasks
2:52
for me. Of course, these are all tasks
2:52
for me. Of course, these are all tasks that you can do manually through some
2:55
that you can do manually through some
2:55
that you can do manually through some UI. And my goal will is to well optimize
2:59
UI. And my goal will is to well optimize
2:59
UI. And my goal will is to well optimize this process to augment my experience
3:02
this process to augment my experience
3:02
this process to augment my experience and to use the AI agent to make my life
3:05
and to use the AI agent to make my life
3:05
and to use the AI agent to make my life easier.
3:07
easier. This is the architecture for the agent
3:09
This is the architecture for the agent
3:09
This is the architecture for the agent that we will build. So we have input. We
3:12
that we will build. So we have input. We
3:12
that we will build. So we have input. We are interacting with a large language
3:13
are interacting with a large language
3:13
are interacting with a large language model. The model creates a plan and then
3:16
model. The model creates a plan and then
3:16
model. The model creates a plan and then our agent executes this plan. We see
3:19
our agent executes this plan. We see
3:19
our agent executes this plan. We see this action and result here. uh the
3:22
this action and result here. uh the
3:22
this action and result here. uh the action is usually calling a tool or uh
3:25
action is usually calling a tool or uh
3:25
action is usually calling a tool or uh referring to the memory and based on the
3:28
referring to the memory and based on the
3:28
referring to the memory and based on the result of the action our agent will call
3:30
result of the action our agent will call
3:30
result of the action our agent will call the LM again and maybe repeat this
3:33
the LM again and maybe repeat this
3:33
the LM again and maybe repeat this process until we have a satisfying
3:35
process until we have a satisfying
3:35
process until we have a satisfying answer.
3:37
answer. So the input as we said will be natural
3:39
So the input as we said will be natural
3:39
So the input as we said will be natural language
3:41
language and the first thing the agent will do is
3:44
and the first thing the agent will do is
3:44
and the first thing the agent will do is call the model to create a plan for
3:46
call the model to create a plan for
3:46
call the model to create a plan for solving this task.
3:49
solving this task. The first action that the the plan will
3:51
The first action that the the plan will
3:51
The first action that the the plan will have is using a tool to find products in
3:55
have is using a tool to find products in
3:56
have is using a tool to find products in our database. So we need to find these
3:58
our database. So we need to find these
3:58
our database. So we need to find these products.
4:00
products. Then after these products are found, our
4:02
Then after these products are found, our
4:02
Then after these products are found, our agent will call the LLM again and the LM
4:05
agent will call the LLM again and the LM
4:05
agent will call the LLM again and the LM will decide if these products are
4:07
will decide if these products are
4:07
will decide if these products are sufficient and if it should proceed with
4:10
sufficient and if it should proceed with
4:10
sufficient and if it should proceed with the next steps.
4:12
the next steps. They are. So apparently the agent now
4:14
They are. So apparently the agent now
4:14
They are. So apparently the agent now needs to call another tool to add the
4:17
needs to call another tool to add the
4:17
needs to call another tool to add the relevant products to the cart. So we
4:19
relevant products to the cart. So we
4:19
relevant products to the cart. So we execute this tool. The products are
4:21
execute this tool. The products are
4:21
execute this tool. The products are successfully added to the cart. This is
4:23
successfully added to the cart. This is
4:23
successfully added to the cart. This is the result from calling the tool. Uh
4:26
the result from calling the tool. Uh
4:26
the result from calling the tool. Uh with this result, the agent calls the
4:28
with this result, the agent calls the
4:28
with this result, the agent calls the LLM once again. And now the LLM can see
4:32
LLM once again. And now the LLM can see
4:32
LLM once again. And now the LLM can see that everything was successfully
4:34
that everything was successfully
4:34
that everything was successfully executed and it can return the
4:36
executed and it can return the
4:36
executed and it can return the appropriate response to the user.
4:40
appropriate response to the user.
4:40
appropriate response to the user. What are the components of this system?
4:42
What are the components of this system?
4:42
What are the components of this system? So we have the model of course um most
4:45
So we have the model of course um most
4:45
So we have the model of course um most important part of our agent is still the
4:48
important part of our agent is still the
4:48
important part of our agent is still the worksh model and for this demo I'm going
4:51
worksh model and for this demo I'm going
4:51
worksh model and for this demo I'm going to use Gemini 2.0 flash it is a pretty
4:54
to use Gemini 2.0 flash it is a pretty
4:54
to use Gemini 2.0 flash it is a pretty good and fast model so it's appropriate
4:57
good and fast model so it's appropriate
4:57
good and fast model so it's appropriate for an agent that calls it multiple
5:01
for an agent that calls it multiple
5:01
for an agent that calls it multiple times. So of course there will be some
5:03
times. So of course there will be some
5:03
times. So of course there will be some latency involved because the agent calls
5:05
latency involved because the agent calls
5:05
latency involved because the agent calls the model multiple times but we still
5:08
the model multiple times but we still
5:08
the model multiple times but we still want it to be quick enough.
5:11
want it to be quick enough.
5:11
want it to be quick enough. After that we have the tools. Now the
5:13
After that we have the tools. Now the
5:13
After that we have the tools. Now the tools they are very understandable for
5:15
tools they are very understandable for
5:16
tools they are very understandable for us as developers. So the tools uh we can
5:20
us as developers. So the tools uh we can
5:20
us as developers. So the tools uh we can um make them more granular. We can look
5:22
um make them more granular. We can look
5:22
um make them more granular. We can look at them as functions. So the first uh
5:26
at them as functions. So the first uh
5:26
at them as functions. So the first uh tool that we need is finding similar
5:27
tool that we need is finding similar
5:28
tool that we need is finding similar products in the product database. And
5:30
products in the product database. And
5:30
products in the product database. And then the second tool that we need is
5:31
then the second tool that we need is
5:32
then the second tool that we need is another function that can add products
5:34
another function that can add products
5:34
another function that can add products to the cart.
5:36
to the cart. Now how are we going to implement these
5:38
Now how are we going to implement these
5:38
Now how are we going to implement these two functions?
5:40
two functions? Finding similar products and yeah of
5:43
Finding similar products and yeah of
5:43
Finding similar products and yeah of course we we can call them multiple
5:45
course we we can call them multiple
5:45
course we we can call them multiple times if we have multiple products.
5:48
times if we have multiple products.
5:48
times if we have multiple products. How do we implement them? Find similar
5:51
How do we implement them? Find similar
5:51
How do we implement them? Find similar products. Uh this tool this function
5:54
products. Uh this tool this function
5:54
products. Uh this tool this function needs to be able to parse natural
5:56
needs to be able to parse natural
5:56
needs to be able to parse natural language um to take a parse natural
5:58
language um to take a parse natural
5:58
language um to take a parse natural language query. So we're going to pass
6:00
language query. So we're going to pass
6:00
language query. So we're going to pass in eggs or flour or baked goods and then
6:05
in eggs or flour or baked goods and then
6:05
in eggs or flour or baked goods and then the implementation will be querying the
6:07
the implementation will be querying the
6:07
the implementation will be querying the product database. So we need to go and
6:08
product database. So we need to go and
6:08
product database. So we need to go and check the actual database and find the
6:11
check the actual database and find the
6:11
check the actual database and find the appropriate products. Uh it will return
6:13
appropriate products. Uh it will return
6:13
appropriate products. Uh it will return MongoDB documents because our product
6:15
MongoDB documents because our product
6:15
MongoDB documents because our product database will be MongoDB atlas.
6:19
database will be MongoDB atlas.
6:19
database will be MongoDB atlas. And here's how we can simply implement
6:20
And here's how we can simply implement
6:20
And here's how we can simply implement it. So if we have a simple keyword such
6:23
it. So if we have a simple keyword such
6:23
it. So if we have a simple keyword such as X, then the implementation can be as
6:26
as X, then the implementation can be as
6:26
as X, then the implementation can be as simple as directly querying the database
6:29
simple as directly querying the database
6:29
simple as directly querying the database with X, this will return all products
6:32
with X, this will return all products
6:32
with X, this will return all products that have X in their product name.
6:35
that have X in their product name.
6:35
that have X in their product name. Uh but this is not how users will
6:38
Uh but this is not how users will
6:38
Uh but this is not how users will interact with the tool because natural
6:40
interact with the tool because natural
6:40
interact with the tool because natural language can be pretty ambiguous. So if
6:43
language can be pretty ambiguous. So if
6:43
language can be pretty ambiguous. So if we prompt it with sweet treats and we
6:46
we prompt it with sweet treats and we
6:46
we prompt it with sweet treats and we try to find that in the database, we're
6:48
try to find that in the database, we're
6:48
try to find that in the database, we're not going to get any matches because
6:50
not going to get any matches because
6:50
not going to get any matches because we're trying to use keyword match and
6:53
we're trying to use keyword match and
6:53
we're trying to use keyword match and that's not going to work because u the
6:56
that's not going to work because u the
6:56
that's not going to work because u the user is going to use ambiguous language.
7:00
user is going to use ambiguous language.
7:00
user is going to use ambiguous language. So how do we implement this? We need
7:03
So how do we implement this? We need
7:03
So how do we implement this? We need some sort of search that is appropriate
7:05
some sort of search that is appropriate
7:05
some sort of search that is appropriate for natural language.
7:08
for natural language.
7:08
for natural language. And this is where vector search comes
7:10
And this is where vector search comes
7:10
And this is where vector search comes in. So when we use vector search, we're
7:13
in. So when we use vector search, we're
7:13
in. So when we use vector search, we're not searching for exact keywords. We are
7:16
not searching for exact keywords. We are
7:16
not searching for exact keywords. We are searching based on the intent or the
7:18
searching based on the intent or the
7:18
searching based on the intent or the meaning of the user. So if the user
7:21
meaning of the user. So if the user
7:22
meaning of the user. So if the user searches for sweet treats and we search
7:25
searches for sweet treats and we search
7:25
searches for sweet treats and we search using vector search, we should get back
7:27
using vector search, we should get back
7:27
using vector search, we should get back KitKat, donut, and cupcake. As you can
7:30
KitKat, donut, and cupcake. As you can
7:30
KitKat, donut, and cupcake. As you can see, we don't have an exact keyword
7:32
see, we don't have an exact keyword
7:32
see, we don't have an exact keyword match, but these are semantically
7:35
match, but these are semantically
7:35
match, but these are semantically close to the sweet treats query.
7:41
close to the sweet treats query.
7:41
close to the sweet treats query. How does that work? Well, the core of
7:44
How does that work? Well, the core of
7:44
How does that work? Well, the core of the vector search are the so-called
7:45
the vector search are the so-called
7:46
the vector search are the so-called vector embeddings.
7:47
vector embeddings. These embeddings are numerical
7:50
These embeddings are numerical
7:50
These embeddings are numerical multi-dimensional representations of
7:52
multi-dimensional representations of
7:52
multi-dimensional representations of some piece of information
7:54
some piece of information
7:54
some piece of information and they are supposed to capture the
7:56
and they are supposed to capture the
7:56
and they are supposed to capture the semantic qualities of the data. So when
7:59
semantic qualities of the data. So when
7:59
semantic qualities of the data. So when we generate these vectors which are
8:02
we generate these vectors which are
8:02
we generate these vectors which are large arrays with numbers and we try to
8:05
large arrays with numbers and we try to
8:05
large arrays with numbers and we try to plot them on a vector space on a like a
8:09
plot them on a vector space on a like a
8:09
plot them on a vector space on a like a plot we should find that um objects that
8:13
plot we should find that um objects that
8:13
plot we should find that um objects that are similar to each other will have
8:15
are similar to each other will have
8:15
are similar to each other will have vectors that are close to each other. So
8:18
vectors that are close to each other. So
8:18
vectors that are close to each other. So if we have our sweet treats and we
8:20
if we have our sweet treats and we
8:20
if we have our sweet treats and we compare this vector and we find the
8:22
compare this vector and we find the
8:22
compare this vector and we find the closest vectors around it
8:24
closest vectors around it
8:24
closest vectors around it we should get back KitKat. Similarly, if
8:27
we should get back KitKat. Similarly, if
8:27
we should get back KitKat. Similarly, if we search for apple, we'll get this
8:30
we search for apple, we'll get this
8:30
we search for apple, we'll get this vector. We'll find the closest ones in
8:33
vector. We'll find the closest ones in
8:33
vector. We'll find the closest ones in the space around it and we should get
8:35
the space around it and we should get
8:35
the space around it and we should get back orange and other fruit.
8:39
back orange and other fruit.
8:39
back orange and other fruit. Now, how are these vector generated?
8:40
Now, how are these vector generated?
8:40
Now, how are these vector generated? Well, we need an embeddings model. We
8:43
Well, we need an embeddings model. We
8:43
Well, we need an embeddings model. We will use an embeddings model from Google
8:46
will use an embeddings model from Google
8:46
will use an embeddings model from Google Cloud's Vert.x AI. And this embeddings
8:48
Cloud's Vert.x AI. And this embeddings
8:48
Cloud's Vert.x AI. And this embeddings model is pretty much a black box. So we
8:51
model is pretty much a black box. So we
8:51
model is pretty much a black box. So we pass in the object, the uh piece of
8:54
pass in the object, the uh piece of
8:54
pass in the object, the uh piece of text, the image, the video. The embed
8:57
text, the image, the video. The embed
8:57
text, the image, the video. The embed model generates a vector for us and we
9:00
model generates a vector for us and we
9:00
model generates a vector for us and we use it. So when we compare this vector
9:02
use it. So when we compare this vector
9:02
use it. So when we compare this vector to the other vectors in our product
9:04
to the other vectors in our product
9:04
to the other vectors in our product database, they should end up close to
9:08
database, they should end up close to
9:08
database, they should end up close to each other. Um if they are close
9:10
each other. Um if they are close
9:10
each other. Um if they are close semantically.
9:13
All right, let's let's jump into the
9:15
All right, let's let's jump into the
9:15
All right, let's let's jump into the demo. So this is the demo that we will
9:18
demo. So this is the demo that we will
9:18
demo. So this is the demo that we will use. Uh it is on GitHub. It's free and
9:21
use. Uh it is on GitHub. It's free and
9:21
use. Uh it is on GitHub. It's free and if you use the link in GitHub, you can
9:22
if you use the link in GitHub, you can
9:22
if you use the link in GitHub, you can actually sign up for MongoDB Atlas and
9:25
actually sign up for MongoDB Atlas and
9:25
actually sign up for MongoDB Atlas and create the post cluster for free. Uh and
9:28
create the post cluster for free. Uh and
9:28
create the post cluster for free. Uh and there is also a script that allows you
9:30
there is also a script that allows you
9:30
there is also a script that allows you to import the data, the product data. Uh
9:33
to import the data, the product data. Uh
9:33
to import the data, the product data. Uh and show you how the data looks like. So
9:36
and show you how the data looks like. So
9:36
and show you how the data looks like. So we have the cards. Currently there is
9:38
we have the cards. Currently there is
9:38
we have the cards. Currently there is nothing in our cards collection. This is
9:40
nothing in our cards collection. This is
9:40
nothing in our cards collection. This is MB Atlas by the way. So there is nothing
9:43
MB Atlas by the way. So there is nothing
9:43
MB Atlas by the way. So there is nothing in our cards collection because we
9:44
in our cards collection because we
9:44
in our cards collection because we haven't used the agent so far. And then
9:47
haven't used the agent so far. And then
9:47
haven't used the agent so far. And then in the inventory we have a whole bunch
9:50
in the inventory we have a whole bunch
9:50
in the inventory we have a whole bunch of products. So as long as it loads we
9:54
of products. So as long as it loads we
9:54
of products. So as long as it loads we should see here that we have different
9:56
should see here that we have different
9:56
should see here that we have different products. We have actually 27,000
9:58
products. We have actually 27,000
9:58
products. We have actually 27,000 documents and they already have vector
10:01
documents and they already have vector
10:02
documents and they already have vector embanks. So they are ready for us to use
10:05
embanks. So they are ready for us to use
10:05
embanks. So they are ready for us to use vector search.
10:08
vector search. And this is how they look like. So, we
10:10
And this is how they look like. So, we
10:10
And this is how they look like. So, we have our categories, we have the name of
10:12
have our categories, we have the name of
10:12
have our categories, we have the name of the product, we have subcategories, the
10:14
the product, we have subcategories, the
10:14
the product, we have subcategories, the brand, and a lot of other information.
10:17
brand, and a lot of other information.
10:17
brand, and a lot of other information. This is a data set that I found for free
10:19
This is a data set that I found for free
10:19
This is a data set that I found for free on KGO, and it's free to use, and it's
10:22
on KGO, and it's free to use, and it's
10:22
on KGO, and it's free to use, and it's perfect for this demo. Now, let's jump
10:25
perfect for this demo. Now, let's jump
10:25
perfect for this demo. Now, let's jump into the actual implementation of the
10:26
into the actual implementation of the
10:26
into the actual implementation of the agent.
10:29
I'm using Google Cloud's agent
10:31
I'm using Google Cloud's agent
10:31
I'm using Google Cloud's agent development kit. And for the vector
10:33
development kit. And for the vector
10:33
development kit. And for the vector search, I'm using MongoDB Atlas vector
10:36
search, I'm using MongoDB Atlas vector
10:36
search, I'm using MongoDB Atlas vector search. So I used the ADK or agent
10:40
search. So I used the ADK or agent
10:40
search. So I used the ADK or agent development kit CLI to generate this
10:42
development kit CLI to generate this
10:42
development kit CLI to generate this project and uh when when I did that I
10:45
project and uh when when I did that I
10:46
project and uh when when I did that I ended up with some structure here and
10:49
ended up with some structure here and
10:49
ended up with some structure here and the agent pi is my actual agent. So this
10:51
the agent pi is my actual agent. So this
10:51
the agent pi is my actual agent. So this is where I added my implementation. I
10:54
is where I added my implementation. I
10:54
is where I added my implementation. I also added the script for creating the
10:56
also added the script for creating the
10:56
also added the script for creating the embeddings if you want to do it from
10:58
embeddings if you want to do it from
10:58
embeddings if you want to do it from scratch and this is the data set that
11:00
scratch and this is the data set that
11:00
scratch and this is the data set that you can import. There are all the
11:03
you can import. There are all the
11:03
you can import. There are all the instructions are the are in the read me
11:04
instructions are the are in the read me
11:04
instructions are the are in the read me of the repo. So you can you can just
11:07
of the repo. So you can you can just
11:07
of the repo. So you can you can just follow it and replicate it yourself.
11:11
So let's jump into the agent. You can
11:13
So let's jump into the agent. You can
11:13
So let's jump into the agent. You can see that this is a Python file. ADK also
11:16
see that this is a Python file. ADK also
11:16
see that this is a Python file. ADK also supports Java if that's uh closer to
11:19
supports Java if that's uh closer to
11:19
supports Java if that's uh closer to what you're used to work with. And I
11:21
what you're used to work with. And I
11:21
what you're used to work with. And I know they're they're working on an API
11:23
know they're they're working on an API
11:23
know they're they're working on an API for NodeJS.
11:26
for NodeJS. Okay. So what do we have here? We have
11:28
Okay. So what do we have here? We have
11:28
Okay. So what do we have here? We have some environment variables that define
11:31
some environment variables that define
11:31
some environment variables that define my Google Cloud project, the location of
11:33
my Google Cloud project, the location of
11:33
my Google Cloud project, the location of the project, the database connection
11:35
the project, the database connection
11:35
the project, the database connection string, the data database name, the
11:37
string, the data database name, the
11:37
string, the data database name, the collection name, and just some generic
11:40
collection name, and just some generic
11:40
collection name, and just some generic um environment variables.
11:43
um environment variables.
11:43
um environment variables. Then I have a function that takes care
11:45
Then I have a function that takes care
11:45
Then I have a function that takes care of generating the vector embeddings. So
11:48
of generating the vector embeddings. So
11:48
of generating the vector embeddings. So when we pass in the user query sweets,
11:51
when we pass in the user query sweets,
11:52
when we pass in the user query sweets, we can't compare the text sweet traits
11:53
we can't compare the text sweet traits
11:53
we can't compare the text sweet traits with vectors. we need to convert sweet
11:56
with vectors. we need to convert sweet
11:56
with vectors. we need to convert sweet reads also to a vector and then perform
11:58
reads also to a vector and then perform
11:58
reads also to a vector and then perform the vector search.
12:01
the vector search. So how what is the implementation? I
12:03
So how what is the implementation? I
12:03
So how what is the implementation? I initialize my Vert.ex AI project,
12:05
initialize my Vert.ex AI project,
12:05
initialize my Vert.ex AI project, Vert.Ex AI from Google Cloud. And then I
12:09
Vert.Ex AI from Google Cloud. And then I
12:09
Vert.Ex AI from Google Cloud. And then I initialize the text embedding model from
12:12
initialize the text embedding model from
12:12
initialize the text embedding model from Google Cloud as well. And using the
12:15
Google Cloud as well. And using the
12:15
Google Cloud as well. And using the instance of the model, I say get
12:17
instance of the model, I say get
12:17
instance of the model, I say get embeddings. I pass in the user query
12:20
embeddings. I pass in the user query
12:20
embeddings. I pass in the user query sweet reads and I return the generated
12:24
sweet reads and I return the generated
12:24
sweet reads and I return the generated vector. Now this is the vector that we
12:27
vector. Now this is the vector that we
12:27
vector. Now this is the vector that we will use to perform vector search.
12:30
will use to perform vector search.
12:30
will use to perform vector search. And where do we use that? We use it in
12:32
And where do we use that? We use it in
12:32
And where do we use that? We use it in the find similar products tool which is
12:35
the find similar products tool which is
12:35
the find similar products tool which is a function as simple as that. We have
12:37
a function as simple as that. We have
12:38
a function as simple as that. We have some dock string describing what the
12:39
some dock string describing what the
12:39
some dock string describing what the function does. The agent will actually
12:41
function does. The agent will actually
12:42
function does. The agent will actually read this dock string and it will
12:43
read this dock string and it will
12:43
read this dock string and it will understand how to use the function.
12:47
understand how to use the function.
12:47
understand how to use the function. And then we have the implementation. So
12:49
And then we have the implementation. So
12:49
And then we have the implementation. So the implementation very simple. We
12:51
the implementation very simple. We
12:51
the implementation very simple. We initialize our MongoDB client using the
12:54
initialize our MongoDB client using the
12:54
initialize our MongoDB client using the py library. Then we generate
12:58
py library. Then we generate
12:58
py library. Then we generate vector embeddings using our generate
13:00
vector embeddings using our generate
13:00
vector embeddings using our generate embeddings function that we just saw for
13:03
embeddings function that we just saw for
13:03
embeddings function that we just saw for our user query. And then this is the
13:05
our user query. And then this is the
13:05
our user query. And then this is the implementation of the vector search. We
13:07
implementation of the vector search. We
13:07
implementation of the vector search. We use a MongoDB aggregation pipeline. We
13:10
use a MongoDB aggregation pipeline. We
13:10
use a MongoDB aggregation pipeline. We have one stage that does the vector
13:12
have one stage that does the vector
13:12
have one stage that does the vector search using the index that I have
13:15
search using the index that I have
13:15
search using the index that I have already created.
13:17
already created. And we have one more stage that projects
13:20
And we have one more stage that projects
13:20
And we have one more stage that projects the fields that we want the query to
13:22
the fields that we want the query to
13:22
the fields that we want the query to return. So, we are actually excluding
13:25
return. So, we are actually excluding
13:25
return. So, we are actually excluding the vector embeddings because they are a
13:27
the vector embeddings because they are a
13:27
the vector embeddings because they are a pretty large array and we don't want
13:29
pretty large array and we don't want
13:29
pretty large array and we don't want this to go over the network. We don't
13:31
this to go over the network. We don't
13:31
this to go over the network. We don't need it. And I exclude a few other
13:33
need it. And I exclude a few other
13:33
need it. And I exclude a few other details here. Finally, I call
13:38
details here. Finally, I call
13:38
details here. Finally, I call collection aggregate. I pass in the
13:41
collection aggregate. I pass in the
13:41
collection aggregate. I pass in the aggregation pipeline and I get back a
13:43
aggregation pipeline and I get back a
13:43
aggregation pipeline and I get back a list of documents and I return the
13:45
list of documents and I return the
13:46
list of documents and I return the documents. So, this is the
13:47
documents. So, this is the
13:47
documents. So, this is the implementation of the first tool that we
13:49
implementation of the first tool that we
13:49
implementation of the first tool that we have. The second tool is adding
13:52
have. The second tool is adding
13:52
have. The second tool is adding documents to the cart. So it is even
13:55
documents to the cart. So it is even
13:55
documents to the cart. So it is even simpler. So we have the product name and
13:58
simpler. So we have the product name and
13:58
simpler. So we have the product name and the username. The user for whose cart we
14:01
the username. The user for whose cart we
14:01
the username. The user for whose cart we are adding the product. We instantiate
14:04
are adding the product. We instantiate
14:04
are adding the product. We instantiate the client.
14:06
the client. Then we fetch the products database. We
14:09
Then we fetch the products database. We
14:09
Then we fetch the products database. We find the product in the products
14:11
find the product in the products
14:11
find the product in the products database.
14:13
database. Then we find the cart for this user. And
14:17
Then we find the cart for this user. And
14:17
Then we find the cart for this user. And if the car doesn't exist, we actually
14:20
if the car doesn't exist, we actually
14:20
if the car doesn't exist, we actually will create it for for this user.
14:23
will create it for for this user.
14:23
will create it for for this user. And then we add the product to the array
14:27
And then we add the product to the array
14:27
And then we add the product to the array to the list of products. We added a
14:29
to the list of products. We added a
14:29
to the list of products. We added a painted at the end. This is what add to
14:31
painted at the end. This is what add to
14:31
painted at the end. This is what add to set does.
14:34
set does. Finally, how do we build the agent? So
14:37
Finally, how do we build the agent? So
14:37
Finally, how do we build the agent? So we start with using this agent class
14:39
we start with using this agent class
14:39
we start with using this agent class from ADK. We name the agent. Uh we
14:43
from ADK. We name the agent. Uh we
14:43
from ADK. We name the agent. Uh we specify the model that we need to use.
14:45
specify the model that we need to use.
14:45
specify the model that we need to use. We give it some short instructions. Of
14:48
We give it some short instructions. Of
14:48
We give it some short instructions. Of course, in a prediction agent, these
14:49
course, in a prediction agent, these
14:49
course, in a prediction agent, these instructions will be much more compre
14:52
instructions will be much more compre
14:52
instructions will be much more compre comprehensive.
14:53
comprehensive. And then we pass in the list of tools.
14:55
And then we pass in the list of tools.
14:55
And then we pass in the list of tools. As simple as that. Now, I want to show
14:58
As simple as that. Now, I want to show
14:58
As simple as that. Now, I want to show you how it works. So, if I run ADK web
15:00
you how it works. So, if I run ADK web
15:00
you how it works. So, if I run ADK web ADK is the agent development kit CLI.
15:04
ADK is the agent development kit CLI.
15:04
ADK is the agent development kit CLI. And if I open it, you will see that
15:07
And if I open it, you will see that
15:07
And if I open it, you will see that actually we have a pre-built user
15:09
actually we have a pre-built user
15:09
actually we have a pre-built user interface. Oh, wait. I actually need to
15:11
interface. Oh, wait. I actually need to
15:11
interface. Oh, wait. I actually need to run it in the root folder, the folder of
15:14
run it in the root folder, the folder of
15:14
run it in the root folder, the folder of the project. So if I open it, you'll see
15:19
the project. So if I open it, you'll see
15:19
the project. So if I open it, you'll see that we have a pretty nice UI that is
15:21
that we have a pretty nice UI that is
15:22
that we have a pretty nice UI that is really useful for uh development
15:24
really useful for uh development
15:24
really useful for uh development purposes. So if I say hi, the agent
15:27
purposes. So if I say hi, the agent
15:28
purposes. So if I say hi, the agent should reply and we say we see hello,
15:31
should reply and we say we see hello,
15:31
should reply and we say we see hello, I'm the online groceries agent. How can
15:32
I'm the online groceries agent. How can
15:32
I'm the online groceries agent. How can I help you with your shopping needs
15:34
I help you with your shopping needs
15:34
I help you with your shopping needs today? And we see also the trace of
15:37
today? And we see also the trace of
15:37
today? And we see also the trace of events here. uh find me sweet treats.
15:43
Now the agent will call the find
15:45
Now the agent will call the find
15:45
Now the agent will call the find simulated products tool and we can
15:48
simulated products tool and we can
15:48
simulated products tool and we can actually see what the tool returned. We
15:49
actually see what the tool returned. We
15:50
actually see what the tool returned. We have this function call and the result
15:53
have this function call and the result
15:53
have this function call and the result that was returned and then we get also
15:55
that was returned and then we get also
15:55
that was returned and then we get also the answer from the
15:59
the answer from the from the agent. So the agent called the
16:01
from the agent. So the agent called the
16:01
from the agent. So the agent called the LLM with this result from the tool and
16:04
LLM with this result from the tool and
16:04
LLM with this result from the tool and the LLM generated this user friendly
16:08
the LLM generated this user friendly
16:08
the LLM generated this user friendly response for us. So would you like to
16:10
response for us. So would you like to
16:10
response for us. So would you like to add any of these to your cart? If so,
16:12
add any of these to your cart? If so,
16:12
add any of these to your cart? If so, please tell me which ones and what is
16:14
please tell me which ones and what is
16:14
please tell me which ones and what is your username. So just to remind you, we
16:16
your username. So just to remind you, we
16:16
your username. So just to remind you, we don't have anything in the cart yet. So
16:19
don't have anything in the cart yet. So
16:19
don't have anything in the cart yet. So if I add something to the cart, the
16:21
if I add something to the cart, the
16:21
if I add something to the cart, the agent should actually change the
16:23
agent should actually change the
16:23
agent should actually change the database. It should insert it in the
16:26
database. It should insert it in the
16:26
database. It should insert it in the cart document here. It should create a
16:28
cart document here. It should create a
16:28
cart document here. It should create a cart document and then add the product.
16:30
cart document and then add the product.
16:30
cart document and then add the product. Okay. So, what is my username? My
16:33
Okay. So, what is my username? My
16:33
Okay. So, what is my username? My username is mira. Add multiack to my
16:38
username is mira. Add multiack to my
16:38
username is mira. Add multiack to my cart.
16:40
cart. Let's see if it does it. Okay, so it
16:42
Let's see if it does it. Okay, so it
16:42
Let's see if it does it. Okay, so it called add to cart. Uh, it looks
16:45
called add to cart. Uh, it looks
16:45
called add to cart. Uh, it looks successful. Let's see if something
16:47
successful. Let's see if something
16:48
successful. Let's see if something actually happened. So, let's refresh
16:50
actually happened. So, let's refresh
16:50
actually happened. So, let's refresh this collection. And we have a document
16:52
this collection. And we have a document
16:52
this collection. And we have a document here. Yep. And we have multipac.
16:56
here. Yep. And we have multipac.
16:56
here. Yep. And we have multipac. And I actually don't have an idea what
16:58
And I actually don't have an idea what
16:58
And I actually don't have an idea what Multipack is, so you guys should educate
17:00
Multipack is, so you guys should educate
17:00
Multipack is, so you guys should educate me.
17:02
me. All right. Yeah, that was the short demo
17:04
All right. Yeah, that was the short demo
17:04
All right. Yeah, that was the short demo that I wanted to show you today.
17:06
that I wanted to show you today.
17:06
that I wanted to show you today. >> Wow, Mir, that was pretty quick and I I
17:08
>> Wow, Mir, that was pretty quick and I I
17:08
>> Wow, Mir, that was pretty quick and I I really loved, you know, on how you
17:10
really loved, you know, on how you
17:10
really loved, you know, on how you squeezed in both the AI agent
17:12
squeezed in both the AI agent
17:12
squeezed in both the AI agent development kit, you know, and and also
17:14
development kit, you know, and and also
17:14
development kit, you know, and and also the MongoDB uh vector search for someone
17:17
the MongoDB uh vector search for someone
17:18
the MongoDB uh vector search for someone getting started with vector search, mira
17:20
getting started with vector search, mira
17:20
getting started with vector search, mira where can you direct them to learn more
17:22
where can you direct them to learn more
17:22
where can you direct them to learn more about it?
17:24
about it? >> Yeah, that's a great question. So I
17:26
>> Yeah, that's a great question. So I
17:26
>> Yeah, that's a great question. So I would say just go to the uh repository.
17:29
would say just go to the uh repository.
17:29
would say just go to the uh repository. So I'm going to open the repo over here.
17:35
And if you go to Atlas and sign up for a
17:38
And if you go to Atlas and sign up for a
17:38
And if you go to Atlas and sign up for a free account, you can actually create um
17:41
free account, you can actually create um
17:41
free account, you can actually create um a free cluster that allows you to
17:44
a free cluster that allows you to
17:44
a free cluster that allows you to perform vector search. So check it out.
17:47
perform vector search. So check it out.
17:47
perform vector search. So check it out. Just use this demo. And it also guides
17:49
Just use this demo. And it also guides
17:49
Just use this demo. And it also guides you through creating the uh vector
17:52
you through creating the uh vector
17:52
you through creating the uh vector search index and it guides you through
17:54
search index and it guides you through
17:54
search index and it guides you through implementing the uh vector search. So
17:57
implementing the uh vector search. So
17:57
implementing the uh vector search. So yeah, everything is in here.
17:59
yeah, everything is in here.
18:00
yeah, everything is in here. >> Perfect. And I and I did remember that
18:02
>> Perfect. And I and I did remember that
18:02
>> Perfect. And I and I did remember that in in your session you did say that you
18:04
in in your session you did say that you
18:04
in in your session you did say that you know the agent development kit, you
18:06
know the agent development kit, you
18:06
know the agent development kit, you know, can either use uh Python or Java.
18:09
know, can either use uh Python or Java.
18:09
know, can either use uh Python or Java. It was very interesting to hear you said
18:11
It was very interesting to hear you said
18:11
It was very interesting to hear you said Java. Is there no way we have an option
18:12
Java. Is there no way we have an option
18:12
Java. Is there no way we have an option for JavaScript?
18:15
for JavaScript? >> Yeah. Yeah. Well, not yet. I know that
18:17
>> Yeah. Yeah. Well, not yet. I know that
18:17
>> Yeah. Yeah. Well, not yet. I know that they're working on it. I hope we have it
18:18
they're working on it. I hope we have it
18:18
they're working on it. I hope we have it soon. Yeah, I'm of course also a
18:21
soon. Yeah, I'm of course also a
18:21
soon. Yeah, I'm of course also a JavaScript developer, so I would prefer
18:23
JavaScript developer, so I would prefer
18:23
JavaScript developer, so I would prefer to use JavaScript for this.
18:25
to use JavaScript for this.
18:25
to use JavaScript for this. >> Perfect. I think you know, as we say,
18:27
>> Perfect. I think you know, as we say,
18:27
>> Perfect. I think you know, as we say, you know, 2025 is the uh year for
18:29
you know, 2025 is the uh year for
18:29
you know, 2025 is the uh year for agents. So, I think it was it really
18:31
agents. So, I think it was it really
18:31
agents. So, I think it was it really makes sense to go ahead and learn about
18:33
makes sense to go ahead and learn about
18:33
makes sense to go ahead and learn about AI agents and how you can build it and
18:35
AI agents and how you can build it and
18:35
AI agents and how you can build it and get started. Uh it was great to have you
18:37
get started. Uh it was great to have you
18:37
get started. Uh it was great to have you up on the show, Mira. Any final thing
18:39
up on the show, Mira. Any final thing
18:39
up on the show, Mira. Any final thing you want to say before we wrap it up?
18:41
you want to say before we wrap it up?
18:41
you want to say before we wrap it up? >> No, I think it's Yeah, it's really easy
18:43
>> No, I think it's Yeah, it's really easy
18:43
>> No, I think it's Yeah, it's really easy to get started with. also try some VIP
18:46
to get started with. also try some VIP
18:46
to get started with. also try some VIP coding uh an agent and yeah it's it's
18:49
coding uh an agent and yeah it's it's
18:49
coding uh an agent and yeah it's it's going to work. It's it's going to be a
18:51
going to work. It's it's going to be a
18:51
going to work. It's it's going to be a great way to learn how to use it.
18:53
great way to learn how to use it.
18:53
great way to learn how to use it. >> Yeah. All right. So, thank you so much
18:55
>> Yeah. All right. So, thank you so much
18:55
>> Yeah. All right. So, thank you so much everyone who's watching this show. Uh
18:57
everyone who's watching this show. Uh
18:57
everyone who's watching this show. Uh this was the very first episode of AI
18:58
this was the very first episode of AI
18:58
this was the very first episode of AI Dev Tools today and we'll see you in the
19:01
Dev Tools today and we'll see you in the
19:01
Dev Tools today and we'll see you in the next episode. Thank you.
19:03
next episode. Thank you.
19:03
next episode. Thank you. >> Bye everyone.
19:04
>> Bye everyone. Bye.