Hello guys!
In this video and in the upcoming series of video, we are going to discuss about a new module in long
chain, which is called as lang graph.
Now Lang graph is quite amazing because it actually helps you to build stateful multi actor application
with Llms.
It is used to create agent and multi agent workflow.
So this is really important.
Now there are lot of libraries a lot of open source libraries that are available which actually helps
you to create multi agent workflow.
But if I probably consider lang graph it's quite amazing.
Uh so in this entire video and in the upcoming series of video, I will be discussing many things about
land graph.
First of all, the agenda of this particular video will be that we will try to discuss what exactly
is lang graph, why lang graph, and we'll see.
Or we'll try to create a chatbot wherein we will get just started with Lang graph, where I will be
showing you with respect to all the coding things.
Right.
So all these things we will be covering.
And when we discuss about why Landgraaf at that point of time, you will understand the importance of
landgraaf.
And through this, you know you will also be able to cover or you'll be able to just compare with all
the libraries, open source libraries that are available to create multi agents workflows.
Right.
And I feel right now Landgraaf is quite amazing.
And as you all know, Lang what Lang is also doing is that Lang is coming up with this own cloud platform
through which you will be able to build your own, uh, agent multi agent workflow, uh, using Lang
graph.
And it, you can do it completely in a visualization way.
Right.
And right now it just supports for the Mac machine.
So we'll be discussing all about that as we go ahead.
But right now let's go ahead and focus on first of all we'll go ahead and see the definition of Lang
graph.
So if I talk about what is lang graph.
Lang graph is a library for building stateful multi actor application with Llms used to create agent
and multi multi-agent workflows.
Compared to other LLM frameworks, it offers this core benefit cycles.
So this is really important.
Controllability and persistence okay.
Line graphs allows you to define the flows that involves cycle essential for most agentic architecture
differentiating it from Dag based solutions.
Now if you have seen already my previous video, I hope everybody knows about graph DB.
Okay, so what exactly is graph DB?
It probably helps you to create, you know, if I probably just talk about creating a drag application
using graph knowledge, right.
So here specifically you have nodes.
You have relationship between the nodes.
Uh, like this.
You know, and with the help of this kind of relationships you can actually build this graph knowledge
okay.
And graph knowledge is specifically built right now even in Google search engine you'll be able to see
graph knowledge and with the help of this graph knowledge, you'll be able to develop some amazing application.
Because the efficiency with respect to the graph knowledge search is quite amazing, you know?
So graph knowledge has the combination of all the kind of search, the hybrid search, the graph knowledge
search, you know, so whenever you have any information which is, uh, displayed or which is probably
converted into a graph knowledge information, then your conversation with this kind of data store,
right, can be quite amazing.
So already I have discussed about this in our previous video, but in this video we will try to talk
about line graph.
And the main thing will be that how we have actually created this graph DB structure, right in the
form of graph knowledge.
Similarly line graph is also offers those kind of functionality.
We can create the entire multi agent workflow using this graph knowledge itself.
Right.
So like how we have nodes relationship and all.
Similarly in the line graph.
Also we'll be able to do that.
Okay.
So till now we have just discussed about the definition.
Don't worry if you are not able to understand because once we start the practical application everything
will be able to understand.
Okay.
Now let's talk about the second question.
The second most important question.
Why land graph.
Why land graph?
Okay, now here I will be talking about some amazing benefits of using land graph in point wise.
Okay, so let's go and talk about this amazing benefits of using land graph.
So number one.
Okay.
Number one is that it really simplifies the development simplifies development.
Now when I say simplifies development what does this basically mean.
See whatever complexities usually whenever we develop any multi AI agents right.
They are multiple things that is involved the state management, state management, state management
of the agent, like at which stage at what work it needs to really do, and agent coordination.
Let's say one agent needs to communicate with any other agents, right?
When we say agents we are basically talking about multi agents.
Right.
So this two things are very important.
You know here if I probably see in most of the libraries that I've actually used, most of the open
source libraries that I've used to probably develop multi agents.
This two information that we have that is state management and agent coordination.
I found out a lot of difficulties with respect to managing these things.
Right.
But with the help of Landgraaf it really simplifies it.
Now when we talk about state management and agent coordination, what does this basically mean?
Let's say that I'm using 3 to 4 multi agents in my generative AI application.
One agent is probably doing some Wikipedia search.
So let's say I probably need I require agent one, I require agent two.
I require agent three.
Right.
So let's say all these specific agents are there right.
Each and every agent probably needs to it does some specific task.
Right.
Let's say this will be doing a Google search.
This will be doing a Wikipedia search.
And this will probably do a vector search.
Vector DB search.
Right.
And here is my chatbot which is specifically using all this multi agents.
Now whenever we develop this kind of application it is very important that we have to do the state management
efficiently for all the agents and also the agent coordination.
What does agent coordination basically means the communication between the communication between this
kind of agents.
Let's say whenever a query is asked, first of all, we go and ask.
Agent one hey, whether you really need to do a Google search, if you are doing it, you really need
to provide that information to agent two.
Then agent three will probably come into picture.
So this kind of communication is basically a kind of agent coordination.
Okay.
So whenever we are developing this kind of things, you know, and there may be also scenario that when
you're developing a use case the agent one response may be dependent on agent two or response, you
know.
So agent two will only be able to work when they get the response from agent one.
I'm just giving some hypothetical scenarios okay.
Now when we are developing this kind of chatbots, uh, as a developer we really need to define workflows.
We need to define workflows.
We need to define logics.
Right without worrying, right?
Without worrying about so many different things.
Right.
So that is what it actually does.
Line graph actually provides you this entire simply it simplifies this entire development process.
And it will actually help you to create an efficient multi AI agents.
Right.
So we will be discussing more about it when we go ahead and discuss about the practical implementation.
Second thing is that uh why line graph you should use it.
Second thing a very important point is related to flexibility okay.
So whenever we talk about flexibility, I will just, uh, make sure to provide some description information
over here so that you will be able to refer this.
Okay.
So with respect to flexibility, you can see with line graph develops developers have the flexibility
to define their own agent logic communication protocols.
This allows for highly customized application tailored to specific use cases.
Whether you need a chatbot that can handle various types of user requests, or a multi-agent system
that performs complex tasks.
Lang graph provides the tools to build exactly what you need.
Okay, so it's all about giving you the power to create.
So, uh, with respect to flexibility, as I said, the kind of logics that you can basically write
will be quite amazing.
You'll be seeing that how granular level logics you can actually write with respect to each and every
agents that you specifically create.
I will be showing you, as we go ahead with one very good practical example.
Okay.
Then the third thing is that if I talk about the third important point, why specifically we should
use lang graph, uh, it is related to scalability.
Okay.
Now whenever we talk about scalability here, when we are building this multi agent application we can
actually build large scale multi agent application large scale multi agent applications.
Now what?
What do we mean by large scale multi agent application.
See the kind of robust architecture.
We basically use this large scale multi agent.
We basically say this as large scale multi agent application because it can it can handle it can handle
high volume of interaction high volume of interaction.
Right.
The interaction can be between agents.
And it also has a really amazing or complex workflows.
And you'll be seeing when we define about complex workflows.
It it will be very simple to develop this entire workflow itself.
Right.
And even long chain is coming up with a feature.
And probably many people, many companies are going to use specifically in enterprise.
Right.
And there is also an enterprise version.
We can specifically develop this as an enterprise level application, right?
With all the features.
And it is also coming up with its own cloud where you can just do drag and drop and you can actually
create this.
Right, uh, final, uh, important feature, uh, if I talk about is something called as fault tolerance.
Fault tolerance.
So it also has this amazing feature line graph okay.
So the kind of libraries you'll be seeing, line graph libraries will include.
Right.
Uh, it will be able to handle errors.
You'll be seeing that it will be able to handle errors.
Uh, it will be ensuring, uh, even though your application fails, it should be continuously working.
And, uh, let's say that one individual agent encounters an error, right?
Then.
Also there will be some fault tolerance mechanism it will basically have wherein it will not just stop
the application, but instead it will keep on running, right?
So this is one of the very important core core feature that is reliability, right.
Whenever we talk about reliability.
So this was two important things we have discussed about the definition of land graph.
We have discussed why land graph.
Now it's time that I show you some of the amazing applications, how we can actually go ahead with the
development here.
What we are basically going to do is that we are going to create a chatbot, okay.
And we'll try to create an agent, let's say in the form of chatbot.
And again in the back, back side or right or in the back end.
You'll be able to see that.
We'll also be able to create a graph like how that entire agent specifically works.
So quickly I will go ahead.
And this I'm executing in the Google Colab.
You can also go ahead and use it okay.
So let's say that I will just use any of the GPU that I have.
Okay.
I will just go ahead and connect it.
Anyhow.
You don't require GPU in this, uh, but, uh, definitely we will be seeing that if you have any kind
of, uh, if you if you require any kind of keys over here, and when I say that I'm going to create
a chat bot, let me just go ahead and discuss about this architecture of the chat bot.
So what I am going to create over here.
Right.
So let's say that, uh, there is a chat bot over here, this chat bot, I will try to create some kind
of node.
Let's say this will be my start node okay.
Whenever any user query comes, you should be able to see that I will create a chat bot over here.
This chat bot can basically interact with any LM models okay.
And once it probably gives you the output we should end this entire flow.
Okay, so the reason why I'm drawing this in the form of graph.
Because land graph also does the same thing Okay, so line graph also creates the entire flow in the
form of graph itself where you'll have nodes.
And all right now there are two main important things when we see this.
These are specifically nodes right start and end node.
This chat bot is one node.
And when I write chat bot that basically means it is having some kind of definition, right?
If a chat bot needs to move from one step, let's say from one state to the other state, we basically
call that as a state management, right?
So probably after executing this the chat bot is moving towards the end state.
So something is basically happening.
So let's go ahead and create this.
And then you'll be able to understand more about it okay.
So first of all we will go ahead and install pip install lang graph.
So we are going to specifically use lang graph lang graph okay.
And we will also use lang Smith.
So let's go ahead and execute this line.
Smith I hope everybody knows what exactly is.
So till then, I will also go ahead and show you the documentation of line graph.
So this is what a line graph is all about right.
It has Python.
It has it supports JavaScript and all.
But uh uh if I just go ahead and show you line graph tutorials.
Right.
So here you can see this is the tutorial.
Right.
And uh not this.
Sorry.
Uh let's see.
Yes.
Here you go.
Right in the line graph page.
It should be somewhere here.
Or let me just go to lang chain.
Lang chain.com.
And here here is your line graph.
Yes.
So here you can actually see we will try to create this kind of nodes.
Right.
And I hope everybody has seen this kind of nodes specifically.
Right.
So what does Lang graph actually supports you to.
too.
It provides controllable cognitive architecture for any task.
It is designed for human agent collaborations.
All right.
This kind of graphs.
Also you'll be able to see all these things.
I will try to show you in this video.
So it has this fault tolerant scalability optimized for real world interaction and integrated developer
experience.
Amazing features.
And I feel right.
If you probably get the access of the beta server right, and you'll just be able to see the power of
this.
But at the end of the day, we will be creating some amazing agents, you know?
So here you can see I have installed both the libraries Lang and Lang Smith.
Now let's go ahead and start more things over here.
Now as we go ahead we are also going to install Lang chain because we definitely require lang chain.
And then we are going to use lang chain underscore grok.
Along with this we are also going to use lang chain underscore community.
Right.
So these are all libraries will be specifically required in order to build our entire chatbot.
Right.
So here you can see the installation is basically taking place.
Okay.
Perfect.
Now let's go ahead and import OS.
Or what I will do is that I will right from Google Dot Colab okay.
Import user data.
Okay.
Uh, now see, as you all know, when we worked specifically with VS code, you know, we used to create
environment variables to access any keys.
It can be grok API, it can be Lang Smith keys.
Now similarly, with respect to Google Colab, whenever you are working with Google Colab here you can
see one option.
Here.
You can actually go ahead and upload all your secret keys.
Let's say if you want to use grok API, if you want to use open API, if you want to use Lang Smith
API, if you want to use Hugging Face API, you can just go ahead and enter it over here.
Add a new secret key and you can add the key and value pair.
Okay, here is your password.
Here is your key name.
Now in order to access this key you can actually see that I have already uploaded it over here.
Right.
So let's say since I'm going to use a chatbot which will be interacting with my API.
So if you don't know about grok API, you can just go over here and search for grok.com.
Uh, when you go to grok.com you can sign it with your email ID.
Let's say I'm going to sign it because it provides you free API to access the open source models, you
know.
So I will go to grok API over here.
And here you'll be able to see that a lot of different different models are basically available right.
Llama 3.1.
You also have llama three.
You have gamma 29B you have distilled whisper large V three encoding.
Uh n so all these kind of models are there.
You can specifically use this particular model.
And I have already covered this in my previous videos.
Okay.
Now in this scenario, what I'm actually going to do, I will be using some APIs for this.
So if I go and click on Start Building here, you can see that I will go to my Grok Cloud console.
Then here you can go to API keys.
Once you go to API keys you can probably create your own API key.
I've created so many different API keys.
Or you can go ahead and create your own API key, right?
I've already shown that also in my previous videos.
Once you create an API key, just go ahead and click over here, add a new secret key.
Just go ahead and write grok underscore API key and put it over here.
Write all the API keys itself.
Now once you're able to add in the secret, the next thing is that I will try to read that particular
API key in my Google Colab.
So in order to read, I will go ahead and write from Google Colab, import user data.
And let's say that I want my grok underscore API underscore key.
I can just use this user data dot get grok API key.
So if I go ahead and just print this, you'll be able to see that I'm actually able to read it.
You know proc API underscore key.
This is just to show you don't use this anyhow.
Uh so here you can see it is Grant.
It is asking should we access this particular secret name grok API key.
The notebook title untitled 106. Ipy in B does not have access to secret name grant access.
So if I click on grant access.
But right now what happened?
Timeout happened.
Right.
So I'll go ahead and execute it once again.
And now you'll be able to access this right.
So this is my grok API key that you are able to see.
Perfect right.
So now this grok API key I can actually use it.
I can use it for creating my application anything that I want okay.
Now once this is done what I'm actually going to do I'm also going to use Lang Smith okay.
And I hope everybody knows what exactly is Lang Smith.
Right.
So here I will go ahead and write Lang Smith.
Uh, Lang Smith actually helps you to.
So if I go ahead and just do sign up right, it will be able to help you to track each and every information
with respect to the interaction that you have actually created in your chatbot, right?
So if you go to Lang Smith over here, here you also you'll be able to get the dashboard right.
So I'll go to settings.
Here is my API key.
If you don't have an API key go ahead and create an API key.
But if you go ahead and see my secret key I've already added that Lang Smith underscore API key.
Okay.
Now let's go ahead and read the Lang Smith key also.
So I will go ahead and write.
Lang Smith is equal to user data dot get.
And here also I'm going to use Lang Smith Lang Smith.
Let's see what is the key name.
Okay.
so I will just go ahead and print my Lange Smith.
Okay.
So here you will be able to see that I will also be able to get it.
So it will ask for grant access.
I will give the grant access over here.
And it should be able to display it.
And it is displaying a f.
E is the last term.
F is also over here.
So I have read both this particular key and both.
This key will be specifically used for creating my chatbot application.
Lange Smith will be specifically used for tracking everything that is basically happening over here.
Now the next thing will be that I will go ahead and import OS.
Then let's go ahead and import OS dot environ.
I will just go ahead and keep save all these things right.
So first of all I need Lange chain or sorry Lange Smith API key okay I can also go ahead and write Lange
Smith.
Or I can also go ahead and write Lange chain API key.
So let's go ahead and do this Lange chain an API key.
I will set this to my lamb-smith.
Okay, we need to set up this specific key itself.
Okay.
Um, then my end point end point is specifically not required.
I will just go ahead and copy this.
Two things.
And this is basically just used to set up the basic requirements.
Right.
Like chain tracing V2 and Lang chain project okay.
So let's say this will basically be my course lang graph okay.
So this is what is my project name that I'm actually writing.
I'm saying that hey, we need to make sure that you need to keep the tracing underscore v2 as true.
And lang lang chain API key is nothing, but it is assigned to lang with API key.
Now you may be thinking, Chris, why did you use lang chain underscore API key?
No, you can also use Lang Smith.
But according to our documentation, when I saw both of them were satisfied.
So I just used lang chain underscore API key.
So let's go ahead and execute this.
So once this is executed you'll be able to see all the information over here.
Now quickly let's go ahead and write from long chain underscore grok import Chad grok because I need
to use the Chad grant open source models.
Okay.
Now this is done.
Now I will go ahead and create my LM model, which is nothing but Chad Grok.
And inside this I will be using my grok underscore API underscore key which is equal to grok API key.
And my model underscore name will be nothing.
But you can use multiple models any models that you want.
So in the grok cloud I can see there is llama 3.1.
Anything that you want I will just go ahead and use this gamma two nine be it.
Okay.
So this specific model I will go ahead and use it.
It is up to you now.
Nothing compulsory which model you really need to use.
You can use any model that is provided by grok right.
So this is done.
This is my LM model okay.
Now the next step will be that.
Now here you can see here I'm able to access all the models.
I'm able to access the model gamma two nine.
Be it.
Okay, now it's time we start building a chat bot using line graph.
Right.
So here is what we are going to basically start.
And this is the most important thing right.
So if I probably go ahead and say this okay.
So first of all uh understand there are multiple things which we really need to start with the importing
part.
Okay.
So first of all I will be importing something called as annotated.
Right.
So from typing I will be importing annotated from typing extension I will be importing type dict.
Okay.
Uh along with this I will be importing two important libraries from Lang graph.
So I will go ahead and right from lang graph, uh you'll understand why this importing is done just
in some time.
Okay.
From lang graph.
dot graph.
Okay I'm going to just go ahead and import two things.
One is state graph.
State graph actually helps you to manage the entire state management.
Then your start node start node and your end node.
Right.
You remember that I actually created a diagram right where we had a start node.
Then we had an end node which actually, uh, shows the flow of the entire chatbot itself.
Okay.
Along with this, uh, I will also be showing like this.
See, the state graph is basically used for the state management purpose.
Now the state graph needs to keep on changing based on some parameters.
Okay.
So for that what I will be doing I will go ahead and write from line graph, line graph dot graph dot
messages message.
I'm just going to go ahead and import add underscore messages.
Okay.
Now this is one of the function.
What it does is that we have this something called as messages right.
As we keep on adding the messages over here, we will be able to see that our state management, our
state of the agent will keep on changing.
Now this messages is just like you can understand like a when a user is giving a query, the LM model
is giving a response.
When it is giving a response, the message will get added over here.
And then my state of the chatbot will also get changed.
Right.
So this messages is basically keeping track of all those things.
Okay.
So now let's go ahead and execute this.
So this has got executed successfully.
You can understand each and every thing I have actually explained.
We will talk about this two right just in some time.
Now we will go ahead and create our own class.
Let's say this is my class state which will be uh, making sure to, uh, properly control the entire
state management.
Here I will go ahead and write typed dict.
Okay.
So I will go ahead and write typed dict typed dict.
Okay.
Typed dict okay.
So this class is basically inheriting this particular type of dict.
Okay.
Now what we will do.
We will go ahead and write some comments over here.
Okay.
So that you'll be able to understand messages that have the type list.
The add message function in the annotation defines how this state key should be updated.
It appends the message to the list rather than overwriting.
So inside this class I've created a variable called as messages.
Okay.
And this messages is of type annotated.
And this annotated is basically saying hey it is a list type.
And here I'm using this function called as add messages.
This add messages will be responsible on adding or appending the messages to this list okay.
Which is basically created in the form of list in this messages variable, and it will not override
them.
The entire state management will be controlled as we keep on adding this particular messages, because
on every add we will be changing our state.
Okay.
Now the next thing that we will go ahead and define, since I have defined my class state, I will go
ahead and write my graph builder.
Okay.
I will go ahead and define my graph builder.
So this is what we start our graph building process.
So here I'm going to use state graph the state graph which I have actually imported it over here.
And this state graph will have this particular class which is called as state because this state knows
which messages are there, what messages are basically getting appended.
And this graph builder should be responsible in managing the entire state management.
Right.
So once I execute this here is my graph builder.
So let me just go ahead and execute this.
So this is my graph builder over here right.
So here you can see line graph dot graph dot state.
State graph at this specific location.
So guys now after we have created the graph builder uh what we are basically going to do is that uh
already in this diagram you saw that right.
We are going to create this chat bot.
Now this chat bot should be interacting with our LLM.
So for this we will go ahead and write some definition.
So let's quickly go ahead and create a function definition chat bot.
And remember whenever we are creating any node right in this entire graph builder, it needs to take
the parameter as state.
Okay, whatever state we are giving over here.
And this will be important because the reason is very simple because based on this state message, right.
Whatever messages, whatever interaction that we are doing, the state management will keep on changing.
So here we go ahead and define this chat bot where we take the parameter as state.
And then we return.
You know that after any response that we get from the chatbot, we need to update this messages variable.
So here I will go ahead and create this messages.
And here I will just go ahead and write LM dot invoke.
Okay.
And this invoke will be specifically invoking from the state message which will have the user queries.
Right.
So whenever a user queries you will be able to see that this messages will get appended in this particular
message variable.
And once it does that we are just going to invoke that.
And whatever response we are getting it we are again appending it over here.
Right?
Or we are putting in this particular value.
We are returning this entire in this particular format.
When we return this when we are inheriting the state class.
Right.
It is going to understand, hey, whenever we return this kind of message, it is going to trigger this
add message and it is going to add this in this messages variable.
Okay.
So just understand in this way is that here I have a chatbot function which is invoking the previous
messages given by the user, and we are returning some kind of messages over here.
Okay, so once we execute this I will be getting my chat bot.
Now this chat bot needs to get added in this graph builder.
So here I will go ahead and write graph underscore builder dot add underscore node.
And here I'm going to specifically use chat bot as my node name which will have the functionality of
this particular chat bot.
Okay.
So once I execute this you'll be able to see that this entire node is basically getting added.
So now if I go ahead and just display this you'll not be able to see much things over here.
But we will be seeing the entire diagram.
So step by step you can see that what we have done first of all we have created this class state.
Then we have created our graph builder.
Then we have defined our chatbot.
What functionality is basically doing and what it is returning.
It is returning.
Just message colon some some output that we are getting over here.
Right?
And remember, the chat bot is inheriting the state class.
And the state class has one variable messages in the form of list.
And there is a function called as add underscore message, which will keep on appending whatever message
we are specifically getting over here.
Right.
So that is what it is basically doing.
Now since we have created this graph builder, now it's time that we connect this chatbot to the start
and the end node okay.
So here I'm going to go ahead and write Graph Builder dot add edge okay.
So add edge start chatbot.
Okay.
So we are basically going to add the start and the chatbot.
And similarly we are going to add chatbot till the end.
Right.
So then only we will be able to find out or will be able to get this kind of flow.
So start is basically appended with chatbot.
And chatbot is basically getting appended with end start basically means whenever we get a user query
it will just start the process, then chatbot will do the interaction with LLM.
It will give us the value and it will go to the end state and how the state management basically happening
because of this state class, which we have inherited in Graph Builder.
Okay.
So once we execute this, this is done.
So finally what we do after creating this, after adding all this nodes we go ahead and write Graph
Builder.
We need to compile it.
So we'll go ahead and write dot compile.
So once we compile it we'll be getting our entire graph ready.
So here is my graph itself.
So once I execute this my graph is ready.
Now let me just go ahead and display this.
So in order to display this in the documentation I saw this code where they are importing this image
and display.
And there is something called as graph dot get graph.
So here instead of graph I will write graph builder okay or sorry.
It should be graph only because we have compiled it.
Get graph draw mermaid png okay so once I execute this, you'll be able to see that I'll be getting
this entire flow.
So start and end are just like one private, uh, functions that are present inside the, uh, state.
State?
Uh, if I probably say this particular class, the state graph class.
Right.
Uh, which is present inside this line graph, dot graph, lang lang graph or graph.
Right.
And now this will basically as soon as the user queries we will go to the start state.
Then it goes to the chat bot.
Here the interaction will basically happen.
And once the interaction happens the state should change right?
Once we get the response it will go to the end state.
Now let's go ahead and execute this.
And then only you'll be able to see the output.
Okay.
Uh and we are just going to start this.
Okay.
So here I will just go ahead and write.
While true user underscore input is equal to input
User input user.
And here I'm going to just go ahead and write f user underscore input dot lower in.
Let's say I will go ahead and say hey if you are just going and typing in quit or Q right.
You're just going to stop the conversation with the flow, right?
So here I'm just going to write print.
Goodbye.
Okay.
And then we are just going to break from here.
Okay.
But if the user inputs something else.
So here I will go ahead and write for event in graph dot stream.
Okay.
We are just going to stream.
And here we are going to use this messages as my key variable messages is a colon.
And here I'm going to give based on user.
See.
Initially whenever a user gives a input message I need to set this as user right as the parameter,
and here will basically be my user input.
Okay, then I will go ahead and write print event dot values.
We are just going to print the values.
Then here more we can go ahead and probably convert this or explore these values.
So here I will write for value in event dot values print value.
And inside that value there will be a key which is called as message messages.
Okay.
And then we will go ahead and print our assistant.
Message assistant basically means the message that is basically coming from our uh LMS.
So here you will be able to see value messages dot content.
So here let's explore this code.
First of all a user is giving an input.
If it is not giving given, quit and Q so it will go to graph dot stream with respect to all the messages
that users have already given.
Then we are going to get that event dot values for value.
We are going to get two important things.
One is value of messages and one is the value of message of content.
So this value of messages I think it should have the user message.
And this should have the LM model response response.
So let me go ahead and execute it.
So I will go ahead and write hello.
Let's see.
So here assistant you can see right.
Hello.
How can I help you see all these messages are basically coming in the form of big value right.
So here.
Hello.
How can I help you?
Today is the response.
And I'm able to get it.
So let me go and ask what is generative AI right.
So here you will be able to see that all the response is there right.
Generative AI is a type of artificial intelligence.
Think of it.
So it's amazing right?
You are able to get the entire response.
And here also you can see response metadata content is over here.
So if you just go ahead and explore this, some of the other keys will be available over here.
Right.
And uh, uh, if you go ahead and see down.
So this is my entire generated message.
So if I just go ahead and write Q it should be exiting over here.
Right.
So here you can see it says goodbye.
So guys, I hope you liked this specific video.
And you were able to understand how to basically create a simple chatbot in the form of Lang with the
help of Lang graph.
And here we have basically used the graph itself right from start till the end node.
We have understood that whenever we create any node, it also needs to have a definition and uh, how
we can connect each and every node.
Now in the upcoming videos we are going to develop more complex projects on Lang graph where we will
be using external tools.
Uh, there will just not use one node, but there will be multiple nodes as we go ahead.
So I hope you like this particular video.
I will see you all in the next video.
Thank you.