FullStack SaaS AI NotebookLM Clone | MERN Stack |React,Node,ShadCN,MongoDB|LangChain Tutorial
By Wizard Engineer
Summary
## Key takeaways - **LangGraph builds AI workflows**: LangGraph is a framework built on top of LangChain that allows creation of AI workflows composed of nodes and edges, where nodes are functions and edges define transitions including conditional ones based on state. [55:37], [56:43] - **RAG enhances LLMs externally**: RAG is a technique that enhances the model's generation by providing relevant information from an external memory like vector databases, addressing LLM limitations on untrained data such as 'Maurice the dragon'. [01:14:46], [01:16:37] - **Corrective RAG fixes irrelevance**: Corrective RAG evaluates retrieved data against user question; if irrelevant, it transforms the query for web search, otherwise uses retrieved data to generate response. [02:02:37], [02:04:47] - **Map-Reduce summarizes large docs**: Map-Reduce breaks documents into chunks, generates summaries for each via LLM, then combines summaries into final summary if token limit allows, collapsing further if needed. [02:42:43], [02:44:47] - **Chunk overlap preserves context**: Chunk overlap takes pieces from previous chunk into next one to preserve meaning and context during text splitting, avoiding loss like 'vector DB' becoming meaningless. [01:25:20], [01:27:11] - **Agents use tools via LangChain**: Agents access tools like Tavily for web search when LLM lacks real-time data like current weather in New York, succeeding where plain LLM fails. [31:16], [33:43]
Topics Covered
- Full Video
Full Transcript
In this video, we built a SAS a research app notebook alarm that allows you to perform Q&A and summarization over multiple documents. We have here the
multiple documents. We have here the left panel. We can use the left panel in
left panel. We can use the left panel in order to add some sources, some document that we want to generate reports about.
We can generate a summary, star gap, briefing, dog, FAQ. We can generate also a notary overview, video overview or a man based on selected sources. You can
see on the left we have some sources that we can select here and then later here we can generate a mind map. Now you
can see we have here the mind map generated based on selected sources. You
can see here's the mind map. You can use a mind map in order to study a given concept. Here's the mind map. We have
concept. Here's the mind map. We have
also the audio generated by the selected sources. I'm going to select here an
sources. I'm going to select here an audio and then we're going to listen to it is a podcast. Hey there and welcome to Tech Unpacked. I'm Alex.
>> And I'm Sam. Today we're cracking open one of the biggest buzzwords in tech, generative AI. But we're going beyond
generative AI. But we're going beyond the hype to the core of what it actually is.
>> Exactly. Because at its heart, it's not just about analyzing data or predicting trends. This is AI that's all about
trends. This is AI that's all about creation. It's writing stories,
creation. It's writing stories, composing music, generating images. It's
simulating creativity, >> which is a huge shift from traditional AI. It's not just looking at the past.
AI. It's not just looking at the past.
It's building something entirely new for the future. And it all starts with a
the future. And it all starts with a prompt.
>> And yeah, we have a podcast generated based on selected sources. And also we can generate a briefing talk. Here's a
generate briefing talk based on selected sources. And we can generate also a
sources. And we can generate also a summary star briefing do the FAQ and many more guys. Okay. Now let's move on the left panel. On the left panel we
have here to bar and that allows us to add some documents. We have here discover model. If I pass here topic
discover model. If I pass here topic like what is rag and click here search.
We're going to make a web search. And
then if I click submit we're going to add these documents. Okay. Now we have here another model which is the add source model. On this model we have
source model. On this model we have multiple ways to add a document. We can
upload it or we can drag it. Also we can upload a fia Google drive. If I click here, Google Drive and I'm going to scroll a little bit and then I'm going to pick a file. I'm going to add it
there. Also, we can add a source via
there. Also, we can add a source via website link or a YouTube link. If I
click here and then I can pass a YouTube link and then I'm going to extract the script of the YouTube link. Also, we can paste here some text and then we can add it. And also, we have a chat section.
it. And also, we have a chat section.
Behind of it, we have an agent that has access to tools to perform a specific action. And you can see we have here the
action. And you can see we have here the title and a little over here about all these documents added in here in the left panel. [clears throat]
left panel. [clears throat] And in here we have the conversation between the AI and human. And here
previously I pass the question. Do you
know who am I and what we chart previously? The agent says I am Ben and
previously? The agent says I am Ben and he knows we've talked about generative AI previously because it has access to the memory. If an agent has access to
the memory. If an agent has access to the memory, it means it can remember previous interaction. And at the bottom
previous interaction. And at the bottom here, we have some suggested question generated by the AI that we can ask here. If I pass here, I'm going to
here. If I pass here, I'm going to select here this one. And then we're going to scroll a little bit. You can
see what skills are needed for AI engineering. And then you're going to
engineering. And then you're going to see we're going to have here a response of the air. Okay. And skills needed for AI engineering. Okay. based on your
AI engineering. Okay. based on your library documents. Here are the key
library documents. Here are the key skills needed for air engineering and you can see the air response is formatted in markdown format for better readability. Now for handle payment
readability. Now for handle payment we're going to use trap and we're going to use also the credit based model and in here I'm going to click here add payment in order to add the payment method that the user is going to use in
order to pure credit inside of our app.
And here I can pass here my car number and pass the add payment information.
And then I pass here 42 4242 for testing purpose and pass you the year and the month. Okay. And then we're going to
month. Okay. And then we're going to pass the validation code. And we're
going to click here save car. And once
the user finished adding his payment methods. Now the user can purchase a
methods. Now the user can purchase a credit. Okay. I'm going pick here this
credit. Okay. I'm going pick here this one. And then we're going to buy a
one. And then we're going to buy a credit for $5 because you can see we have here free plan free starter and creator. And then I'm pick here this
creator. And then I'm pick here this one. I make a payment and $1 is equal to
one. I make a payment and $1 is equal to 10 credits. It means we're going to do
10 credits. It means we're going to do five times 10 and then we're going to get here 50 credits. And then you can see in here we increment the credit automatically and that's what we're going to build throughout this video
guys. We we are going to build notebook
guys. We we are going to build notebook alarm and for the authentication we're going to use Google for that. All right
guys, now we're going to be talking about some prerequisites you need in order to follow along this video. You're
going to need basics of react and NodeJS only basics guys. Now if you follow along this video here's what you're going to need. We're going to be talking about vector datase and how it works.
We're going to be talking about embedding model. We're going to talk
embedding model. We're going to talk about rack from scratch retrieve your augmented generation. We're going to be
augmented generation. We're going to be talking about link chain. You're going
to learn the basics of link before you build this app. Uh for payment we're going to use strap. We're going to be talking about background jobs. For
authentication we're going to use Google off. You're going to learn how to
off. You're going to learn how to integrate Google Drive inside of your app. We are going to learn how to build
app. We are going to learn how to build an agent that is memory and also you're going to learn how to build an agent that is access to tools. And we're going
to be talking about also about prompt engineering. And guys, I can say it's
engineering. And guys, I can say it's better to follow the first part and the second parts, okay? In order to build this app, follow the first and the
second parts. And also for text stack
second parts. And also for text stack we're going to use MongoDB, Express, React and NodeJS. And for designing we're going to use SH Cen and Tin CSS.
Also I'm going to talk about some more providers that we're going to use throughout this video. And we have here Cha Fireworks. Chworks is a model
Cha Fireworks. Chworks is a model provider is totally free guys. You're
going to create an account the link down in description. And we have here chart
in description. And we have here chart together. This one is paid one. And if
together. This one is paid one. And if
you want to use a paid one, you can go with Chator AI. If you want to use a free one, you can go with Cha Fireworks or you can go with Char Cress. The link
down in description guys, this one is free. Now let's learn how to set up our
free. Now let's learn how to set up our project. We're going to need a tool
project. We're going to need a tool which is node. You can see actually I've already installed node. If I type node-v, I'm running version 22. And now
in order to get the version, you're going to move here. You're going to tap nodejs.org website and once in here guys you're going to click download and you're going to scroll a little bit you're going to choose a NodeJS version
related to your brain system and once you already install NodeJS we're going to install here to tab script and in order to get tab script here you're going to type npm install-g tab script
in order to install tab script globally you can see here if I tab here tsc-v and you you can see this is my tab script version I'm running version 5.9.
Okay. And now we going to set up our NodeJS project. You're going to tap here
NodeJS project. You're going to tap here make there to create a directory. Now
I'm passing my app. And then here you're going to cd into my app here. And you're
going to type npm init-y.
And once done you're going to see you have a pk the JSON file at the root of your project. Now once you you got a
your project. Now once you you got a file you're going to type the following command. You're going to type npm
command. You're going to type npm install express to install to install the web server. You're going to install malta for file uploading. You're going
to install datam for to get access to our environment variable. Okay. And also
you're going to create a data file at the root of your project. npm install-d
nodemon for starting our node.js app. In
case we make changes inside of it, you're going to install typ script tabs node and ts node. You're going to copy the following commands and also you can see as I said we're going to use a tab
scripts and you can see at the root of my project I have the ts config the json you're going to go at this repository and then you're going to copy the content of this file right here and you
can see if I type if I pass here file index ts file and here I pass here late age is a number you can see I just tap
it okay and then I say isal 12 and pass here console.log
here console.log age. Now, in order to transpire this fat
age. Now, in order to transpire this fat down to JavaScript, I'm type this command. Tap here npm run build. Yeah,
command. Tap here npm run build. Yeah,
I'm going to get into my project pass cd notebook lm clone and then pass npm run build. And then they're going to
build. And then they're going to transpile down this file to JavaScript.
You can see we have here this folder and we have the index.js file. You can see this is JavaScript. Okay. Now we're
going to install lingraph and linkchain.
You're going to tap here lang linkchain.com/lraph.
linkchain.com/lraph.
And once you land on this website, you're going to click here. You can see docs and then I'm going to move to JavaScript section here. I'm going to click here langraph. Okay. Once you
click in here, they're going to take you to the page here. You're going to scroll a little bit and then you're going to move to this section here. Let me zoom a little bit. And you can see we have here
little bit. And you can see we have here gentic right click there. And I'm going to we're going to cap this command here in order to install the following package. And now once you tap this
package. And now once you tap this command, we are going to install we are going to move here. We're going to move here at together AI. Okay. You're going
to tap together.ai. Okay. And
together.ai is an API. You can see in here the tab chat together AI. Chat to
AI is an API that offers a more than 50 plus leading open-source models. Okay,
you can see this is how we're going to use it. You can see if I scroll down and
use it. You can see if I scroll down and we need to import chat to get AI. Okay,
and then here we can pass here the name of the model we want to use in here.
Okay. And we can pass here the temperature which controls the creativity of the model. Okay. And we
can pass also the API key in here. You
can see here you can see I've already gamma API key. If I get into that MV5 file, you can see we have here to get our AI key. Okay, I got it in here. And
here I'm going to pass that right now here. And then we can pass here the API
here. And then we can pass here the API key too. Okay. Now, in order to get the
key too. Okay. Now, in order to get the API key, you're going to move it together.
And here I'm going to sign in. Okay. And
if you you don't have an account, create an account. And then once you sign in,
an account. And then once you sign in, you're going to move to the page in here. And once in here guys you can see
here. And once in here guys you can see we have here this is my balance my credit okay 0.69 69 and I've already
used here 0.2021.
Okay. And then you're going to copy the key here. You can see this is my API
key here. You can see this is my API key. You're going to copy yours here.
key. You're going to copy yours here.
And then you can see at the bottom here we have here a bunch of motors here. I'm
going to click here. We going to use a motor provided by M. Okay. Is totally
free guys. Okay. And pass here. I'm
going to look for a motor here and pass here. I think the name is Turbo. Let me
here. I think the name is Turbo. Let me
pass here. You can see Turbo. We are
going to cop it right here.
Okay, let me scroll down. Okay, you can see we have here the price. You can see this model right here is totally free.
You can see this a chart model and MEA elama 3 70 billion parameter is routable free.
Okay, it's totally free. We can use it.
Okay, let me click in here and see some details about it. And in order to use it, we can copy this name right here.
I'm copy it. And then I'm going to pass it in here. You can see we're going to head into inside of our code here. You
can see pass here. We pass here another motor. Okay. Mro MRO AI. And I'm going
motor. Okay. Mro MRO AI. And I'm going to replace it with this with with this Mama motor. Okay. And
then we're going to pass you the API key. We're going to pass you this and
key. We're going to pass you this and pass it process env. And then we going to pass you the name of the API key.
Okay. We going to copy this one here.
And then we going to pass it in here.
Okay. Like this. Pretty simple. [snorts]
Okay. And then we can start interacting with the motor. And here.
That's all you need to do in here, guys.
Once done, you you already set up. Okay. Now, we're
going to try to chat with this model.
Now, I'm going to try to chat with the model. Okay. And in order to chat with
model. Okay. And in order to chat with the model, I'm passing a message. I'm
create here an array of mess. I'm
passing cones message. I'm passing
message is array. And here is equal to this array. I'm passing the row is equal
this array. I'm passing the row is equal to the user. And then I'm pass the contents and say translates
this message in French. Okay.
Yeah, I'm passive French like this. And
here Yeah, I'm pass I'm say this is a system prompt and here is a user. I'm
going to pass you the row. Now the user and say I'm pass you the content and say hello world. Okay. And here in order to
hello world. Okay. And here in order to call the model, we're going to pass here a response. I can just pass here results
a response. I can just pass here results and I'm pass a weight and we're going to pass here the model invoke in order to call the model. And we're going to pass
in the message array like this. Now
let's head into the command prompt here and then I'm type here node and pass source index.ts. Okay. and I'm tap in
source index.ts. Okay. and I'm tap in and I'm going to go I'm going to get into the second tab and then I type here npm run build and then we are going to
see what we're going to get. Okay, in
here we run our app and inside the second tab in here we compile our we transpile the index we transfer the index ts file down to
JavaScript. Okay, you can see here in
JavaScript. Okay, you can see here in here the finish and in here too we have here the AI method. Okay, contents
bonjour lemon, we have a translator message. Okay, you can see if we head
message. Okay, you can see if we head into the index js file, you can see we have here pretty much the same thing that we have into the index.ts file. If
you want, you can work with JavaScript or TypeScript. Okay, pretty much the
or TypeScript. Okay, pretty much the same thing. Okay guys, and here you can
same thing. Okay guys, and here you can see in here we pass here the system method. The system method is a message
method. The system method is a message that we can pass to the AI to tell to give the AI a specific role. And here in our context, we tell the the row of the
AI is a translator because if we pass here another message, we are going to translate it. Okay, let's say what is a
translate it. Okay, let's say what is a banana? A banana. Okay, and now let's
banana? A banana. Okay, and now let's see which message we're going to get in here. And then I'm tap enter. Yeah, you
here. And then I'm tap enter. Yeah, you
can see actually got here a message, guys. You can see we pass here a a
guys. You can see we pass here a a message. What is a banana? Okay, the row
message. What is a banana? Okay, the row of the AI, the actual of the AI is a translator. Okay, translate this message
translator. Okay, translate this message in French. And here you can see we have
in French. And here you can see we have here a lot of things. Yeah, we should get something like this in French here.
Yeah, something like this. Kiss skin.
Okay, kiss skin banana. Okay, this is a French message. Okay. But you can see in
French message. Okay. But you can see in here we have here a lot here. Okay. Now
I'm going to try to be specific. I'm
going to improve my prompt. Okay. You
can see pass translate this message.
Okay. And here I'm going to modify this prompt. Okay. And pass this one here.
prompt. Okay. And pass this one here.
You are a professional. Okay.
Professional translator. Your job is to translate the user message
in French. Yeah, like this. And then I'm
in French. Yeah, like this. And then I'm passing an example. Example, hello
world. Okay, we are going to have something like this is equal bonju lemon. Okay, something like this. Okay.
lemon. Okay, something like this. Okay.
Now, and here I'm pass here do not and pass do not do not return anything anything else here. Okay. Now,
let's run this again and see what we're going to get in here. And then here I'm type here this note. Okay, we got here the response. Okay guys, you can see we
the response. Okay guys, you can see we have here the AI response. You can see K banana. You can see the AI succeed. Now
banana. You can see the AI succeed. Now
you can see actually I just improved my my prompts. Okay, you can see we pass
my prompts. Okay, you can see we pass here. You are a professional translator.
here. You are a professional translator.
Your job is to translate the user message in French. You can see here I use few shots. Few shot is a pro prompt engineering technique. You can see if I
engineering technique. You can see if I go here and you can see uh prompt engineering is the process of writing refine and optimizing input to encourage
generative AI system to create specific highquality outputs. And you can see we
highquality outputs. And you can see we have here zero shots is when we don't give the AI a we don't give the AI a
way. We don't teach the AI how the AI
way. We don't teach the AI how the AI should respond. You can see if I remove
should respond. You can see if I remove this. Okay, we have here zero shots. If
this. Okay, we have here zero shots. If
I pass here this, we have few shots because I teach the AI how it should respond. Okay, and in here you can see
respond. Okay, and in here you can see we have also channel thought. Channel
thought is a prompt engineering technique that will tell the AI to think step by step. Okay. And we have other prompt engineering technique. If passive
if you pass here prompt if you pass a prompt engineering you're going to see we have a lot of them in here okay and if you don't know what is prompt
engineering technique you can come here and read a little bit about it okay guys you can see we have a lot here okay we have a lot here you can come here and
click here and learn more about prompt jering okay now in here I was explaining ts of message. We have AI message, we have system message and human message.
Okay, let me show you the difference here. And here, let me pass you these
here. And here, let me pass you these two. I'm going to comment this and yeah,
two. I'm going to comment this and yeah, let me uncomment this here, guys. Okay,
I can just copy this here and then I'm pass it into this class and pass here system message. Okay, and then I'm pass
system message. Okay, and then I'm pass that here. Okay. And as I said before, a
that here. Okay. And as I said before, a system message is like we give the AI a specific role. Okay. Your job is to do
specific role. Okay. Your job is to do this. Okay. This is a system message.
this. Okay. This is a system message.
But also we have the user message. The
user message is the message provided by human. Okay. And if I comment this, I
human. Okay. And if I comment this, I can just pass here new human. Yeah. New human message.
new human. Yeah. New human message.
Okay. We're going to have here the the same thing. Okay. I can pass you this
same thing. Okay. I can pass you this here. Okay. Okay. You may message what
here. Okay. Okay. You may message what is a banana. Okay. And now if you run this again, we're going to have here the same thing. Okay. You're going to see.
same thing. Okay. You're going to see.
Let's wait a bit.
Let's wait a bit here.
Okay. Yeah, you can see. Yeah, we have here the response. Okay. Can see. And
yeah, we have also the a message. pass
here a class new AI message. Okay, the
AI message is the response returned by the AI. You can see you can see if I
the AI. You can see you can see if I move at the bottom here, you can see we console here the results. And if we head into the console here, you can see this
is an AMS is the response of the AI.
Okay. Now, we're going to try to use a prompt engineering technique which is chain of thought. Okay. We're going to tell the AI to think step by step. Okay.
You can see in here we have chain of thoughts. Okay. Now let's try to tell
thoughts. Okay. Now let's try to tell the AI to think step by step. Okay. Let
me copy this. And then I'm going to pass this here. You you are a professional
this here. You you are a professional math expert. Okay. Like this.
math expert. Okay. Like this.
Your job is to solve user questions.
Okay. Like this. And then I'm passing what is x + y. Okay, x + y = to I'm pass
is equal to zero. What is the value of x? And and here I can just add here
x? And and here I can just add here another prompt. I'm going to try to
another prompt. I'm going to try to improve this prompt. I'm tell think step by step through your reasoning and explain your thoughts. Your thoughts
like this. Yeah, like this. And then
let's see what we're going to get. Okay,
I'm passing not. And then I'm pass I pass a source. We're going to pass here index.ts file. index.ts. Okay. And then
index.ts file. index.ts. Okay. And then
we're going to see what we're going to get. Okay. And now let's wait a bit.
get. Okay. And now let's wait a bit.
Okay. Yeah, you can see we have here something. Yeah, the air is thinking. We
something. Yeah, the air is thinking. We
tell the air to think step by step. To
find the value of x, we need to isolate x on one side of the equation. Given the
equation x + y =0, our goal is to our goal is to get x by itself. Okay, you
can see that actually the is thinking and as we are using here chain of thoughts which is a prompt engineering technique where we tell the air to think through his reasoning step by step.
Okay.
And now we are going to talk about another thing guys. We just learn types of air message. You can see you have to know that we have system message, we have human message and we have also the
AI message. Okay. AI message. Okay.
AI message. Okay. AI message. Okay.
Which is the response of the AI. Now we
are going to talk about prompt template.
Okay. Now I'm pass prompt prompt like this. And then if I pass a prompt
this. And then if I pass a prompt template and then I'm going to import it from lenchen and pass here import. And
then here I'm pass I'm passive prompt template.
Yeah from template like this. And then
we're going to pass you from Yeah. I'm pass from at lenchain. And
Yeah. I'm pass from at lenchain. And
then we're going to pass forward slashcore forward slash prompt. Yeah. with an S like this and then in here we are going to pass in the prompt. Okay, I'm I'm
going to copy this. I'm going to copy this prompt here and then pass into this function here. UI professional math
function here. UI professional math exports. Your job to your job is to
exports. Your job to your job is to solve user questions. Okay. Okay. In
here we got prompt template here. Let me
see how we use it. Yeah. We're going to pass here new prompt template and pass here new prompt template. Okay. Okay.
Let's see in here.
Yeah, here we should pass your prompt template from template. Okay. Like this.
And then we're going to remove here. No
new. Okay. And you can see pass the prompt. You are a professional math
prompt. You are a professional math expert. Your job is to solve the use
expert. Your job is to solve the use questions, think step by step through your reasoning, and explain your thoughts. Okay.
thoughts. Okay.
And here I'm pass here is the user question. Okay. And pass here braces and
question. Okay. And pass here braces and pass here input. Okay. Like this. And
then now we if I if we comment this I'm going to do this. I'm going to I'm going to comment the message array. And you
can see if we copy this and we move that here. And then you can see we pass here
here. And then you can see we pass here this I'm pass here row is is equal to system and then I'm passing the content.
Okay.
And here pass here you pass here convoke I'm pass invoke prompt is equal to await and then pass a prompt. Yeah, we're
going to pass prompt dot invoke here.
We're going to pass it the input and we're going to pass it the input of the user. Okay. What is Yeah, I'm going to
user. Okay. What is Yeah, I'm going to copy the input here. x + x + y is equals to zero. Okay. We're going to copy the
to zero. Okay. We're going to copy the input and then we're going to pass it in here. Okay. Pass it in here. And then
here. Okay. Pass it in here. And then
here I'm passing invoke prompt value.
Okay. Like this
value. And here, yeah, we're going to pass here the message. Here, we're going to pass here the user. Okay. User. And
I'm going to wrap that into an array like this.
Okay.
Yeah. We're going to wrap that into an array. Okay. I'm going to copy this.
array. Okay. I'm going to copy this.
We're going to pass it in here like this, guys. We get we get rid of the
this, guys. We get we get rid of the error. And now, let's try again and see
error. And now, let's try again and see what we're going to get. And then I'm going to explain you what is the prompt that from template. Okay, we are going to come here and then we're going to run
this again. And you're going to see that
this again. And you're going to see that actually if we use the prompt template that from template we have the possibility to give to provide to pass a
property into the prompt. It's like we define here function. It's like we pass here function hello and then we pass into the function a parameter. this the
parameter here and then we return it.
Okay, it's the same thing. It's like we define here a prompt that we have the possibility to pass in a an input. Yeah,
we can take this as a function that is a parameter which is an input and then in order to pass that input we we call here
prompt.invoke and then we pass you this
prompt.invoke and then we pass you this input. You can see and if we head into
input. You can see and if we head into the console, you're going to see we're going to have pretty much the same thing. You can see okay it works pretty
thing. You can see okay it works pretty well. But also we have another way to
well. But also we have another way to pass the prompt the inputs. I'm going to pass you another way chat prompt template from message. Okay you can see in here we have here this one prompt
template from template. I'm going to comment this one and then you can see in here pass system and we pass the prompt.
Okay. We pass here the tab is the human message or we can pass here the user and then we pass here the question. Okay.
Here's the question. Okay. And now here what I'm going to do here I'm going to pass here something like this. You can
see if I comment this you can see we have here the prompts this variable. We
pass it in here prompt.invoke and then we pass here the inputs. And now what I'm going to do, you can see I'm going to get rid of the array inside the invoke function. And then we're going to
invoke function. And then we're going to pass here invoke prompt only. Okay,
we're going to pass that here. And then
we're going to have the output. Okay,
now let's run this again. And if I head into here, I'm tap this again. I'm going
to run the prompt. I'm run the index.
I'm going to run the index.ts file. And
then you can see we have pretty much the same thing. Okay, what if I tell the AI
same thing. Okay, what if I tell the AI to give me only the response? Okay, now
I'm going to try tell the air to give me only the response and here I'm going to pass here think step by step through your reasoning and explain your thoughts. Okay, I'm try to add here an S
thoughts. Okay, I'm try to add here an S and then I'm say I'm going to pass instructions.
Okay, instruction and here I'm passing this return only the response. Return
only the value I'm passing the value pass you the value of X. Okay, now let's see again what we're going to get here.
Okay. Okay, we're going to try it again and see if we're going to get only the value of X. Yeah, you can see we got here again the thoughts of the reasoning of the AI. Now, we're going to try to
force the AI to return only the value of X. Okay, now we don't need it linking.
X. Okay, now we don't need it linking.
Now, I'm going to copy here something.
We're going to cap this line here and then we're going to pass here. We going
to force the to give us only the response. Okay. And you can see we have
response. Okay. And you can see we have here this I'm going to pass here in a parameter we we pass here respond format value. Okay, we're going to pass value
value. Okay, we're going to pass value and pass X. Okay, this the value and then we're going to import here Z. Okay,
and also we're going to import the Z to JSON schema. Okay, we already install
JSON schema. Okay, we already install that. I can pass here value
that. I can pass here value of X. Okay, now let's see if we're going
of X. Okay, now let's see if we're going to get here only the value of X. Okay.
And now let me run this again here and run this. Yeah, the value of X is Y. You
run this. Yeah, the value of X is Y. You
can see the value of X is Y. Yeah, we
only got the the response. Okay, we for the AI. Okay, and that's good. And now
the AI. Okay, and that's good. And now
you can see in here we have the possibility to get access to it. Pass a
con value of X and then pass here JSON.
I'm pass JSON.
JSON. We're going to pass a JSON.parse
here. And then we're going to pass it result.
And then you're going to see we're going to have here an object. Okay.
Now we got an error here. Arguments of
type message content is not a snapable parameter of type string. Okay. And if I pass here record, you can see we have here an object. And then here I'm passing for the key. We're going to have
it the string and the value you can pass here any. and we get rid of the error.
here any. and we get rid of the error.
Okay. And now let's run this again. We
are going to type here note again. We're
going to pass we're going to run this command and we're going to have here an object. Okay. Yeah, you can see we have
object. Okay. Yeah, you can see we have here an object value of X is minus Y and that's a good answer. Okay. All right
guys, now let's talk about tool calling.
So what is a tool? A tool allows an agent to perform an action. Let's say we try to ask our AI assistant what is the current weather in New York. The agent
is going to say I don't know because the agent wasn't trained on recognizing the current weather of given city in real time. The agent is going to fail and
time. The agent is going to fail and let's say we ask the agent again generate a chart about current population in Miami. It's going to f
again. Now what if you ask the agent
again. Now what if you ask the agent what is the value of x if y + y = 12 the agent is going to succeed that
immediately because the agent the because llm was trained on a mathematical books the lm is going to succeed okay and you can see here we
have here an agent which doesn't have any tool okay doesn't have any tool if we ask some question like what is the car weather in New York or generate a
chat about current population in Miami the agent is going to fail. But what if we ask a question like X give us the value of X if X + Y is equal to 12 the
agent is going to succeed. Okay, because
it was on train on mathematical books.
Now we're going to give the LLM the possibility to get access to the internet to save the internet and see the car weather in given city. That's
what we are going to do. We are going to give an agent a tool in order to perform an action. Okay, here we have an agent.
an action. Okay, here we have an agent.
Okay, we have here the LLM wave tool.
You can see it is here a tool search for searching the web for generating a charts and for converting data into JSON. Okay. Now in here you can see pass
JSON. Okay. Now in here you can see pass a question like what is the car weather in New York? Here the agent is going to succeed because it is a tool that allows it to surf the internet. Okay, once it's
got error, it's going to generate a chart. Okay, once it got the error, it's
chart. Okay, once it got the error, it's going to convert it into JSON and then it's going to generate a charts. And
here we're going to have a valid response. Okay, because our agent here
response. Okay, because our agent here is access to tours and it it can perform actions. Okay, now we're going to talk
actions. Okay, now we're going to talk about runnable. Okay, before we start
about runnable. Okay, before we start learning how to use the tool, I'm going to introduce you Runnable. So, what is a runnable? A Runnable is a way of taking
runnable? A Runnable is a way of taking the output of a function and pass it as input to another function. Okay? And
let's say you can see in here we have here a little diagram. Let's say we have a runnable and we're going to take the output of this runnable one. We're going
to pass it as the input to the runnable 2. And we're going to take the output
2. And we're going to take the output the output of the runnable 2 as input to the runnable 3. And a runnable implements a method like invoke here
batch and stream. Now let's get into our text editor to learn how to use that.
Now you can see in here I'm going to head into in here. Let me get into the index.ts file. And here you can see we
index.ts file. And here you can see we are we pass here llm.invoke
and this is a runnable. Okay, we can write it in this way. Okay, let me show you first. And here I'm going to do
you first. And here I'm going to do this. I'm going to pass you cons
this. I'm going to pass you cons and then I pass you pipe and then we're going to pass you the llm. Okay, like
this.
And then we're going to pass equals.
Okay, we're going to pass it chain reinvoke here. And we're going to pass
reinvoke here. And we're going to pass you the inputs. The inputs. Okay, like
this. And then we're going to see what we're going to get. Okay, chain results.
Now, let's cancel this and see what we're going to get here. Console log.
Okay chain.
And now let's see what we're going to get here. You can see now we're going to
get here. You can see now we're going to try to run it and pass it a weight because the invoke returns a promise.
Now let's run this again and see what we're going to get here. And pass here node and then I'll pass a source index and pass the TS. And now let's check here what we're going to get here. You
can see we have here the response. Yeah,
you can see we have here the reasoning of the air. Okay. Now let's pass here the response for matter. Okay. And if we run this again, we're going to have the same thing. Okay. We're going to have
same thing. Okay. We're going to have here the response of X, the value of X.
Okay. Now, let's learn how to create a runnable. Okay. I'm going to get into
runnable. Okay. I'm going to get into into the runnable.ts file and then I'm putting this code. Okay. Everything is
from Lchain. Okay. Lenchain expression
language. Okay. Cheat sheet. Okay.
You're going to come here and then you're going to learn about RA. Okay. We
have a lot of things in here, guys. I'm
going to give you a summary about runnable. Okay. Now to create a
runnable. Okay. Now to create a runnable, we need to import to create a runnable from a function. Let's see. You
can see in here we have a function and pass funk. I'm pass fun one and I'm pass is
funk. I'm pass fun one and I'm pass is I'm pass function and pass this here.
Okay, this is another function and we can say this is a function one. Okay,
and we're going to take this function.
We're going to pass it in here. Okay.
And to create a runnable, we use the runnable lambda in first. Okay. That's
from and then we pass here the name of the function. Okay. Now, in order to
the function. Okay. Now, in order to call a runnable, let's say we need to call we want to call the first runnable.
We can pass here.
And here you can see here I'm pass here a string. Okay, let me pass here a
a string. Okay, let me pass here a string and pass here even hello. And
then we are going to console here a hello. Okay. Now you can see in here if
hello. Okay. Now you can see in here if you want to run if you want to take the output of the first runnable here and pass it as the input to the next
runnable we can use the runnable sequence. Okay. And then I'm taking you
sequence. Okay. And then I'm taking you runnable one here. Let me comment this line here. Runnable one. And then we're
line here. Runnable one. And then we're going to pass here the mirror property.
Let me explain. Let me remove this.
Let's say we have here two runnable.
Okay. If we have two runnable, okay, we are going to pass here, we can pass here the first property and the last property. Okay. Now, as we have here
property. Okay. Now, as we have here free runnable, we are going to pass the middle property. Okay. Like this. If we
middle property. Okay. Like this. If we
put our cursor over the runnable sequence and you try to see the code here, you're going to see we need to pass it here. Something like you can see
we have first, middle, and last. Okay.
If you have more than three roundable, it's better to use here the middle property. Okay. Now I'm going to cancel
property. Okay. Now I'm going to cancel here something pass a cancel log and then pass a chain and here I'm going to invoke this random pass here result is
equal to a weight here and pass a chain invoke here. Okay, we're going to pass
invoke here. Okay, we're going to pass hello and then you're going to see we're going to have here hello. Okay, you can see we have here the first runnable.
We're going to take we pass this string.
Okay. And then we're going to pass here hello to string. And then we have here the second runnable. We're going to take here to we going to take this string.
We're going to convert it to uppercase.
And then we have here the third runnable. We going to we going to take a
runnable. We going to we going to take a part of this string. Okay. Now let's run this and see what we're going to get.
Okay. Now I'm pass here node and then I'm pass here source. We're going to pass here runnable. Yeah. Runnable.ts.
And then we're going to run this. Okay,
we got here H and E. Okay, they take the output of one runnable and they pass it as the input to the next one. And I can use even this. I'm going to comment
this. I'm going to pass here one.
this. I'm going to pass here one.
Runnable one pipe pipe. I'm passipe. I'm
pass here runnable two. Okay. Now I'm
passipe. We're going to pass hereable three. We're going to get the same
three. We're going to get the same thing. Okay. Now let's run this and see
thing. Okay. Now let's run this and see what we're going to get in here. I'm
going to run this again. We're going to have the same thing. Yeah, we have here an object. And here what I'm going to do
an object. And here what I'm going to do in here and pass here chain because this is runnable. And then I'm going to pass
is runnable. And then I'm going to pass a consult.
Yeah, result is equal to a weight and then pass chain invoke. We're going to pass here hello. We're going to have the same thing guys. Okay, now let's run
this. And you can see in here guys, we
this. And you can see in here guys, we just have here the same output. And
guys, you have to know that a runnable is a way of passing the output of a function to another one. Okay. Try to
make a pause and practice in order to learn. Okay. And now we going to learn
learn. Okay. And now we going to learn how to pass a tool to the LM. Okay. Now
we going to use Tavali. Tavali is a state tool is a tool that we can use in order to save the internet. Okay. Now in
order to to have here the valley you're going to type npm install at lenchain for/ the valley and that we already
install lenchen core don't install this one you're going to tap only this in order to install the valley and then you're going to head into your v file you're going to create these two
environment variable it's a valid API key okay you can see in here I'm not heading to my v file I've already create here Tavali. Yeah, I got the Tavali API
here Tavali. Yeah, I got the Tavali API key. Now, in order to get the Tavali API
key. Now, in order to get the Tavali API key, go on Google and then you're going to type here Tavali Tavali search and then you're going to see this. Okay.
Yeah, you're going to see this. You're
going to type here Tavali. You're going
to click here and then once you land on the this once you land on taval.com, you're going to create an account. I'm
going create an account here.
And then here once you create an account you're going to move to the dashboard and then you're going to copy the API key. Okay, you can see in here I'm going
key. Okay, you can see in here I'm going to click here continue with Google and once they finish here I'm going to have here my API key. Okay, now I'm going to
continue. I'm going to copy this. Okay.
continue. I'm going to copy this. Okay.
And then let me first create here a file here and pass it to to the TS. Okay. And
then we're going to go into the index.ts file. I'm going to copy everything in
file. I'm going to copy everything in here and pass into the tools TS. Okay.
And then I'm going to copy here this line and copy that and pass it in here.
And then let me remove all of this. We
can and you can see in here we can pass to the tavali sage instance main properties. We can pass the max results.
properties. We can pass the max results.
You can see passive five topic general include answer false include row contents include image false okay you can pass here some properties you want
okay now I'm going to remove that and then I'm going to copy this line pass any type here okay like this and then if we go back here
yeah I'm going to continue here again you're going to see I'm going to have here my API key you can see in here guys This is my dashboard. Okay. And then
once you create an account, you're going to have here 1,000 credits. Okay. And
then you're going to cap here your API key. Okay. Do that. Now we going to
key. Okay. Do that. Now we going to continue. Yeah, you can see in here I've
continue. Yeah, you can see in here I've already passed here create an instance of Tavali. Now what I'm going to do in
of Tavali. Now what I'm going to do in here, I'm going to create a tool. Now
we're going to go back in here. We're
going to go at lenchen and here you're going to you're going to look for tool calling. Okay, you're going to scroll
calling. Okay, you're going to scroll down and then in here guys in order to create a tool we use the tool function.
Here you can see we have here the multiply tool. Okay, we can we pass it
multiply tool. Okay, we can we pass it the input this the input and we pass it the name and the description of the two
multiply two numbers. Now I'm going to copy these two. We're going to use it.
I'm going copy that and then I'm passing here. We have here I'mma copy this line
here. We have here I'mma copy this line and pass edit tab here. Okay. And then
we are going to pass here this. Okay.
Yeah, we have here two. And then yeah, we got an error here. Okay. Now we're
going to fix that. Yeah, we got here two two variable. They have the same name. A
two variable. They have the same name. A
value search like this. And then we're going to pass here a constants. and pass
lm with tools like this. And then pass here weights llm bound tools. Okay, we
use the bound tool in order to attach to to the lm. Okay, I'm pass here the multiply tool. And now let's create here
multiply tool. And now let's create here another tool in order to allow the lm to perform a set to the web. Okay. And pass
it a value to let me pass here like this. And you can see here let me
like this. And you can see here let me yeah you can see in here guys we pass here the query okay is the inputs and
then we pass it a valal invoke in order to to invoke the valley and you can see the name of the tool is the valley search and the description is search the
web using the valley to find real time information okay and here for the description don't pass a message like let's say
empas search the web and you have to consider that the description here is like a prompt okay you have to be
specific okay like set the web set the web using safal to find real time information okay like this but also here we you can see we define here schema we
pass here the query and the type is a string okay and you can see for the multiply Here we pass here two inputs A
and B. Okay. Now we're going to try to
and B. Okay. Now we're going to try to pass here. Let's pass here to the tool
pass here. Let's pass here to the tool tali tool and we're going to prompt our lm and see if we the lm is going to call the tavali tool. Pass here this cause
results.
R result is equal to await here lm with tools dot invoke here. And then we going
to pass here let's say row user. And
then I can pass here the contents and say what is the current weather in New York. Okay, New York. Okay, like this.
York. Okay, New York. Okay, like this.
And then let's see what we're going to get. Now let me wrap that into array to
get. Now let me wrap that into array to get rid of the error. And now let's try to pass a console.log. and we're going to pass a result and see if we the AI
the LLM is going to call the tool. Now
let's run this. I'm tap here this note source for/tools.ts and let's check here if you're going to call the tool here. Okay, you can see in
here guys we have here a tool core. You
can see okay if we scroll down all the way to the bottom here you can see two calls and you can see the name of the tool the L&M core is Taval search you can see the query current weather New
York okay now I'm going to create here a chain I'm going to do this pass chain yeah pass I'm going to name this chain
okay and here we're going to pass here to chain and pass here to chain okay like this yeah two chain And we're going to pass here. You can see in here we
have a function runnable lambda in order to create a runnable. Okay. And what I'm going to do, I'm going to go here and pass here runnable runnable lambda like
this. That from and we're going to pass
this. That from and we're going to pass here a function. Pass a sync here. A
sync. We're going to pass here the user input. Okay. And then we going to pass
input. Okay. And then we going to pass here cons. We going to pass here this.
here cons. We going to pass here this.
Okay, you can see we pass here message pass the we pass into the human message instance. Okay, and then pass a message
instance. Okay, and then pass a message that chain that invoke. Okay, and here
we are going to pass here to a message a wait batch. Okay. And here I didn't
wait batch. Okay. And here I didn't explain about batch here. You can see when talking about runnable here you can
see we can pass here this runnable. Let
me comment this. You can see in order to call a runnable we use the invoke function. Okay. And here we can use the
function. Okay. And here we can use the invoke function in order to pass only one input. Okay. But what if we use here
one input. Okay. But what if we use here the batch? Okay. If we use batch we're
the batch? Okay. If we use batch we're going to pass here an array of inputs.
Okay. But pass hello and pass here I can pass here I can pass here dog pass here banana you can see we can pass here an
array of input okay and once we call that you're going to see what we're going to get and pass here runnable to you're going to see we're going to have
here they're going to convert all of these inputs to uppercase okay you can see runnable two we have here runnable two here Okay, now let's run runnable to
here. Runnable like this the TS and then
here. Runnable like this the TS and then we're going to run this. You're going to see we have here hello in upper case, dog in upper case and banner in upper
case. You can see we can use here batch
case. You can see we can use here batch function in order to pass the runnable multiple input. Okay. And here if we go
multiple input. Okay. And here if we go back into the tools the TS5 you can see in here we pass here runnable lambda in order to convert that function into a
runnable okay and then we pass the human message and then a message and here pass chain invoke this the chain here okay is
the lm with tools and then here let me comment this right now and then here we pass here the human message okay to the lm Okay. And once we call the llm here,
lm Okay. And once we call the llm here, we're going to inside we're going to have here an AI an [clears throat] AI object. Okay. You can see every time
AI object. Okay. You can see every time we call the AI, we have an we have an AI object. Okay. And inside of this AI
object. Okay. And inside of this AI object, we have here this property tool course. Okay. And then here we're going
course. Okay. And then here we're going to pass here the tool AI.
Okay. And once we run this we are going to perform a web set. You can see pass here tavali. Okay. Tavali is at the top
here tavali. Okay. Tavali is at the top here is this instance here. And then we pass here tavali.batchai
ai message.
And here we're going to have here the two message. Okay. Now let's try this
two message. Okay. Now let's try this and see what we're going to get here.
Pass a console to message. Okay. Like
this. And later run this runnable here and cop it and then pass a console results is equal to await and pass here
to chain invoke and here we're going to pass it an input user input and pass user input. Yeah, let me pass here user input. Yeah, we're going to
pass here what is the current weather. Let let me copy this. Yeah, I'm going to copy this.
copy this. Yeah, I'm going to copy this.
What is the current weather in New York?
And now let's see what we're going to get here. Okay, this. And then we're
get here. Okay, this. And then we're going to see the result here and pass here. Yeah, I'm going to remove this.
here. Yeah, I'm going to remove this.
Okay, now let's see what we got in here.
And here I'm pass here to console ai message. Okay, like this. And then I'm
message. Okay, like this. And then I'm pass here a message like this. Now I'm
going to run this.
And here I'm passing towards the TS.
I'm going to pass here this. Okay, I'm
pass here an array like this. And then
we're going to pass a row. We're going
to pass user and we're going to pass the content and passing user input. Okay,
like this.
Yeah, we are going to wrap that into an object like this. And then we're going to remove the error. And then I'm going to comment this line and pass here is
any to remove this typing error. And
we're going to cancel this. And now
let's run this and see what we're going to get. Okay. Okay. Yeah, you can see
to get. Okay. Okay. Yeah, you can see actually got the data here. You can see this is the AM message. Okay. Is an
object. And then we pass here. You can
see we have your tools. You pass am tool calls. And we got this array. And then
calls. And we got this array. And then
you can see the name of the tool that we are calling is the valley search. And
you can see the query is car weather in New York. And then what I'm going to do
New York. And then what I'm going to do in here I'm going to pass here constant.
I'm not defining a constant chain results. And we're going to pass here
results. And we're going to pass here weights. And you can see we have the
weights. And you can see we have the chain here. Yeah, you can see in here
chain here. Yeah, you can see in here we're going to pass here chain and pass here this. Okay. We're going to pass
here this. Okay. We're going to pass here chain invoke. Okay. And we're going to pass in array. And instead of it, we're going to pass in the row is the
user. We're going to pass here the user
user. We're going to pass here the user input. User input. Yeah, like this. And
input. User input. Yeah, like this. And
also we're going to pass here the AMS. You can see we have here AMS. I'm copy that. And then we're going to pass in
that. And then we're going to pass in here. And also we have the two the two
here. And also we have the two the two method. Okay. And this is an array. Now
method. Okay. And this is an array. Now
I'm going to copy this array here like this. And then we're going to return
this. And then we're going to return here the chain results. Okay. And pass
here return. We return the chain results. And here we're going to pass
results. And here we're going to pass here the two message like this. Okay.
Yeah. Everything is okay in here. Yeah.
Like this. Okay. We get rid of the error. And you can see as we pass here,
error. And you can see as we pass here, what is the current weather in New York?
And here right now the AI is going to surf the internet. Okay, because we just pass it a to a value. Okay, the AI is going to perceive its environments and
then it's going to say that on its environment it is a tool that allows it to go on the internet. Okay, and now let's run this and see what we're going
to get here and pass here consults here. pass here results da da da and I'm
here. pass here results da da da and I'm passing results and now let's run this and see what we're going to get.
Everything is okay in here. Okay, I'm
run this and you can see in here guys we got the current weather in New York City is mostly clear with a temperature of
665 60 okay and that's cool. We got the car weight right here. And if I pass here a question like what is two
multiply by 10? The AI is going to use the multiply to that we passed with. And
this how we can pass a two to the air in order to take an action.
All right guys, now we're going to be talking about lingraph. We just finished learning the basic of lang chain. We
talk about runnables. We talk about tools. We talk about prompt templates
tools. We talk about prompt templates and other thing guides. We learn a lot.
We got basics of link chain. Now let's
talk about lingraph. At the beginning we said lang graph is a framework built on top of lench chain and langraph allows
to create an airway flow. Okay. And you
can see as I said before and an airflow is composed by set of nodes and ages.
You can see in here we have two graph.
This the first one and this the second one. And for the first graph here we
one. And for the first graph here we don't have a conditional age. You can
see when we're going to run this graph we're going to start at the beginning with the starting node. We're going to run the node A, the node B and node C.
And then we're going to eat the end nodes. And these nodes are basically
nodes. And these nodes are basically functions. Now we have here in our graph
functions. Now we have here in our graph where we have a conditional H. Here
we're going to start with the starting node we going to eat the node A and then inside the the node A where as we have a condition H we can transition from the
node B or C and then we're going to eat the node D and then we're going to move to the end node and this is a graph.
Okay, now let's learn how to implement a graph using lingraph. Okay. Now you're
going to tap here link linkchain.com/lraph
linkchain.com/lraph and then you're going to pull your cursor here. You're going to select here
cursor here. You're going to select here langraph. Okay. You can see we have here
langraph. Okay. You can see we have here for python and for javascript. You're
going to click here lang graph. Okay.
Once you click in here they're going to take you to the page here. And then
we're going to copy a boiler plate of a graph. Okay. Now let's head into the
graph. Okay. Now let's head into the source folder. And then here I'm pass
source folder. And then here I'm pass here len graph. Okay. I'm pass graph.ts and then I'm going to put in this code.
Okay, we already install lang graph.
Okay, lang. Yeah, we already install lenchen. And as we already install
lenchen. And as we already install lenchen, we're going to have here to lingraph. Okay, now you're going to copy
lingraph. Okay, now you're going to copy this boiler plate right here. And then
we're going to create this graph right here. We're going to start with a graph
here. We're going to start with a graph where we don't have a conditional age.
And then we're going to learn how to create a graph where we have a conditional age. And now let's start
conditional age. And now let's start here. Now you can see I just import here
here. Now you can see I just import here and start state graph in annotation. We
import all of these property from ling graph. Now what I'm going to do here I'm
graph. Now what I'm going to do here I'm going to explain you everything in here guys. Now we going to learn how to
guys. Now we going to learn how to define a state. You can see pass here state annotation. Annotation that's
state annotation. Annotation that's root. We pass here an object and inside
root. We pass here an object and inside of it we have aggregate. Aggregate.
Aggregate is a property and that's what we call a state here. And if I want to define here another state I can pass here I'm pass here current node and then
I'm passing annotation. I'm pass here the value. It's going to be a string.
the value. It's going to be a string.
And if I want to pass here default value I'm going to pass here property and pass default. And here we are going to return
default. And here we are going to return here this and pass here an empty string.
Okay. And you can see here when we define here a state we can pass we we pass it into the annotation that's root function. Okay. And then here we are
function. Okay. And then here we are going to pass here annotation and you can see I just type here the the value of the current node state. And then the default value is going to be empty. And
we have here another property which is the reducer. A reducer allows to modify
the reducer. A reducer allows to modify the value of the state. Okay. And here
we have here the previous value and pass here previous val. And we have here the next and pass the next val. Okay. And
here we're going to check if if the pre if the previous file we have a value.
We're going to return here.
We're going to return here the previous value and pass a previous value. Else we
are going to return here the next value.
Okay, you're going to understand it later guys. Now let me give you the
later guys. Now let me give you the definition of a state. Okay, a state it allows it allow us to and it allows it
allow us okay to know and pass here. It
allow us to know on which on which node I'm passing which node we are okay like this. This the first definition and we
this. This the first definition and we can use a state to store
we can use a state here to store value inside of it. inside of it. Okay. And
yeah, we just define here state and we have here United States which is aggregate. Okay. Now, let me define
aggregate. Okay. Now, let me define United States here. I'm name it next node. Pass here next node. Okay. Next
node. Pass here next node. Okay. Next
node. And we pass here default value is going to be a string. Okay. And we have a previous value and the next value. I'm
going to define United States which is users. Yeah. Let me remove this one.
users. Yeah. Let me remove this one.
Yeah. I'm pass here users. Okay. Here
we're going to pass a user. We're going
to put in an array of users. And I'm
pass here this. And then I'm going to say default value is going to be an array here. And then I can pass here
array here. And then I can pass here this we have here the previous value.
Previous value concat here. And I'm
passing here. We're going to pass in the next value. Okay. And it works like this
next value. Okay. And it works like this for the reducer. Let's say for the previous value here we have here empty
array okay and if we have data the if we pass data okay let's say we pass Ben okay we are going to take here the previous the previous value which is an
named array and then we're going to pass here concat we going to add in Ben okay the array is going to looks like this okay Ben like this and we can do this
here if I pass here something like response uses and I pass here an empty array. Okay, pass an empty array. If I
array. Okay, pass an empty array. If I
pass user concat and I pass here Ben here, we're going to have Ben inside the array. Okay. Yeah, I'm pass concat.
array. Okay. Yeah, I'm pass concat.
Yeah, let me see here. Pass concat like this. And let's check here. Concat like
this. And let's check here. Concat like
this. Yeah, you can see we have here Ben. Okay. And again if you pass here we
Ben. Okay. And again if you pass here we push another value when we are going to visit let's say in here guys on on the
node A we pass here a value Ben and then here on node B we pass here Chris and we're going to take this array here we
are going to start on node A we're going to have here Ben like this we on node A we are going to have here an empty array we're going to push in Ben when we are
going to move to the next node, we're going to have something like this here.
Put a passive band and then we're going to have increase. Okay. Now, we're going to see how it works in practice. Okay.
Now, I'm going to unccomment the aggregate state here to remove the error. And if you want to work with
error. And if you want to work with JavaScript, you can just remove this tab script here and it's going to works the same. Okay. Now, I'm going to start
same. Okay. Now, I'm going to start here. Yeah. I'm pass here node A. You
here. Yeah. I'm pass here node A. You
can see we have here some node node A, node B, node C, node D. Okay. And we
pass all of these node here to the graph to construct the graph. And we have here some edges. Okay. We are going to move
some edges. Okay. We are going to move from node A to B, from A to C. Okay. And
here this graph looks like this. A to B, A to C. Okay. And then B to D. Yeah.
This graph looks like this one here.
Okay. And I'm going to simplify it.
We're going to pass in only three. We're
going to pass only three notes. A B C.
Okay. And here I'm going to pass A B C.
And get rid of the the D not node here.
A B C. And here we're going to pass this. We going to move from A to B, from
this. We going to move from A to B, from B to C and then from C to to N. Okay.
And if we put our cursor over the end property right here, it returns here end. Okay, this is the end node here.
end. Okay, this is the end node here.
Okay, this the end node. But also you can see we have a starting node here.
And that's what we pass here. Start.
Okay, let me pass here. Edit tab here like this. Yeah, like this starts. Yeah,
like this. Yeah, like this starts. Yeah,
let me pass. Yeah, this an edge. Okay.
Okay, we're going to start here. starts
and then from the starting node we are going to start with the node A from A to B from B to C from C to end okay and now
you can see in here we pass here the node A let me pass here something we going to pass here you can see in here in order to update the state we pass
here we pass we pass here users okay is array and then I'm pass here Ben okay and then when we going to move to the node to the node B. We're going to pass here
Chris. Okay, and pass here Chris. And
Chris. Okay, and pass here Chris. And
then when we're going to move to the node C and pass here Isaac. Okay, Isaac
like this. And then we are going to you can see in here pass here. We pass here.
We copy the graph here. And then we invoke the graph. You can see we going I'm going pass here. I'm going to initialize the user array. Okay. And
then we're going to see what we're going to get here. Now let's run this. And
here I'm pass here node. And we're going to pass here source. And gra I'm passing graph. Okay. And that ts. And if we run
graph. Okay. And that ts. And if we run this, let's see what we're going to get.
You can see in here we have here current node here is empty. Next node empty. But
for the users here, we have here Ben.
Okay. But we don't have here. Yeah. We
don't pass here this. Yeah, we should pass here. We should pass here users
pass here. We should pass here users because we want to update the user state. Okay. Yeah. Oh, yeah. We are
state. Okay. Yeah. Oh, yeah. We are
going to run this again. You're going to see we're going to have here. We're
going to have here Ben, Chris, Isaac.
Now, let's move here in order to understand how the reducer property work. You can see in here we have here
work. You can see in here we have here users. A users is array. We pass
users. A users is array. We pass
annotation and we pass default values array and here I'm going to pass here this okay and here I'm pass here if
we're going to pass here I'm pass I'm going to return here this okay and then here I'm pass here console log preva
okay I pass a previous value and pass a previous file log this. Let me copy that. And then we're going to pass it
that. And then we're going to pass it here. And I'm passing console.log
here. And I'm passing console.log
next var. Okay. Yeah. Like this. I'm
passing next var. Okay. Now, let's run this again here and see what we're going to get. And here you can see we have
to get. And here you can see we have your previous val is an empty array.
Next v empty array. And now when we start visiting the node A here, when we start visiting the node A, we push in
Ben. Okay. And then here you can see
Ben. Okay. And then here you can see here the previous value becomes Ben.
Okay. Now the next value is Chris. And
then we we use the concat function in order to add Chris to the array. Now the
previous value becomes here Ben and Chris. Okay. And then next value is
Chris. Okay. And then next value is Isaac. And that's how it works. And you
Isaac. And that's how it works. And you
can see in here guys they reduce property. It allows to to to track the
property. It allows to to to track the previous value. and the next value of a
previous value. and the next value of a property okay of a state. Now let's
create here a conditional age. You can
see that actually we are dealing with this face graph here. Now we're going to pass here a conditional A to the node A.
Okay. And we are going to create the node D and from the node A we're going to decide if we can transition to the node B or C. Now let's learn how to do it. Now I'm going to create here node.
it. Now I'm going to create here node.
We're going to pass in node D here and pass node D. And we're going to pass here node D guys. And then we're going to pass here add conditional age. And
here I'm going pass the node where we want to put in a condition. Okay, I'm
select here a and then I'm pass here this state like this. And we can just copy this. You can see pass here a
copy this. You can see pass here a function. Okay, this function we can
function. Okay, this function we can name it as a router. Okay, I can just copy this code here. And then I'm pass
rather. Okay, like this. And we can we
rather. Okay, like this. And we can we can just pass you this router. Okay,
like this. And now in here I'm going to pass here condition and pass if state uses includes here and pass include John
and pass it John. We are going to return here the node B and
if state pass if pass again if state uses include and pass includes pass here Chris we're going to return here the
node C okay and pass here return C yeah like this else we're going to return here the end node okay and pass here end
like this or we can just pass here ends like this. You can see and here is a
like this. You can see and here is a constant. We can copy this even this. We
constant. We can copy this even this. We
can pass even this. And now we're going to try this. Okay. You can see actually I'm going to pass something. We just add
here a condition a conditional note here. And you can see actually just
here. And you can see actually just [clears throat] pass to the node a condition. And now pass here console.log
condition. And now pass here console.log
log and pass here node A like this and pass a node A. We going to copy this and then I'm pass it here node B. We are
going to check if we're going to move to the node or to the node here and pass here node. We're going to pass a node C.
here node. We're going to pass a node C.
Yeah, node C. And here we're going to pass here node D. Okay. Node D. Okay.
Now, let let me check here something.
Yeah, we we pass a condition. Okay. And
then we can transition from node B or C.
And then we're going to move to the node D. Okay. And here what I'm going to do.
D. Okay. And here what I'm going to do.
I'm going to go here. You can see in here we just pass here a router. Okay.
We going to check if inside the users array we have a drone. We're going to move to node B. If we have a crease, we're going to move to node C. Okay. And
then from node from node B we can transition to D. Okay. And from node C we can transition to D. Okay. Now here
what I'm going to do I'm going to pass here from node C you can see from node C we can transition to D here. And from
node I'm copy this again. We're going to pass it from node B we can transition to the node D. Okay. And then from node D
here we can eat the end node and pass here end like this. Or we can just pass here the end constant and pass here this end. Okay. And now let's try this and
end. Okay. And now let's try this and see what we're going to get. I'm going
to yeah let me run this and see what we going to get here. Okay. Now I'm type here and run this and see we're going to
get. Yeah, you can see node A, node B,
get. Yeah, you can see node A, node B, node C, node D, node D. Okay. Yeah, let
me let me first remove here something.
You can see this node D. Okay. I'm going
to remove that here.
Okay.
Okay. Now, let's run this again and see what we're going to get here.
Okay. Yeah. Node A B C. Okay. You can
see we move here node A B C. Okay. Yeah,
we moved here. Now what I'm going to do, I'm going to You can see in here we pass here an H from A to B. From B to C.
Okay. Now I'm going to comment this from A. Yeah, I'm not comment because we just
A. Yeah, I'm not comment because we just add here a router. Okay. A conditional
age. Okay. From C. Yeah, let me check here. From we can move from B to D and
here. From we can move from B to D and pass here from B pass here from B to D.
Yeah. Yeah. Copy this and then from B to D and from C to D. Okay. Yeah. We come
in this and we going to use the the route here as a bridge to move to the node D. Okay. And now let's run this
node D. Okay. And now let's run this again and see what we're going to get here.
Okay, we have here node A. We don't
transition here. Let me see. Node A and then here. Yeah, we don't have here
then here. Yeah, we don't have here John. Let me pass here John. Here we
John. Let me pass here John. Here we
have Yeah, we have here Chris like this.
Let me pass here Chris in lower case here. Okay, Chris.
here. Okay, Chris.
Yeah, I'm going to start here. Let me
pass here John like this and see what we're going to get here. Let me run this again. Okay, run this. Yeah, you can see
again. Okay, run this. Yeah, you can see node A, node B. Okay, we move from node A, node B and then we are going to
transition to node D. Okay, now inside the node D and pass in something like console and pass here console
log and pass here D like this. Yeah, if
you run this again, you're going to see you're going to see something here. Node
A B D. Okay, you can see in here we move like this node A B D. Okay, because here the inside the users array we have here
John. Okay, now let me pass here.
John. Okay, now let me pass here.
Let me pass here Chris because when we're going to start running the node A, we are going to add in Chris immediately. Okay, let me pass here
immediately. Okay, let me pass here Chris and see who we are going to get here. Okay, now let's run this again and
here. Okay, now let's run this again and run this. Okay, we're going to have here
run this. Okay, we're going to have here A B A C D. You can see in here we have
here A C D and then D it's the end note.
Okay. And guys, in order to understand this, you need to practice. Okay, you
need really you need to practice in order to understand this. All right,
guys. Now, let's talk about rag. RAIN
for retrieval augmented generation. Rack
is a technique that lets enhance the model's generation by providing the relevant information from an external memory. The external memory can be an
memory. The external memory can be an internal database or an external database. It can be the user's previous
database. It can be the user's previous CH session or the internet. In the world rack, we have three words. We have
retrieval which is the retrieve data that we can extract from an internal database. We have the word augments
database. We have the word augments which we we have the word augments is when we're going to take the retrieve data and then we're going to pass it to the LLM. We're going to augment the LLM
the LLM. We're going to augment the LLM and then the LLM can use this retrieve data in order to generate a response based on it. Now you know LLM are
trained on huge amount of internet data.
So LLM becomes genius. You know if we ask Charpt a question like what is JavaScript charge GPT is going to respond immediately because he was
trained on the JavaScript documentation.
But what if you ask Charpt about something he wasn't trained on? Like
who's Maurice the dragon? Let's say
Maurice the dragon is an actor is a new actor but information of Maurice the dragon doesn't exist on the internet.
Here Chip PT is gonna try to figure out what who is Maurice the dragon but eventually Chip P is going to f because data of Maurice the dragon is not on
internet now these are kind of limitation that rag tried to address this it's like we are going to give the LLM another tool a power to get access
to extend the resources and when we talk about extend the resources we have an internal memory or an external memory or
the internet. Now, as the LLM doesn't
the internet. Now, as the LLM doesn't have access to the internet data and the LLM doesn't have the possibility to get access to extended resources or
internal, we are going to give the LLM this possibility and then the LLM is going to be [clears throat] again genius. Okay, because we're going to
genius. Okay, because we're going to give the LLM the possibility to get access to extend data sources or internal data sources and these are kind
of limitation raviceses.
It allows to augment the LLM. Now let's
take a look to this diagram of a rag app. You can see we have here some steps
app. You can see we have here some steps that we need to go through in order to give the LLM data. Okay. Now for the first step we need to store data into a
vector database into the database. Now
you can see we have here the user the user first of all in order a use start using a rack system the user needs to provide the data to the lm. Now we have
here the user can import into our rack system external data or internal data.
This data can be PDF web pages and other stuff. And then we are going to take this data on the step two. We
are going to split it into chunks because a lot of large language model has a contest window. You know a contest window is the amount of data that the
LLM can process in one go. Let's say
here you can see we have here a model.
An embedded model is a machine learning model. This embedding model can have a
model. This embedding model can have a limit of 32k tokens that can process in one go. But what if we pass it
one go. But what if we pass it more tokens more data let's say we pass it for 40 token the LLM is going to fail
and we're going to get an error. Now
once we take this data we split it into chunks we going to convert it into embeddings. Embeddings are numerical
embeddings. Embeddings are numerical representation of these chunks of the used data because we're going to take this data we're going to split it into chunks and then we're going to pass it
to the embedding model. The embedding
model is going to convert it to numbers and these these numbers we call embeddings that we're going to store into the vector database. A vector
database is a database that store a numbers. Once we store data into a our
numbers. Once we store data into a our rack system, it time to query our rack system. And here we have another step.
system. And here we have another step.
On step six here, the user can start now quering our rack system because it is data. Now the user can send the query
data. Now the user can send the query and then we're going to pass it to the LM. On step seven, we have here another
LM. On step seven, we have here another component of a rack system which is a retriever. A retriever is a component
retriever. A retriever is a component that basically retrieve data into a vector database. You can see on step
vector database. You can see on step seven the LLM make a query to the retriever and then the retriever retrieve data into the vector database.
And once we have the data into the retriever, we're going to pass the data to the LM. And then the LLM can use this data. And then the LLM can use this data
data. And then the LLM can use this data in order to generate a response to the user. And we're going to pass to the
user. And we're going to pass to the LLM, the retrieve data, but also the user question so that the LM can generate a good response. And that's how
a rag system works. Now, we going to talk about some main component of a rag app. We have here a retriever and
app. We have here a retriever and generator. Now a retrieve as I said
generator. Now a retrieve as I said before is basically a component that allows to retrieve data into a vector database.
And here you can see we have here the user question. We're going to take the
user question. We're going to take the user question we're going to embedding.
We're going to pass it to an embedding model. An embedding model is a machine
model. An embedding model is a machine learning model that converts the data into numerical representation. And then
we are going to take this embeddings because in here we have embeddings.
Embedding are simply numbers of this question. Okay. And then we're going to
question. Okay. And then we're going to take these embeddings. We're going to pass to the vector database in order to perform similarity search. And once we perform similarity search inside the
vector database, we are going to get an array of documents. Okay. And then we're going to pass the model in order to generate the response. and we run the
generation phase. Yeah, you can see and
generation phase. Yeah, you can see and then we're going to have the final answer. And that's how a rack system
answer. And that's how a rack system works. Now, we're going to jump into the
works. Now, we're going to jump into the practice in order to learn more about that. Now, in order to store data into
that. Now, in order to store data into Victor database, we need to run through some steps. The first thing we need to
some steps. The first thing we need to do is to guide the once we already got data, we are going to split the data into chunks. And then we're going to
into chunks. And then we're going to take these chunks, we're going to pass it to the embedding model. The embedding
model is going to convert it into embeddings. and we're going to pass
embeddings. and we're going to pass these embeddings into a vector database.
Now, we're going to need an embedding model provided by Coher. You're going to type cohhere.com/rank.
type cohhere.com/rank.
And once you land on the homepage, you're going to click sign in to create an account. And once you create an
an account. And once you create an account, they're going to take you to the dashboard and you're going to click here API key and then move here. You're
going to click here new trial key to create to create a key. Okay. Once you
finish creating your key, you're going to get into your MV file. You're going
to pass in here co here API key. Yeah.
And also we're going to need a vector database. You're going to type pine cone
database. You're going to type pine cone vict db. You're going to see this.
vict db. You're going to see this.
You're going to click here. And once you move to the pine cone landing page, you're going to create an account. And
once you create an account, they're going to take you to the dashboard again. And in here, we're going to
again. And in here, we're going to create an index. An index is a database.
Click here create. And then pass here the name of your vector database. and
choose here a vector database provided by Nvidia. Okay. And then here once you
by Nvidia. Okay. And then here once you click here you're going to scroll a little bit.
You're going to see in here at the bottom if I pass it the name of a ve database. You can see that actually I've
database. You can see that actually I've I have the possibility to create database. You're going to click here
database. You're going to click here create. And once you click create
create. And once you click create they're going to take you to the indexes page. And the indexes are my database.
page. And the indexes are my database.
Okay. You can see I have here notebook.
Now get into the API key. In order to get an API key, you can create it here.
And if I head into my v file, you can see I pass the pine API key, but I also pass the pine cone index. Okay, do that.
Now you can see in here I just import some package in order to process data. I
import here the documents, the document class. We're going to use the document
class. We're going to use the document class in order to create an array of documents. I import here the recursive a
documents. I import here the recursive a recursive car text splitter from lench chain. We're going to use that class in
chain. We're going to use that class in order to split an to split a document into chunks. You can see once we got
into chunks. You can see once we got data here we need to extract the data and then we're going to convert the data into an array of documents. And this
array we're going to pass it to the embedding model in order to convert it into embeddings. that what we're going
into embeddings. that what we're going to pass to the ve database and you can see I import here the document class the recursive charact splitter to split the
data I import here coe embeddings to have embedding of the splitting data and then we import here the vector database to is where we're going to store the
data and we have here chio webbased loader in order to extract the data from a web page and I import here to the data in order to get access to our
environment main variable. Now I create here another function web embedding.
We're going to pass it a page that we're going to use in order to extract data.
And here the first thing in order to store data into the fake database, we need to extract the data from a web page or from a PDF. Okay. And once we extract
data, we're going to have here an array of documents. Okay. You can see pass
of documents. Okay. You can see pass here Chile web loader. We're going to pass it a URL. And then we're going to get here an array of documents. And once
we got an array of documents, we're going to pass it to the recursive karatic splitter in order to split it into chunks. And we're on this stage
into chunks. And we're on this stage here, the second stage here. For the
first one, we extract data. And then we move to the step two where we are going to convert the data into chunks. And you
can see I pass here recursive. You can
see in here pass recursive character. I
pass the chunk size of 500 and chunk overlap of 200.
Now you can see in here we pass the chunk size but also we have the chunk overlap. Let me explain you that. I'm
overlap. Let me explain you that. I'm
going to move here. Let me move here. We
have here a PDF and we're going to take this PDF. We're going to split it into
this PDF. We're going to split it into chunks. You can see in here pass here
chunks. You can see in here pass here the chunk size is 500 and the chunk overlap 200. The ch overlap we use it in
overlap 200. The ch overlap we use it in order to to preserve the meaning to preserve the context of a document.
Okay, of the splitting documents. Now
you can see in here we have a PDF. We
are going to take the PDF we're going to split it into chunks. You can see inside of the PDF we have hello can you explain me hello Ben can you explain me what is
a database and here you can see I pass here hello Ben can okay and then we pass here
can you explain the chunk overlap is when we take a pieces of previous chunk we pass to the next one you can see we have here only the second chunk here we
have can you explain we take explain we pass to the next chunk and then we have here explain me what is then we're going to take what is we're going to pass to the next to the next chunk in order to
preserve the meaning but what if I remove here this let's say I remove here what is we're going to have something like a
vector DB because I don't take here the piece of the previous chunk okay we're going to lose the meaning and here I can
save This we empas we use ch yeah yeah ch overlap to preserve
to preserve to preserve the meaning the meaning of the chain okay is when we take a piece of the previous chain okay and then we pass to the next one and
once we split the data we are going to to convert it into embeddings we're going to pass it to the coh embeddings And then we are going to take this embeddings. We're going to pass to the
embeddings. We're going to pass to the vector database. You can see I pass here
vector database. You can see I pass here I create here an instance of pine cone.
I pass the API key process. Pine cone
API key. I pass here pine cone index which is the name of our database here notebook alarm. And and then here we
notebook alarm. And and then here we pass here new pine cone store. We pass
here this embeddings. And then here we're going to call a function vector store. add documents and then we're
store. add documents and then we're going to store these embeddings into the ve database. Now I'm going to pass here
ve database. Now I'm going to pass here I'm going to invoke the web file embedding. We're going to invoke the
embedding. We're going to invoke the function by passing it a web page and this web page talks about prompts engineering. We are going to store all
engineering. We are going to store all of this data here into our database. Now
what I'm going to do I'm going to run the file and run it. We're going to pass here node source injection pipeline TS.
And once we see the message here, finish indexing, we we are going to know that we already store our data. We already
store this data into the vector database. Now let's see what we're going
database. Now let's see what we're going to get in here. If we see a mess here, it means we store data into the vector database. Okay. And yeah, you can see we
database. Okay. And yeah, you can see we have mer finished indexing. Okay. We
store this data into the vector database. Now we're going to create the
database. Now we're going to create the retriever in order to start quering our vict database. I'm going I'm going to
vict database. I'm going I'm going to import here the document the recursive katic splitter the coh embeddings pine con store. You can see in here we define
con store. You can see in here we define a function query vector DB pass the query. We instantiate here a coher
query. We instantiate here a coher embeddings. Pass here the model, the API
embeddings. Pass here the model, the API key. Pass here pine con store, pine cone
key. Pass here pine con store, pine cone index and the vector store here. And you
pass here pine con store that from existing index. Pass the embeddings and
existing index. Pass the embeddings and the pine cone index. And then here we are going to pass here vector store similarity search. We're going to pass
similarity search. We're going to pass you the user query. Now I'm going to pass here query. I'm going to start creating a database and see what we're going to get and pass a con result.
Okay, like this and pass here wait and then we're going to pass here what is prompt engineering engineering and we're going to get here an array of documents.
Let's see console.log and pass here.
Yeah, we're going to pass a console.log
result. Okay, now let's run the retriever and see what we're going to get. I'm pass here this source for slash
get. I'm pass here this source for slash retriever.ts.
retriever.ts.
Okay, we're going to get here an array of documents. Okay, these are the
of documents. Okay, these are the splitting chains. Okay, now let's see
splitting chains. Okay, now let's see what we're going to get here. Okay, you
can see that actually we got here an array of document. Okay, you can see we pass here the query what is prompt engineering. Okay, and you can see this
engineering. Okay, and you can see this is a document. Okay, we got an array of documents. Okay, we have here the page
documents. Okay, we have here the page contents, the metadata. Okay, inside the metadata, we have the source here and the title of the page. Okay, and we have here a little definition prompt
engineering also known as incontest prompting refers to the method for how to communicate with LLM. Okay. And here
we have here another documents. These
are the chunks. Yeah. And you can see in here guys for for the the you can see in here the first document here is different from this document here is is
so different guys. You can see for the first documents we have here a lot of data but for this document we don't have a lot of data here. You can see we have
here free line but for the first one we have here more than three line. And
yeah, now we're going to try to create a document. You can see when we create a
document. You can see when we create a ve database, it returns an array of documents. Now to create a document, we
documents. Now to create a document, we can use the document class here. Okay,
something like this. I can pass here con do array like this. And then I can pass here is equal to no is equal to array and pass here documents. We can pass
here the page content. can pass here something. Okay. And here I can pass in
something. Okay. And here I can pass in the meta data. M data. And inside the metadata we can pass in the title, the
source, pass the source. Okay. I pass I can pass it the page number and other stuff guys. And this how you can use the
stuff guys. And this how you can use the document class, the document class in order to create a documents, an array of documents. Okay. If I duplicate it,
documents. Okay. If I duplicate it, we're going to have here two documents.
pass here this can see actually have here two documents and if I console here cons log I can pass a doc array and here we're going to have an array of
documents now let's see again and run this you're going to see what we're going to get if I run the retriever we're going to have here an array of documents okay now let's wait a bit you
can see we got here an array of documents and you have to know when you going to query a vict database you're going to get an array array of document.
Okay, this result here is an array of document. You can see if we put our case
document. You can see if we put our case over the result constant, they infers it to be a type of document interface.
Okay, and it is the key and value. You
have to know that. And if we head into the pipeline, the TS and when we extract data into with the Cheio web loader, we
pass here loaded. Okay, we have here an array of documents. As you can see paras over the do constant. We have here an array of documents. Then we're going to take this array of documents. We're
going to pass to another class which is the recursive car text splitter.
[clears throat] In order to split it into chunks. Okay, you can see pass here
into chunks. Okay, you can see pass here splitter split documents. We're going to convert it into chunks. And once we have these chunks, we're going to pass it to
the embedding model. And then we can start quering our vector database in order to get data. Now I'm going to pass here query. I'm going to remove this and
here query. I'm going to remove this and pass here ts of prompt engineering.
Okay. Or I can just pass here what is few shots. Pass here what is few shots.
few shots. Pass here what is few shots.
Now let's see what is few shots like this. Let's see what we're going to get
this. Let's see what we're going to get from our vic database.
And then I'm going to run this again and see what we're going to get here. We're
going to have here an array of documents. Okay. Now let's wait a bit
documents. Okay. Now let's wait a bit and see what we're going to get. Yeah,
you can see again we got here an array of documents. Okay, this is the first
of documents. Okay, this is the first dog, the second one, we have here the third one and the fourth and so on. And
you can see few shots learning few shots learning present. Okay, we got here this
learning present. Okay, we got here this data. Okay, and also we can pass here
data. Okay, and also we can pass here another method. You can see in order to
another method. You can see in order to query our vector database we invoke the similarity set function. Now I'm going try to invoke here another function
which is I'm pass retriever. Okay,
vector store is retriever. And then you can pass here this retriever like this.
And then pass here consult is equal to await and pass here retriever invoke.
Okay. And then we can pass here the user query. Okay. Like this. And we're going
query. Okay. Like this. And we're going to get the same thing.
Now I can I can run the retrieve again and we're going to get data that we're going to pass to the LLM and once we pass the data to the LM we are going to generate a response based on the user
query. Okay, you can see again we got we
query. Okay, you can see again we got we have the same thing. Okay, now let's talk about a generator. We already
learned how to store data into a vector database but also we learned how to retrieve data into a vector database.
Now we're going to create another file which is the generator generator. Yeah,
generator.cs.
Now we're going to pass you some package here. We're going to import here some
here. We're going to import here some package. We import here the am system
package. We import here the am system message. We import here the prompt
message. We import here the prompt template the chat prompt templates and also import here zord to JSON schema. We
we already learn about all of these pages guys. Now you can see in here I
pages guys. Now you can see in here I just changed the model. I pass here chat fireworks. Previously we used to get our
fireworks. Previously we used to get our AI. Okay, we used to get our AI. If I
AI. Okay, we used to get our AI. If I
move at the top here you can see we have here chat to get AI. If you want you can change the motor. You can see previously I show you that in here langraph provide
us the possibility to use different models and here if you want you can use bedrock chart you can use chat anthropic you can pick a whatever model you want
guys. Okay, here you can see I pick here
guys. Okay, here you can see I pick here chat fireworks and when you try to pick a model, you have to make sure this model is support all of these features
here. You can see streaming JSON mode to
here. You can see streaming JSON mode to calling with structured outputs multimodal. Okay, you can see here if I
multimodal. Okay, you can see here if I scroll at the bottom here chat fireworks it supports all of this feature and if I pass here together AI 2 supports all of
these feature you can see chat together AI supports all of these feature. Try to
pick a model which supports mostly all of these features listed here guys.
Okay. And yeah, I pass here this. Okay.
Chat fireworks. If you want to use chat fireworks, you can go, you can tap a fireworks.ai. And then you're going to
fireworks.ai. And then you're going to create an account. Get into the model library. And then you can pick a model
library. And then you can pick a model you want. If I want, I can pick even
you want. If I want, I can pick even deepsee and then I'm copy this. And I'm
going to pass it in here like this.
Pretty easy. Now, let's continue. Now in
here you can see we pass here the user query what is prompt engineering and we import here the query vector DB okay which is the retriever and we import it
from the retriever that okay and pass here let's run this and see what we're going to get here console.log log. We're
going to have here an array of documents and pass here results. And if we run this, we're going to have here an array of documents. Okay, I'm going to run
of documents. Okay, I'm going to run this. Now, let me go first into the
this. Now, let me go first into the retriever. And then I'm comment this.
retriever. And then I'm comment this.
Okay. Let's go into the gener. We're
going to run it. Generator. TS. Okay.
And then, yeah, we got here an error and felt to yeah, f import retriever. Okay.
And pass the TS right now as we don't use. And then I'm going to run this and
use. And then I'm going to run this and see what we're going to get. Okay, going
to pass here this. We're going we going to retrieve data into the vector database. We're going to have here an
database. We're going to have here an array of documents. Okay, and once we got an array of documents, we're going to pick the first array. We're going to pass it to the lm in order to generate the response. That's what we're going to
the response. That's what we're going to do. Okay, you can see again we got here
do. Okay, you can see again we got here an array of documents. Now, we are going to move here. I'm going to get rid of this. We are going to I'm going to have
this. We are going to I'm going to have here something. Um I've already
here something. Um I've already explained you all of this and I'm pass it in here. You can see in here pass here prompt template that from template you already know that. Okay, we already
talked about that. And I pass here prompt you are an assistant. Let me read it a little bit. You are an assistant for question for question answering task. Use the following pieces of
task. Use the following pieces of retrieve contest to answer the question.
If you don't know the answer, just say that you don't know. Use free sentences maximum and keep the answer concise. And
we pass the question, but also the contest. The contest is the retrieve
contest. The contest is the retrieve data. And then pass here prompt.voke
data. And then pass here prompt.voke
which is runnable. And then we pass the user query. And we pass it the first
user query. And we pass it the first document. Okay, we're going to pass it
document. Okay, we're going to pass it that document here. Pass here results.
We select the first item that page content. Okay. And then we're going to
content. Okay. And then we're going to pass here the prompt. We're going to pass the prompt to the LLM. And then the LLM is going to generate a response based on the user query. You can see if
we take a look to the diagram, you can see we have here the same thing. We take
the question, we pass to the embedding model. They're going to embed it and we
model. They're going to embed it and we going to pass the vector database to perform similarity search. And once we have here data, we are going to pass the
data to the LM. You can see we pass the contest but also the user the user question and then we're going to have here an answer. Now let's try to run this and see what we're going to get
here. I'm pass here not source
here. I'm pass here not source for/generator.ts and then we're going to have here a response from the lm. Now let's see
again here what we're going to get.
Okay. Yeah. Again we have here the response. Okay. This is the AI message.
response. Okay. This is the AI message.
Okay. You can see we have here the response. Prompt engineering is the
response. Prompt engineering is the practice of designing and refining inputs to effectively guides large link models toward the outputs. You can see
now we're going to be talking about multiquery generation. Previously we
multiquery generation. Previously we learned how to retrieve data into a vector base using a single query and this can lead to a poor retrieval. You
know the user question can be too broad, ambiguous, too specific. the user
question sometime it can't align with the vocabulary of our documents. Now in
order to mitigate to this kind of issue we're going to use the LM in order to generate different questions. Now once
we have here these different question generated by the LLM we're going to use this question in order to retrieve data into the vector store. And here we're going to have here an array of
documents. And once we have an array of
documents. And once we have an array of documents, we're going to pass this array to a model which is a reranker in order to to rank these documents. And
then once we have here and then once we rank these documents with a model, we are going to pick a document which is high score. Then we're going to use the
high score. Then we're going to use the reciprocal rank fusion in order to combine in order to match the results of all documents which is a high score. And
then we're going to pass this data to the model in order to generate the response. Now in order to generate
response. Now in order to generate multiple query, we're going to use here prompt engineering technique which is stay back prompting. So stay back prompting is a prompt engineering
technique is when we tell the AI to think about the question in a general way. Now if you want to learn more about
way. Now if you want to learn more about pro step by prompting, you can come here. You can ask charge about step by
here. You can ask charge about step by prompting. Then charge it's going to
prompting. Then charge it's going to explain you how stepback prompting works. Now we're going to continue. I'm
works. Now we're going to continue. I'm
going to come here. We are going to use this prompt here. You are you are AI re you are AI assistant. The the user asked we're going to pass the user question
and then we're going to tell stay back and consider this question more broadly.
Reframe it in general terms. Identify the main themes or dimensions involved.
Generate five diverse search query that can cover these dimensions ensuring each query explores a different perspective or rephrasing. Now this is the prompt
or rephrasing. Now this is the prompt that we're going to use in order to generate five questions. Now we going to head into text editor and then in here
what I'm going to do I'm going to head into the generator again in here and I'm going to copy this prompt here. We use
this prompt in order to generate the answer. Okay. Now I'm going to copy this
answer. Okay. Now I'm going to copy this and pass you pass you a prompt. Yeah,
generate.
Yeah, we're going to pass a generate question. Generate question prompt like
question. Generate question prompt like this. And then I pass a generate
this. And then I pass a generate question prompt. I'm going to copy the
question prompt. I'm going to copy the prompt. I'm going to copy it here. I'm
prompt. I'm going to copy it here. I'm
going to pass it here. Okay, pass it in here like this. And then we're going to pass we're going to pass it to the LLM.
And here I'm going to comment this this code here right now. And then let me cop here this. I'm going to pass it up here.
here this. I'm going to pass it up here.
And here what I'm going to do I'm going to pass here this. Yeah, generate
question prompt val. We're going to pass it in here. And then yeah, I'm pass it in here. Generate.
in here. Generate.
Yeah, I'm pass generate question like this prompt. And then we're going to
this prompt. And then we're going to pass here generate question prompt invoke. We're going to pass here the
invoke. We're going to pass here the user query. Okay, we're going to pass
user query. Okay, we're going to pass here the question which is which is the property. Going to pass it in here and
property. Going to pass it in here and the query here. We're going to remove here the contest. And then we're going to pass this prompt to the model. And
now I'm going to copy the model. I'm
copy this. And then I'm going to pass it in here. We're going to pass a generate
in here. We're going to pass a generate prompt. We're going to pass it in here
prompt. We're going to pass it in here that value. And then we're going to pass
that value. And then we're going to pass here console.log
here console.log lmm result like this. And here I'm going to pass here a response for ma. I'm
going to tell the model I'm going to force the model to return an array of an array of questions. And here I'm going to head into here. I'm going to copy this.
I'm going to pass you to the invoke function this parameter. I'm going to I'm going to copy this object. We're
going to pass it to the invoke function in order to for the model to generate an array of question. Now let's go here and then I'm going to pass it in here. Okay,
like this. And then we're going to say here we're going to pass here questions.
It's going to be an array and pass here an array of question like this.
Yeah, we got an error. And here let me check edit if we import. we imported
here and I'm going to pass here this dot array and we're going to need an array of string here and pass a string like
this and then let's check let's see what we're going to get in here okay yeah you can see actually we have here an array of questions okay this is the array we
have here five question and now I'm going to pass the array I'm pass and pass a and pass a past result here
is equal to JSON pass here pass and we're going to pass here the llm results that question okay like
this and here you can see in here we have an object okay this is a string and in order to get access to the array we
going to pass here you pass pass your past results past results yeah pass results dot pass it that questions and
here I'm pass here is any to remove the typing error I can asset it is string yeah like this okay we have here typing error I can just pass here is any to
remove the typing error and then if we run this again we're going to have here an array of questions now let's wait a bit and see what we're going to get in here
okay let's wait a bit yeah you can see actually have here an error Okay, y passive content like this. And here I can asset
it now as a string. Okay, like this. And
now let's run it again. Okay, tap inner and see what we're going to get. Oh
yeah, you can see actually we have here an array of questions. You can see what is prompt engineering and how does it work for AI model. You can see that actually in here guys we generate five
different question that we can use in order to retrieve data into the vector database. Now we are going to iterate
database. Now we are going to iterate through the array and then we're going to retrieve the data into the vector database. That's what we're going to do
database. That's what we're going to do right now. Now as we have here five
right now. Now as we have here five different question and pass questions and pass questions is equal to pass
results dot questions.
Yeah, like this. And then what I'm going to do, I'm going to iterate through the array. And here we're going to do this
array. And here we're going to do this and pass here and pass here for cons question in yeah, we're going to pass here of questions. And then we're going
to yeah, you can see of questions. Yeah,
this array and here I'm set it as an array of string like this to remove this typing error. Questions. I'm copy that
typing error. Questions. I'm copy that and pass in here like this and pass here questions. Okay, we are going to iterate
questions. Okay, we are going to iterate through the array and then we're going to pass you this and pass here
results a weight query vector DV for each question we are going to have here an array of document pass here I'm create here our constant all retrieved
docs here pass here all retrieve docs like this and then we are going to we going to pass here all retrieve docs it's going to be an array like this and then We're going to pass or retrieve
dogs push. We're going to push in the
dogs push. We're going to push in the results and then we're going to take the all retrieve do array. We're going to push in the results. We're going to pass here results. Okay, we going to have
here results. Okay, we going to have here an array of documents. Now, before
we run this code, I'm going to head into the retriever the TS and here we're going to add here in our instance which is coher ranker. Okay, co here rer rank
and we're going to use this model provided by co here in order to rank an array of documents. Okay, now I'm going to console here console log. We're going to pass here ranked
log. We're going to pass here ranked documents and see what we're going to get. We're going to have here an array
get. We're going to have here an array here. Let's see. Okay, you can see in
here. Let's see. Okay, you can see in here we have here the an array of documents and then here we pass the array of documents to the ranker model.
Okay, now let's call this function and see what we're going to get. I'm going
to head to the console here and then I'll pass you I'm run this. Okay, we
going to run the retriever. I'm pass
here retriever thet like this and see what we're going to get. Okay, and make sure you import the cohhere rank. Okay,
you can see cohhere rank. Okay, at
lenchain/coher import the model. Okay. And then you're going to pass here new cohhere. You're
going to pass here the cohhere API key that we use for the embedding model.
Going to pass the key here. You can see if I head into the dam, we have here the coher API key. I use this key for the embedding model. You can see we have
embedding model. You can see we have here the embedding model, but also I use it for the coher rank. It's going to work. And then you're going to pass it
work. And then you're going to pass it the name of the model. Reank English v3.
pass that and then you're going to pass here an array of documents. Okay, but of the user query here. Okay, that we pass in here. Now let's head into the console
in here. Now let's head into the console and see what we got here. You can see we have here an array of documents. We have
here an objects and you can see the documents which is position on the index zero. The relevant score is pretty high.
zero. The relevant score is pretty high.
Okay, you can see 0.99.
Okay, is pretty high. Okay. Now, we're
going to pick a document which is a relevant score which is which is pretty high. We're going to return it. Now, in
high. We're going to return it. Now, in
order to return it, what I'm going to do in here, guys, first we're going to check if we have data into the results array and pass here going to check if we have data, [clears throat] we going to
return here an array of documents and pass here return. We're going to pass here results and then I'm pass here ranked documents. We're going to pick
ranked documents. We're going to pick here the first item into the array and then pass here that index like this. If
we don't have data into the results array, I'm going to return here an empty array and pass it. Else we're going to return an empty and pass here. Return an
empty array like this. And now what I'm going to do, I'm going to create here another file. I'm going to name it
another file. I'm going to name it reciprocal rank fusion. The TS like this reciprocal rank fusion. Okay, we are going to put in this algorithm. Okay.
Now I'm going to copy this algorithm.
We're going to paste it in here. Okay.
In order to fuse in order to merge this document into a single array. And then
here I'm going to let me tap here this this parameter. Okay. I'm going to go
this parameter. Okay. I'm going to go ahead and get into the retrieval app that appears. And if we put our cursor
that appears. And if we put our cursor over the results array, you can see they infers it to be a document in a first.
Okay, they infers it to be a document interface. Now I'm going to copy the
interface. Now I'm going to copy the tab. We're going to head into the respro
tab. We're going to head into the respro rank respro rank fusion.ts. I'm going to tap it like this. We have here an array of documents. Okay, I'm going to import
of documents. Okay, I'm going to import that. And then we're going to get rid of
that. And then we're going to get rid of the error. Now we're going to go ahead
the error. Now we're going to go ahead and get into the generator. And inside
the generator, what I'm going to do in here, we are going to pass a cons fused dogs. Okay. Is equal to respro
fused dogs. Okay. Is equal to respro rank fusion. Okay. And here we're gonna
rank fusion. Okay. And here we're gonna pass here this array. I can just tap it like this. You can see I'm going to
like this. You can see I'm going to import that first. And then here I'm going to copy that. And I'm going to tap
this array is document interface. I'm
going to import the interface. I'm going
to import it from link chain. Yeah, we
got an error. I'm going to move edit top here. And yeah, I'm passing the TS like
here. And yeah, I'm passing the TS like this. And also we going to import that
this. And also we going to import that in first I'm going to import it from Lenchen. Okay. Yeah. Let me import it.
Lenchen. Okay. Yeah. Let me import it.
Yeah. Let me see what we got into the respro rank fusion. We import it from lenching core for/ documents. I'm going
to copy that. We going to go ahead and get into the generator. We're going to pass edit type here.
Yeah, like this. Then we're going to remove the typing error. Now I'm going to copy the all retrieve do array. I'm
going to pass it to the I'm going to pass it to the reciprocal rank fusion.
Yeah, we're going to pass here and then we're going to pass here console log fuse docs. Pass here fuse docs and see
fuse docs. Pass here fuse docs and see what we're going to get here guys. Okay,
everything is okay. Now we're going to run the generator ts and pass here this pass here generator.ts.
Now let's see what we're going to get in here. Yeah, actually have an error. does
here. Yeah, actually have an error. does
not provide an export name document interface. Now let's remove that here
interface. Now let's remove that here because we have here an error. Now in
order to fix this error, we're going to import here the document class and pass a tab here and we're going to remove this class. We're going to take here the
this class. We're going to take here the document class and pass here is we're going to pass a document and then we're going to pass here this array. Okay,
inside in inside of this array we're going to have in in an array and here I'm going to copy this class. We're
going to pass into the reciprocal rank fusion. We're going to pass edit here.
fusion. We're going to pass edit here.
Okay, pass it in here. And then I'm going to pass here documents. Okay, like this. Okay, going
documents. Okay, like this. Okay, going
to pass here document like this. Okay,
and we're going to get rid of the error.
Now we're going to try to run this and see what we're going to get. And here I should pass here a question like this.
And now let's run this and see what we're going to get here guys. Okay. And
here I'm pass here. We're going to run we're going to run here the generator.
And now let's wait a bit and see what we're going to get.
Okay. You can see that actually we have here an array of documents. You can see we have here a documents. This the first one and this is a second one guys. You
can see we have here an array of documents. And now what I'm going to do
documents. And now what I'm going to do guys, I'm going to take this there. I'm
going to do this. I'm going to convert this array of documents to a string.
Okay. Now what I'm going to do, I'm going to import here a class. I'm going
to import here the format document a string. And you can see if we put our
string. And you can see if we put our case over the format document string.
You can see we pass it an array of documents. And then we have here a
documents. And then we have here a string. That's what we're going to do.
string. That's what we're going to do.
And what I'm going to do in here, I'm going to copy that. You can see pass here reciprocal rank fusion. And I pass here cons to and pass a doc to string
like this. We're going to pass here
like this. We're going to pass here format document as string. I'm going to pass it in here like this. And then pass a fuse doc like this. We're going to have here an array of we're going to
have here an array of string. Okay. And
in order to get to remove this typing error, I can just assert it. I'm gonna
assert the fused dog constant is dog array. Okay, like this. And now what I'm
array. Okay, like this. And now what I'm going to do, I'm going to create now a file here and name it prompt.ts. And
we're going to head in, we are going to go back in here into the generator. We
are going to go back into the generator and I'm going to copy this prompt. Okay,
we're going to put it into the gener into the prompt.ts. Okay, right here.
And then we're going to uncomment this and then we're going to pick this prompt in order to generate the answer. Okay.
Okay. I'm going copy it and then we're going to pass it in here. And I'm going to remove this one here. We're going to use this one. Okay. And we're going to import the prompt template. We're going
to go back in here. And then we're going to copy this class here. I'm going to copy this class. And then we're going to pass it in here. Okay, like this. Now
we're going to use this prompt. Okay, we
the prompt is response and pass a response and pass a response generator prompt like this. And then
we're going to export it and pass here.
Export response generator prompt. Now
let's copy it and get into the generator. TS and we're going to scroll
generator. TS and we're going to scroll at the bottom here. We're going to pass it in here. Let me pass here generator
resp response prompt like this and then I'm pass it here and then I'm pass that invoke and you can see we're going to pass it to property the questions and
we're going to take here this array of questions okay this is the array of question I'm going to copy it and then pass it in here pass here join okay we
are going to have here a string and you can see we're going to pass here to this prompt. We're going to pass here another
prompt. We're going to pass here another property which is the retrieve dock. I'm
going to cop it and then we're going to go back in here. I'm going to pass that here like this. And for the retrieve do we're going to pass here the doc to
string. You can see we pass the fuse the
string. You can see we pass the fuse the do array to the format to the format document as string. We're going to get here string and we're going to c this string. We're going to pass it in here
string. We're going to pass it in here like this. And then yeah like this. I'm
like this. And then yeah like this. I'm
going to pass here the query which is the original question. Okay. And here we are going to pass here questions join to have an array to have a single
to have a single string. Okay, of
question okay like this. And now we're going to pass that to the LLM. I'm going
to scroll down. I'm copy this and then I'm going to pass it in here. I'm coming
this. And then we're going to pass here LLM results. And then I'm going to copy
LLM results. And then I'm going to copy this and pass it in here. Yeah, it seems we have here in our constant lm result.
I'm going to remove it. Let me check a tab here. Yeah, we have here lm results
tab here. Yeah, we have here lm results again. Okay. Yeah, here I'm going to
again. Okay. Yeah, here I'm going to pass here response. AI response. Okay, like this.
response. AI response. Okay, like this.
And then I'm pass here console. We're
going to pass here console.log log
AI response like this. And then I'm going to pass here the AI response.
Okay. And now let's see what we're going to get. I'm going to run this file
to get. I'm going to run this file again. Everything is okay in here. Now
again. Everything is okay in here. Now
let's run this and see what we're going to get. Okay. Now I'm going to run here.
to get. Okay. Now I'm going to run here.
I'm type here not for/generator.
TS. Now you can see in here guys that actually we have an air response. You
can see based on the retrieved information here is a clear and concise answer to your question. What is prompt engineering? Prompt engineering is a
engineering? Prompt engineering is a practice of carefully designing and refining the input. Okay. Given to an LLM to guide it to guide it towarding
producing a desire output without changing the models internal parameters.
You can see that actually we have here the response. This is the final response
the response. This is the final response guys. All right guys, now going to be
guys. All right guys, now going to be talking about some different rack techniques. Previously we learned what
techniques. Previously we learned what is rag and high works. We said rag is a technique that allows to enhance the motor's generation by providing the model the possibility to get access to
external data sources.
Now in here you can see on this image I just list some different rack techniques. We have knife rack, advanced
techniques. We have knife rack, advanced rack, modular rack, corrective rack, specular rack, aentic rack, self rack.
Try this throughout this video. We're
going to stick to knife rag and corrective rag. Now let's learn how
corrective rag. Now let's learn how knife rack works. You can see in here I have here a document and inside of this
document they talk about Python. Okay,
Python programming language and we are going to take this document, we're going to store it into a vector database and then we are going to ask what is Python
and then we're going to get this definition from the model. Given the
data, Python is an interpreted language.
Now here if we pass here in we store into our vector database a Python book where we have a false definition of Python we're going to get this given the
retrieve data Python is a compiled language okay you can see that this is an error okay a mistake okay we got a false response because inside of our
defective database we store a Python book where we have a false definition of Python now in order to to get to this kind of issue. We're going to leverage corrective rack. In here, you can see we
corrective rack. In here, you can see we have the user here. We are going to forward his request to our system. And
then in here, we going to retrieve data into a database. And inside of a vector database, we have a fake document about Python. Now, once we got this data, the
Python. Now, once we got this data, the LLM is going to evaluate the user question versus the retrieve data. If
the LLM sees that the data retrieved from the vector database is irrelevant to the user question, we are going to perform a web search. Okay, you can see in here we perform a web search. We are
going to transform the user query. We're
going to perform web search and then once we have here web data, we are going to pass it to the LLM in order to generate a response to the user. And if
the user question is relevant, we are going to retain the response to the user based on the retrieved data. Now, in
order to understand corrective rack broadly, I'm going to present you this architecture, this diagram. You can see in here the user send a question to the LM. We're going to take the question,
LM. We're going to take the question, we're going to generate a multiple version of it. Then we're going to we're going to then we're going to fade data into the vector store for each question.
We are going to have here an array of documents for each question that we're going to pass to cohhere ranker. And
then in order to retrieve a document which is a high relevant score and once we pick here a document which is high relevant score we're going to use the
reciprocal rank fusion algorithm in order to match these documents into a single array. And then once we have here
single array. And then once we have here the single array, we are going to iterate through it. And then we're going to use the llm to check if each document
inside this array is relevant. And here
if you don't find a relevant document, we are going to transform the user query and then we're going to make a web search. We are going to take the web
search. We are going to take the web data. We're going to pass to the LLM in
data. We're going to pass to the LLM in order to generate a response to the user. And if we found here relevant
user. And if we found here relevant document, we are going to use this relevant document in order to generate the response to the user. And that's how
it works guys. Now we're going to get into our text editor and then we're going to implement corrective rack. Now
let's learn how to implement corrective rack. We're going to get into our text
rack. We're going to get into our text editor and in here we're going to create a ka. I'm passing ka over dog. Yeah, we
a ka. I'm passing ka over dog. Yeah, we
are going to pass ka over dog the ts.
And in here we're going to put in a graph. We're going to use a graph in
graph. We're going to use a graph in order to write to a given node. You can
see on this diagram here we have a router and we're going to use the router in order to decide if we can move to a given note. And now we're going to head
given note. And now we're going to head into the lesson folder. You can see that previously we talked about lang graph.
We learned what is l graph and we implement a simple graph. Now what I'm going to do, I'm going to just copy everything in here. We're going to put it into the keyna of a dog ts like this.
And here what I'm going to do, I'm going to create here some states. And we going to have the next node retrieve do filter doc and transform query. I'm going to
copy this state. And then I'm pass it in here. Okay. And we're going to pass here
here. Okay. And we're going to pass here actually we have here the next node.
Okay. And the next node I'm going to pass here a nish qual sing operator. And
here I'm pass here if the previous v I'm going to get rid of the default value.
If the previous v is now or ended we're going to return [clears throat] here the next v. Okay like this. This is the nish
next v. Okay like this. This is the nish coaling operator. And if the next v is
coaling operator. And if the next v is now or undefined we're going to return here empty like this. And we have also here the retrieve do. The retrieve do is
going to be array. I'm pass it in here.
And we can just remove here return here.
And then I'm pass here concat. Okay,
like this. And the previous value here is an array. And if we have the next value is let's say is another array.
We're going to take the next value.
We're going to push it into the previous we're going to take the pre we're going to take the previous value. We're going
to push in the next value. And here
we're going to create here another state. Here we have here the filter doc
state. Here we have here the filter doc is an array. I'm going to copy this one.
and we're going to pass it in here like this filter doc. We're going to copy it.
We're going to pass it in here. We have
transform query. This this one is a string. I'm going to copy this. And then
string. I'm going to copy this. And then
we're going to pass here transform query. Okay? Like this. And yeah, you
query. Okay? Like this. And yeah, you can see in here we have here two string and the and we have here two array. The
retrieve doc this one is an array of document. I pass this and filter doc is
document. I pass this and filter doc is an array of document. and pass here document like this. Okay. Now we going to create here a node. Now I'm going to
get into again into the dudu empty file.
And for the node we're going to have here retriever node, gray do node, transform query node, website node, and the generate node. Okay. Now we're going to start with the retriever node. And
inside of the retriever node, we're going to call the retriever. And we're
going to put in a we going to use the LLM in order to generate multiple query of the user question. We're going to use these questions in order to f data into the vector database and also inside the
retriever node we're going to use reciprocal rank fusion algorithm in order to merge data of of multiple array. Okay. Now what I'm going to do
array. Okay. Now what I'm going to do I'm going to copy this so I'm not going to forget what I'm doing. I'm going to copy that and then we're going to head into in here. We're going to pass it in
here. Now we're going to pass here close
here. Now we're going to pass here close retriever and pass here retriever. Okay,
retrieve like this. This is not and [snorts] here I'm going to remove everything in here. And also we're going to pass here another property. I forgot
because I'm going to use this this code here in order to get the the user message. Okay, I'm passing here. And you
message. Okay, I'm passing here. And you
can see we're going to pass here state message. This message here is going to
message. This message here is going to be an array of message. We're going to have in it's going to looks like this.
Let me show you. We're going to have an array which looks like this. We're going
to have here new human. We're going to have human message here. Okay. Let's say
what is a dog. Okay. And we're going to have here AI message. You can have here new AI
AI message. You can have here new AI message. Okay. And the here the message
message. Okay. And the here the message array holds the conversation between the AI and human. And we can you can see we pass here something like this state
message filter get type. Okay. In order
to get the type of the human in order to get the type of the message if we pass here AI we're going to have here the last AI message. Okay. As we pass human we are going to extract only this human
message. Okay, you can see when we're
message. Okay, you can see when we're going to iterate through the array, we're going to pick this last human message. Okay, if you pass here AI,
message. Okay, if you pass here AI, we're going to pick the last AI message.
Okay, and this array can continue like this. Let's say here the AI can respond.
this. Let's say here the AI can respond.
Okay, because when we are going to ask, we going to ask the user question. The
AI question, we are going to take this message, we're going to put it into the message array. We're going to put it in
message array. We're going to put it in here. Once the AI responds, we're going
here. Once the AI responds, we're going to pass here the AI message. If the
human again responds, we're going to pass it in here. Okay, human message.
Okay, you have to know that the message array holds the conversation between the AI and human. And now here you can see I just extract the human message, the last human message. And I'm going to move
human message. And I'm going to move here. I'm going to define this message
here. I'm going to define this message array. I'm going to use a pre-builtin
array. I'm going to use a pre-builtin state annotation. Okay, I'm going to
state annotation. Okay, I'm going to import it from langraph. Okay, we are going to call the retriever in order to retrieve data into the vector database.
Now, let me head into the generator.ts and in here I'm going to copy everything in here. We have here this generate
in here. We have here this generate question prompt. Okay. Now, what I'm
question prompt. Okay. Now, what I'm going to do, this is a prompt here. We
are going to create, we have here prompts that and inside of this file, we're going to put in all our prompts.
And I'm going to create here another folder inside the source folder. I'm
pass a prompt folder. Okay. And I'm pass here ur.
And I'm going to head into in here and pass index ts like this. And I'm going to put in the first ur. And the first
one is going to be I'm passport function extract message. Okay. Extract message. And here
message. Okay. Extract message. And here
I'm going to pass the message can be the message type can be AI or human. I'm
passing message and I'm pass here a tuple. Okay. It can be AI. Yeah, it can
tuple. Okay. It can be AI. Yeah, it can be AI or human. Yeah, I'm passing human like this. This is a tuple. And then
like this. This is a tuple. And then
we're going to head into the key of Dr. TS. I'm going to copy this and then
TS. I'm going to copy this and then we're going to put it in here. Yeah,
like this. And then I'm going to pass here. Yeah, I'm going to pass. Yeah, I
here. Yeah, I'm going to pass. Yeah, I
can just pass here message type like this. And we're going to copy that.
this. And we're going to copy that.
We're going to pass it in here. But
also, we're going to pass it an array.
And here I'm going to pass here this.
Yeah, I can pass you the state. Okay.
And the type of the state we're going to head into the kts.
I'm going to copy it. The top of it is state annotation. Okay. Yeah, you can
state annotation. Okay. Yeah, you can see in here we have here the state annotation is this graph here. The top
this graph. Now in order to get the type we need to export it into the we need to export it into the index.ts f5 and actually I can just pass here any okay
and pass here any like this. Yeah like
this to remove the typing error in here and pass here any okay like this. Once
we call the function we can pass here the state but also the message type. It
can be a or human. Now let's go back into the key. We're going to go back into the We're going to go back into the generators
and in here I'm going to copy everything in here. Okay, I'm going to copy
in here. Okay, I'm going to copy everything in here, guys. Okay, we're
going to put it into the KNA over dot TS and pass it here at the top. And we're
going to get it off. Yeah, we're going to need here the query vector DB function. We're going to need here the
function. We're going to need here the respro rank fusion algorithm. We're
going to need this function.
And yeah, we're going to need here response generate prompt. Okay, now I'm going to remove this here. And yeah, let me see what I pass here. Just pass here
only the LLM. And I'm going to import something else into the generator TS.
You can see we have here generate. We
have generate question prompt. I'm going
to copy that. Yeah, we're going to copy this prompt. We're going to put it into
this prompt. We're going to put it into the prompt folder. Okay, I'm going to head into in here and pass here prompt prompt.ts like this and pass it in here.
We're going to head into the prompt here. You can see we have response
here. You can see we have response generator prompt like this and pass like this. I'm going to copy this.
this. I'm going to copy this.
I'm going to remove this one here and then I'm put it in here. Okay, like
this. We're going to copy this code.
We're going to pass it at the top. Okay,
like this. We're going to export the generate question prompt. Okay, like
this. We're going to export it. Yeah,
that's good. We're going to go like again the generators.
And in here you can see we pass you the user query. Actually, in order to get
user query. Actually, in order to get the user query, we are going to use this function here extract message. Okay.
Now, if we head into the key of Dr. TS and we move here and I'm going to call cons query and pass a query is equal to
extract last message extract extract message okay and here we're going to pass you the state and I'm passing the message type is going to be human okay
and we're going to pass here yeah last message okay and in order to get a query we're going to pass something like this query is equal class
human message content like this. And
then we're going to get access to this property. Okay. And I'm going to set it
property. Okay. And I'm going to set it as a string in order to remove this typing error. Okay. Yeah, we are going
typing error. Okay. Yeah, we are going to go back in here.
And then I'm going to pass here something. Yeah, this one here. I can
something. Yeah, this one here. I can
just return here the Yeah, I'm pass here last message like this. We're going to return it. Okay, we're going to pass it
return it. Okay, we're going to pass it in here. Pass you return like this.
in here. Pass you return like this.
Okay, and yeah, we're going to go back into the keyn of dots. We get off the error. Now, we're going to use the llm
error. Now, we're going to use the llm in order to generate multiple questions that we're going to use in order to retrieve data into the vector database.
Now, I'm going to copy this code here.
Okay, I'm going to copy this and then we're going to go into the Q&A over Dr. TS. We're going to pass it in here.
TS. We're going to pass it in here.
Okay, like this. And you can see generate question. And I'm going to
generate question. And I'm going to import a prompt from the prompt folder like this. Okay. And here we're going to
like this. Okay. And here we're going to pass here a sync because we have here invoke returns a promise. And we're
going to pass it the query. Okay. And
here you can see we have a response for matter. I'm going to copy this and then
matter. I'm going to copy this and then I'm going to put it into the index.ts file. party export and then pass here
file. party export and then pass here con response formatter like this is equal to an object. Okay, we're going to import z to JSON schema. We're going to
import it in here and we're going to import to z. Okay, like this. Yeah,
response for mror. Okay,
question. Yeah, I'm pass question response for m. Pass here question response for m. We're going to import it and cop it and then we're going to pass
it in here and we're going to pass it to the lm. Okay, we have here this and pass
the lm. Okay, we have here this and pass it in here after the array like this.
And then we're going to import it. Yeah,
like this. Okay, and [clears throat] here we are going to pass here and pass here this. We're going to go back into
here this. We're going to go back into we're going to go back again to the general ts. You can see we're going to
general ts. You can see we're going to parse through the results and then here we're going to have here an array of questions. We're going to iterate
questions. We're going to iterate through. I'm going to copy this again.
through. I'm going to copy this again.
Okay, let me copy everything in here.
I'm going to copy everything in here.
We're going to put it into the retriever node in here. We're going to go back in here and we're going to pass it in here like this. Okay, we pass the results. We
like this. Okay, we pass the results. We
pass here question. Pass result
questions. So we have an array question and here you can see pass here or retrieve doc and you can see in here we have retrieve doc. I'm going to use this
state here. I'm going to cop it and then
state here. I'm going to cop it and then we're going to update it or retrieve doc and here I'm pass here return. Going to
pass here return and then we're going to pass in the state that we want to update. As it is an array we are going
update. As it is an array we are going to copy all retrieve dot. We're going to pass it in here like this and then we're going to update it. Okay. or retrieve
dog like this. Yeah, I can just pass it.
Yeah, like this. We going to pass here first fuse dog. We're going to call first there is pro rank fusion and then we're going to pass it in here like this. Okay, this is an array. I'm going
this. Okay, this is an array. I'm going
to remove this and then we're going to push it into the retrieve dock. Okay.
Yeah, like this. We are done. I think we are done with this retrieve node. Okay.
We are done in here and you can see we imple inside the retrieve note I'm passing retrieve note we have the retriever we have the question generator but also we call the respro fusion rank
function okay now we just finished with this now what I'm going to do in here we are going to move to another node which is let me check into the two empty file we're going to move to another node
which is the grade do okay now we going to grade the document we're going to check if inside the the array we have a relevant dog to the user question. Now
we're going to go back in here. We're
going to create here another node which is pass a grade dog node. Yeah, like
this. And here what I'm going to do I'm going to first first of all we're going to define here a prompt. Okay, I'm going to copy this prompt here and we are going to put it into the prompts. Let's
head into the prompt. TS and we're going to pass it in here like this. I'm
passing export pass exports and then you can see pass here great dog prompt. Okay. You are a great assessing relevance of retrieve
document. Okay. To the user question.
document. Okay. To the user question.
Here's the retrieve document. We're
going to pass the counters and but also the user question. And if the document contains keywords or semantic meaning related to the user question, grade it as relevant. Okay. give a binary score
as relevant. Okay. give a binary score yes or no [clears throat] to indicate whether the document is relevant to the user question and we're going to have
also the grade dog response for matter.
I'm going to copy it and then we're going to put it into the utility ts file. We have the URL. CS file. We're
file. We have the URL. CS file. We're
going to pass it in here. And great dog grade dog response. And here we we pass here an enam because we're going to have
here an object banner score. We're going
to have yes or no. Okay. And if we have yes, we're going to push the document into the filtered array. If is no, we aren't going to push it. Okay. Now pass
here export. We're going to pass this to the LLM. Now let's go back into the key
the LLM. Now let's go back into the key of a do the tears and in here into the great doc node. What I'm going to do first I'm going to extract the user
message. Okay. Okay. I'm going to copy
message. Okay. Okay. I'm going to copy last message and then I'm going to pass it in here. Yeah. We're going to pass it right here like this. And you can see in
here we have your retrieve do this array where we pushing array of documents.
Okay. Now in order to get access to it we're going to use here. Yeah. We're
going to use the state. You can see progress over the state. We have the next node and we have here the filtered.
We have the next node transform query.
We can get access to a property inside the states annotation graph. Okay. Now
in order to get access to this array, we are going to copy that pass all retrieved doc is equal to state
this. Okay. Now we're going to call the
this. Okay. Now we're going to call the prompt. And this the prompt that we need
prompt. And this the prompt that we need to call. We're going to go back in here
to call. We're going to go back in here and we're going to call the grade prompt. I'm cop it. And then we're going
prompt. I'm cop it. And then we're going to go back into the key of TS. We're
going to pass it in here. Yeah, like
this. And I can I can just pass here chain. We can use runnable. We already
chain. We can use runnable. We already
learned what is a runnable. We're going
to put everything we have learned so far in practice. And I'm pass
in practice. And I'm pass yeah I'm going to pass here you create great documents great do prompt I'm import it and then I'm pass here pipe like this and then we're going to use
we're going to pass here the llm like this we're going to pass the prompt to the llm and now I'm pass I'm pass here we going to iterate we're going to
iterate first into the retrieve do array and I'm pass here for I'm pass dog do in all retrieve docu like this
and then what I'm going to do I'm going to pass here cons chain results chain result like this we're going to pass
here chain invoke like this we're going to pass here you can see we are we're going to pass here the user question we're going to pass last message and
pass here this we're going to pass last method last message the content yeah like this and also O going to pass here the contest. Okay, for the contest it's
the contest. Okay, for the contest it's going to be the doc content and pass here pay and pass here
page content. Okay, let me see the type
page content. Okay, let me see the type of or the type of or retrieve do array is the type of document. Okay, and here
the type of doc is a string and let me check here. Yeah, we pass here in of.
check here. Yeah, we pass here in of.
Okay, we're going to pass here of and here they're going to infer the type of dog constant is going to be a document.
Okay, this is an object and then we're going to pass here doc page content like this.
Like this. And then yeah, like this. Let
me check in here.
Okay, we pass you. We're going to pass here the question like this. Okay. And
we're going to pass here the the great document response for matter. We're
going to import it. Yeah, like this. And
I can just I say is need to remove this typing error and pass here is in like this. And then we're going to do this
this. And then we're going to do this and pass here past results and is equal to JSON. We're
going to pass it G and pass here. Pass
it JSON parse. We're going to pass here chain results like this. And here for the chain result, we're going to pass
here content. And I'm going to I'm going
here content. And I'm going to I'm going to asset it as a string.
String. And if you check here, if we head into the unit here, as you can see, we're going to have YouTube property yes or no. I'm going to tap it. I'm going to
or no. I'm going to tap it. I'm going to assert this past result as a tuple. We
[clears throat] can have here yes or no like this. is a tuple and here we have a
like this. is a tuple and here we have a typing error and here I'm going to pass here a weight because the invoke return
a promise like this a wait and here too going to pass here a sync like this everything is okay so far and yeah now what I'm going to do in here I'm going
to pass here past result yeah like this that is equal to yes if is equal to yes we going to push the if is equal to yes we're going to push push the content
into this array. Let me move here. You
can see parase over the state we have here the filtered dog. Filtered dog.
We're going to push the content into the filtered dog array. I'm going to copy that. And here I'm pass here else.
that. And here I'm pass here else.
I'm pass here else. And then we going to pass here this. Okay. Here we have the loop. And we are going to pass here
loop. And we are going to pass here return. We're going to pass here filter
return. We're going to pass here filter doc. Okay. We're going to create here
doc. Okay. We're going to create here another array and pass a cons filtered filtered doc here is equal to an empty
array. I'm going to asset it as document
array. I'm going to asset it as document array like this.
And we're going to copy that. We're
going to pass it in here that push and pass here. We're going to pass here
pass here. We're going to pass here push. We're going to pass here dog
push. We're going to pass here dog content. Okay? Like this. I'm going to
content. Okay? Like this. I'm going to pass here new yeah we're going to pass here new document and then we're going to pass in
an object and we have here the we have the page content we're going to pass here doc page contents like this so I'm going to copy the all filtered doc we're going to pass it to the filtered dock
here array now let's head into the todo empty file and see on which node we're going to move to we are going to move to the transform query node now let's head into the prompt ts and in Here we are
going to create a prompt. Yeah, this is the prompt. You are generating a
the prompt. You are generating a question that is well optimized for semantic search retriever. Look at the input and try to reason by the underly semantic intent meaning and here we're
going to pass here the question and we're going to tell the air to formulate an improve question. Now let's go back into the ka key over do ts and in here
I'm going to pass here the note transform transform query. Okay. And
we're going to copy the name of the prompt here and pass here. Yeah, we're
going to pass it transform transform query prompt. Okay, like this. We're
query prompt. Okay, like this. We're
going to import it. And then we're going to pass here the llm and we're going to pass here new pipe new string output parser. Okay,
you can see when we get a respon from the AI, we have an object. You can see I'm going to give you an example. This
is an AI message. Okay. And you can see we have a lot of property into this object. You can see we have the use we
object. You can see we have the use we have the use it metadata. We have tools.
We have invalid tool calls. We have a lot of property. And if we pass here the new string output parser, we're going to get only a string. We are going to
retrieve only the string. Okay. And you
can see we have here the content. And
now we're going to get only this. Okay.
is we pass here no string output pass we're going to get get only a string okay now let me pull my curs here okay you can see here they give us an example how to use it you can see we have a
prompt template we pass here tell me a joke about we pass a topic and then pass here runnable sequence we pass the prompt and you can see we pass the model
and then pass here no string output parser and then we are going to invoke the chain we're going to pass it topic bears And then we're going to get get here a string. Like this. It's pretty
easy. And now we're going to pass here a sync as we have a promise inside of this as we have a promise inside of this function. And then we're going to pass
function. And then we're going to pass here better question.
And we're going to pass here the last human message. Okay. Okay. You can see
human message. Okay. Okay. You can see we have here last [clears throat] message. We're going to extract the last
message. We're going to extract the last human message. I'm going to pass in here
human message. I'm going to pass in here and then pass here last human mess and pass here that content like this.
Yeah, we get rid of the error and then we're going to pass here question. Okay,
we're going to return this question in order to make it safe. Now I'm going to pass here I'm going to pass here something like better question. Okay,
like this I can just pass here AI question and pass a transform query. Okay,
transform query like this. And if we put our case over the state here, you can see we have here transform query. I'm
going to copy it. And then we're going to pass it in here. Okay. Now, we're
going to use the transform query in order to make a web search. Now, in
here, we just finished with this node.
I'm going to cop here another node here, which is the web search. We're going to use the valley. Previously, we learned how to use the valley when we talked about tools. You can see we have the
about tools. You can see we have the lessons footer. And if we head into
lessons footer. And if we head into tools, you can see we have a tavali. We
already learned how to use tavali. We
said tavali is a set tool. And in order to invoke it, we pass it to valley.invoke and we pass the query. And
valley.invoke and we pass the query. And
now let's go back into the key of a dog.ts. And in here, what I'm going to
dog.ts. And in here, what I'm going to do, I'm going to pass here this node web search. We pass here. We're going to
search. We pass here. We're going to import it. Import.
import it. Import.
Then we're going to pass here the transform query. Okay, like this. And we
transform query. Okay, like this. And we
are going to iterate through the doc array. Here you can see we have a docs.
array. Here you can see we have a docs.
This is an array returns but value. We
are going to pass a dos results that map. We're going to iterate through it.
map. We're going to iterate through it.
And then we are going to return an array of documents that we're going to pass to the retrieve do. Okay. And now we're going to move to another node which is
the generator. Okay. And I'm pass here
the generator. Okay. And I'm pass here generate generates. And we already have
generate generates. And we already have here some code into the generator.ts.
I'm going to copy everything in here.
Okay. Going to copy everything in here.
And then we're going to get rid of the generate thets file. I'm going to put everything into the generate function.
I'm going to pass everything in here.
Okay. Yeah. Like this. Like this. And
now in order to generate the response, we going to use the retrieve doc. Okay.
We are going to pass here state retrieve do okay and we use for document a string and the retrieve do is an array
of document we're going to convert it into a string and then once we have here a string we are going to pass it to the lm and then here we're going to pass it
the original question which is the human question okay now in order to get it we're going to copy this again we are going to pass it in here Okay. And we're
going to pass here last message content like this. Now, in order to get access
like this. Now, in order to get access to the questions array, we're going to pass here use state generate questions.
And we're going to invoke the join function in order to get a string of message. And we're going to return here
message. And we're going to return here this. We going to return here an array
this. We going to return here an array of me and pass here. Return. We're going
to pass here message. And as I said before, the method the message the method array holds the conversation between the AI and a human. And we're
going to pass here the a response. Okay,
a response. And this is the message array is right here, guys, which is a pre-builtin state annotation. And we're
going to update it. And now we're going to create here the router in order to decide if we can generate the response to the user or we can transform the user query in order to make a web search. And
here I'm going to pass here the router.
And you can see inside the router we have a logic. And here I'm checking if the filter do array we have data. If we
don't have data we are going to transform the user query and then we're going to make a web search. And and if we have data we are going to generate the response immediately. It means we
are going to move to the generate node.
Okay. In order to generate the response to the user okay to this node here. Now
you can see I just pass you I just pass you the graph. You pass it the retriever node, create do node, generate node, transform query node, website node. And
here you can see the starting node is the retriever node and then we are from we are going to start first with the starting node. The starting node and
starting node. The starting node and then we're going to eat the retriever node. After the retriever node we're
node. After the retriever node we're going to eat the great dog node. Okay.
And after that you can see on the gray do node here we add a condition and then we pass here the router in order to in order to check if we have data into the
filter do array. If you don't have data we're going to transition to transform query node. Okay. Else we're going to
query node. Okay. Else we're going to move to the generate node. Okay. Now you
can see after that we pass here transform query. From transform query
transform query. From transform query we're going to move to the website. from
the website to generate and then we're going to eat the end node. Okay. And
then here we go the graph and we pass here message. You can see passing new
here message. You can see passing new human message and you pass the content tabs of prompt engineering. Okay. And
now let's head into the and see what we're going to get. We're going to run this file. I'm type here node source
this file. I'm type here node source for/kna over do.ts and then we're going to see what we're going to get in here guys. Yeah, you can see actually got an
guys. Yeah, you can see actually got an error and this the error message transform query is already being used as state attribute and now in order to get
rid of this error I'm going to pass here something I pass here new query like this okay new query and and then we're going to remove the error you can see at
the bottom here we have a node where the name is transform query okay we have here a node the name is transform query Okay. And if we keep the same name as
Okay. And if we keep the same name as the state, we're going to get an error.
Now here I'm going to modify that. Here
we're going to get into we're going to move here. Pass here. We don't pass it
move here. Pass here. We don't pass it in here. We're going to move to
in here. We're going to move to transform query node. And in here I'm pass here no question. Okay. No
question. Okay. And then we're going to pass it no question. Also guys you can see in here we pass here pipe and then we pass here string output
parser and this string can contains also the reasoning of the llm. Now in order to avoid that I'm going to remove it and then I'm going to go into the prompt.ts.
We're going to get into the [clears throat] ur folder index.ts TS file and then here I'm pass here to for okay and we have
here transform response for matter okay transform response formator we're going to use this on the transform query node okay I'm going to copy that and then we're going to pass it in here in order
to avoid an error okay now we're going to go back in here and I'm going to pass it in here yeah like this and I'm going
to import this okay you can try this sometimes you can the AI can return only the question and sometimes the AI can
return the question with its reasoning.
Okay. Now in order to a comment this now we are going to go back into the ur you can see also we have here another response for generate response formator.
Okay. Now we are going to use this response for in order to extract to force the AI to separate the response with its reasoning. Okay, we're going to have you the reasoning but also the
answer. Now I'm not going to use this
answer. Now I'm not going to use this right now. We're going to run it and
right now. We're going to run it and then you're going to see what we're going to get. Okay, I'm going to pass it right now. I'm going to pass it here.
right now. I'm going to pass it here.
Okay, we are going to right now I'm going to pass it here and then I'm going to comment it. Okay, now let's run this and see what we're going to get. Okay,
you're going to see that actually going to get the response with the reasoning of the air. Okay.
Yeah, you can see again guys, we got an error. Now, we're going to go back here
error. Now, we're going to go back here again and yeah, we pass here
this. Okay, JSON pass a response. And
this. Okay, JSON pass a response. And
then yeah, now let it here to see what we got here.
And you can see in here we pass we have an error. We going to look for it. Okay,
an error. We going to look for it. Okay,
we have two input parsing exception received two input did did not match scheme. Okay, and we have here an error
scheme. Okay, and we have here an error guys. We are going to fix it. Now let me
guys. We are going to fix it. Now let me check this. We have here new question.
check this. We have here new question.
Okay. Yeah, let me go edit up here and see which state we pass here. We have
here no query instead of no question.
Okay, that's why we got here. Okay, I'm
going to copy this no query. Okay. And
here we are going to move to the transform node again. And we're going to pass here this and pass here new query.
And we're going to move to the website node. And in here you can see we still
node. And in here you can see we still pass here transform query. That's why we got an error. And I'm pass here new query like this. Now let's run this again and see going to get. I'm going to
head into the console. We're going to run this file again. And then let's check here what we're going to get in here guys. Now you can see guys that
here guys. Now you can see guys that actually we have the response and you can see results that's what I pass here.
You see at the bottom pass your results colon colon and here you can see we have uh no object and inside of it we have
the message array we have here the human question. Okay types of prompt
question. Okay types of prompt engineering. Okay. And here you can see
engineering. Okay. And here you can see a response. Okay. You can see um the
a response. Okay. You can see um the user is asking about types of prompt engineering. Let me start by stepping
engineering. Let me start by stepping back to understand the broader contest.
You can see that actually the air give us the response but actually you can see the response contain the reasoning of the air. Now I'm going to remove the
the air. Now I'm going to remove the reasoning of the air from the question.
Okay, you can see we have you think yeah I'm going to remove that. We don't need that. Now in here we're going to copy
that. Now in here we're going to copy this here and then we're going to pass it in here. I'm going to remove this here. Okay. And we're going to import
here. Okay. And we're going to import the generate response from okay like this. And then in here you can see if we
this. And then in here you can see if we click here we have the we're going to get here an object. We going to have here the reasoning but also the answer.
Now what I'm going to do in here, I'm going to pass here call results and then pass here JSON JSON pass and pass here a
response. Okay. And then pass here that
response. Okay. And then pass here that content is the string is string. And
here we we have here an object. Okay.
And I can pass here reasoning is a string but also we have the answer. Okay. The answer is also a
the answer. Okay. The answer is also a string. Okay, like this. And if we check
string. Okay, like this. And if we check here, you're going to see we got the same thing. Okay, reasoning like let me
same thing. Okay, reasoning like let me cut this in order to avoid errors. Okay,
I'm going to try to compare. We have
your reasoning reasoning like this. But also we have your answer. Okay. Now what I'm going to
your answer. Okay. Now what I'm going to do in here, I'm going to pass here AI message. Okay, pass here.
AI message. Okay, pass here.
Okay, I'm going to pass here no AI message. Okay, like this. And then we're
message. Okay, like this. And then we're going to pass here results and then I'm pass here that answer like this. Yeah,
we can remove this. Okay, like this. And
if you want to see the reasoning, I'm going to console here the reason linking. Okay, console.log
linking. Okay, console.log
and pass here a resing.
Yeah, like this. And then we going to see it in here and pass here results like this reason name. Okay. Yeah. Now
let's run it again and see what we're going to get. I'm going to run this tab inner and see what we're going to get.
Yeah. You can see again we have here the response and you can see that actually we we separate the response with the reasoning of the air. Okay. Now you can
see here raising the user asked about types of prompt engineering. I need to provide a structured answer that covers the difference categories and techniques of prompt engineering based on the
retrieve information. The retrieve docs
retrieve information. The retrieve docs mention several key techniques like zero shots, few shots, channel thoughts and others. And I should organize these into
others. And I should organize these into a clear taxonomy while keeping the answer concise and informatic. Okay, you
can see now we have the answer here. All
right guys, now let's talk about the map reduce technique in order to generate the summary, the star guide, the briefing talk, the FAQ, but also the map map. So what is the map reduce
map. So what is the map reduce technique? The map reduce technique is a
technique? The map reduce technique is a way of breaking down a a document into multiple pieces of documents and then we are going to take these pieces of
document we're going to pass one by one to the LLM in order to generate the summary and then at the end we're going to have here an array of summary and then we going to take again this array
of summaries of each piece we are going to pass them into the LLM in order to generate the final summary. Now our
graph is going to looks like this. Okay,
I'm going to move here. Our graph is going to looks like this. We're going to take a document. We're going to break it down into multiple pieces of documents and then we're going to have here a
node. Okay, map summary. We are going to
node. Okay, map summary. We are going to iterate through these pieces of documents and then we are going to take piece by piece. We're going to pass it to the LLM in order to generate the
summary. Okay. And then we're going to
summary. Okay. And then we're going to have here an array of summaries. And
once we have here an array of summaries, we are going to count the total number of tokens of all summaries in this array. We are going to check if is less
array. We are going to check if is less than the max token. If is less than the max token, we are going to generate the final summary. If it's not less than the
final summary. If it's not less than the max token, we are going to collapse summary. It means we are going to split
summary. It means we are going to split all these summaries into smaller summaries until the token length of all summaries is less than max token. Okay.
And then we're going to have here again an array of summaries that we are going to pass to the LLM to generate the final summary. Okay. Now I'm going to walk you
summary. Okay. Now I'm going to walk you through the code. We are going to head into the summary.ts. We are going to implement the summary pipeline. So
before we implement the summary pipeline, I'm going to explain you something into the test ts which is the send function this method and when we talked about lang graph I didn't explain
you what is the send function. Now I
want to explain you what is the send function because we're going to use it into the summary pipeline. So what is the send function? The send function is basically a function that we're going to use in order to send data to another
node in a graph. Now you can see in here we have a simple graph and we have here some states generates. We're going to use the states in order to decide if we
can we can generate a jokes or a comments about a subject. Now the
subject here is an array. We're going to pass in some items. We can pass in cats or dogs. We can generate a comment about
or dogs. We can generate a comment about a dog or a joke. Okay, these are subjects that we can have here. You can
see this is an array. Now you can see we have here what to generate this is the node and inside of it we iterate through the subject array and here I'm checking
if the value of generate is equal to comments we are going to move to the generate comments node else to generate joke node okay and then we are going to
send to to to a given node that we're going to return here data we are going to send it subject okay now you can see
in here we're going uh send let's say here the value of generate is equal to comments. We are going to send to the
comments. We are going to send to the generate comments node. We're going to send it an array of we're going to send it an array of data. Okay, now you can see in here we have generate comments
node. Okay, we pass here comments
node. Okay, we pass here comments comment about and then pass here state that subject. Okay, we are going to pass
that subject. Okay, we are going to pass here. We're going to send here data. Now
here. We're going to send here data. Now
let me show you what we are sending in here. And if I pass here something like
here. And if I pass here something like console.log
console.log okay state okay I'm pass here send data like this and then we are going to pass
here state subject okay we going to head into the console and see what we're going to get.
Okay now let me check here you can see in here the generate is equal to comments. Okay. And here too we going to
comments. Okay. And here too we going to move to generate comments node. Okay.
Now let me run this and see what we're going to get. Okay. And here I'm going run this. And then you can see we have
run this. And then you can see we have here send data. We have here cats this array but also we have here dogs. Okay.
You can see when we are going to iterate through the subject array we are going to send a data. We are going to send item by item. Okay. You can see inside the subject array we have hidden two
[clears throat] item. We're going to send cats then dog. Okay. And then
inside the generate comments we are going to generate a comment about a cats and then dog. Okay. You can see we are sending an array of Adam to the generate
comment node. Okay. And here you can see
comment node. Okay. And here you can see in here I can I can pass here a a property which doesn't exist into this
state here. Okay. Now let's see we can
state here. Okay. Now let's see we can pass here end okay and I pass here da da and I'm pass text okay end text like
this you can see actually we don't have the end property into the graph here you can see we don't have it but we send we
can get access to it is like we just added this this property into the graph okay now I can pass here something like
this pass here this pass here state dot and then I pass here and you can see when I tap this state you can see inside
the graph we have comments generates drugs and subject but we don't have here ends and and end here is a property is a
states returned by the send function okay and we can get access to it by using the state is like we're going to inject it into the state into the graph okay if I pass here end Okay, you can
see actually we have a typing error because we don't have we we don't have it into the state. Okay, into the graph.
Now I'm going to run this and then you're going to see what we're going to get.
Okay, you can see we have here comments about dogs and then we have here da da da and text. Okay, you can see we can use the send function in order to send
data in order to send property or states to another node in a graph. Okay, that's
what they said here. We can use the send function in order to send a message or packet to a specific node in a graph.
Okay, that's what they said here. Now
let's go and implement the summary pipeline. And here we are going to
pipeline. And here we are going to import chio webbased loader in order to extract the data into this web page. We
pass here loaded load. We're going to have here an array of documents. And
we're going to take this array of documents. We're going to pass it to
documents. We're going to pass it to we're going to pass it to the recursive character. the chunk size 1,00 chunk of
character. the chunk size 1,00 chunk of lab 200 and pass here text split documents. We pass here an array of
documents. We pass here an array of documents. We going to have here a an
documents. We going to have here a an array of split documents. Now we pass here the model token max and we have here approximate token to calculate the
value of a single token. The value of a single token is equal to four characters. We're going to return it
characters. We're going to return it using this approximate tokens function.
Now the length function here we use it in order to get to calculate the number of tokens of all documents into the document array. Now in here these array
document array. Now in here these array is going to looks like this. We're going
to have here an array of documents.
Okay. These documents are basically chunks of the original array. Okay. And
then we are going to return the we're going to count the we're going to count a tokens of this document. Let's say in here we can have here 12 and here we're
going to have here let's say 22 and then we are going to return an array that looks like this. We're going to have here 12 and here 22. These are tokens of each chunk. Okay. And then we are going
each chunk. Okay. And then we are going to sum up these tokens in order to get the total value of tokens of your array.
Now I'm going to remove this. We are
going to implement the graph. Okay. Now
you can see this our graph and we have here some states contents summary collapse summary and fun summary. Now
I'm going to begin at the end here in order to understand how it works. Now
you can see in here we have generate summary collect summary collapse summaries generates final summary. These
are nodes. Okay. Now we start here on starting node here we pass map summary.
Map summary nodes what it does? You
basically iterate through an array of summary on this section here. You can
see we have a map summary note. We are
going to iterate through an array of documents. Okay. And then we are going
documents. Okay. And then we are going to send a piece of documents to the generate summary in order to generate the summary. Okay. Now let's see in
the summary. Okay. Now let's see in here. I'm going to click here map
here. I'm going to click here map summary. Okay. You can see in here we
summary. Okay. You can see in here we are iterate. We are iterating here.
are iterate. We are iterating here.
Let's see. We have here map summary. We
are iterating through an array of documents. Okay, we pass here. Let me
documents. Okay, we pass here. Let me
move at the bottom here to show you something. You can see we pass here a
something. You can see we pass here a app that stream. We invoke the graph and then here we pass here split docs split split docs map here and then pass here
the content. You can see passing the
the content. You can see passing the content. This is the states. Okay. And
content. This is the states. Okay. And
then we going to pass here a piece of document. We're going to send to the map
document. We're going to send to the map summary a piece of document. Okay, we aren't going to pass the whole we aren't going to pass the all documents but instead we
are going to send a piece of document.
Okay, now we pass here state contents.
We send a piece of document to the generate summary node. Okay, we have here generate summary. Okay, this node we have here we pass here a piece of document. They're going to generate a
document. They're going to generate a summary about it and then they're going to take this summary. They're going to push it into the summaries array. We're
going to something this you can see we are going to pass this piece here to the generate summary node and then they're going to push it into the summary array
and then once they push it into the summary array we run this tape. We run
this stage here. Okay, we are going to move here to generate summary and from generate summary we are going to move to
another node here collect summaries.
Okay, now we are going to check the logic into the collect summary. Okay,
now you can see inside the collect summary in here we are iterating through an array of summaries. Okay, you can see pass here collapse summary. We are going
to pass a state summary map. We are
iterating through an array of summary in order to check if in order to check in order to check here if the the if the
token length of our summary that we have into the summary array is less than the max token. Okay. If is less we going to
max token. Okay. If is less we going to generate the final summary. Okay. Here
you can see from collect summary you can see from collect summary you can see in here we have a condition should
collapse. Okay. And then we are going to
collapse. Okay. And then we are going to decide if we can collapse summary. To
collapse summary it means we are going to split the summaries into smaller summaries. Okay. Until the token length
summaries. Okay. Until the token length is less than the max token. Okay. And if
the token length is less than the max token, we're going to generate the summary. If I click here, you can see we
summary. If I click here, you can see we have here a condition. We pass here length function. We pass here an array
length function. We pass here an array of documents. Okay, you can see the
of documents. Okay, you can see the infers it the collapse summaries as an array of documents. And then we going to
decide if we can generate this the final summary or we can or we can here or we can split again this array of summaries into smaller summaries. Okay. Because in
here you can see we return here another node collapse summaries. Okay. Now let's
see the logic inside the collab summaries node. Okay. We have here
summaries node. Okay. We have here collapse summary. Okay. I'mma click here
collapse summary. Okay. I'mma click here and then you can see in here we pass here splits of splits list of
dogs. Okay. And this is a function that
dogs. Okay. And this is a function that we import from lenchen splits a list of documents into sublist based on the maximum token limit. Okay. And then
we're going to split it again. And then
here we're going to iterate through the array. And then we are going to return
array. And then we are going to return again an array of summaries that we're going to pass to the LLM in order to generate the final summary. And that's
how it works guys. And in order to understand as I said you need to practice try to practice in CAX. Now in
here you can see in here we compile the graph. We compile the graph in here and
graph. We compile the graph in here and then we pass here after the stream.
Okay. We pass here splits. We are
passing a chunk of document to the graph. Okay, because we you can see pass
graph. Okay, because we you can see pass here contents and then we pass here splits. This is an array of documents of
splits. This is an array of documents of ch then pass here do page contents and then now we are going to run this and see what we're going to get. Okay, we
can pass even something like this. Pass
here consults pass your final summary.
Okay. And then we will pass here app invoke here. Invoke. We are going to
invoke here. Invoke. We are going to pass I'm going to copy this. Okay. And
then I'm pass into the invoke function.
I'm pass here and pass here a weight. And then we're going to comment this. Okay. Is the same
thing. But as we use here stream, we are
thing. But as we use here stream, we are going to observe the execution of the graph. Okay. That's why we use stream.
graph. Okay. That's why we use stream.
Okay. You can see even inside the test the TS when I was explaining you about the send function you can see at the bottom here we use stream in order to
observe the execution of the graph. Now
in here I'm using here to here we use here to stream in order to observe the execution of the graph. Now
we are going to I'm going to copy this.
I'm going to move it in here summary and I'm going import it there. And then we have here test. I'm going to add it into lessons. Okay. When you're going to find
lessons. Okay. When you're going to find this codes on GitHub lessons, we put in everything we learn. And inside the source folder, we're going to put in
everything about the projects. Now,
let's run the summary tiers and see what we're going to guys. Now, I'm going to head into the console and we're going to type node source for/ summar. Then we're
going to tap in and let's see what we're going to get guys. Now let's wait a bit and actually going to see they're going to start generating the summary. Okay,
now let's wait a bit and see what we're going to get here. Yeah, you can see that actually they are generating the summary and then here we are going to
wait a bit. Yeah, you can see actually we have here collect summaries. Okay, we
are collecting a big chunks of summaries and then we're going to collapse them into smaller summaries. Okay, in order to get the final summary. Okay, now in here you can see collapse summaries.
Collapse summary and here you can see they generate the final summary. You can
see that actually works. Okay, now this summary includes the reasoning of the air. Okay, based on the provided
air. Okay, based on the provided summaries, the main themes can be cons consolidated into the following core areas. You can see core prompt
areas. You can see core prompt engineering and optimization. The
foundation involves systematically structuring input to improve model outputs. Okay, you can see this is the
outputs. Okay, you can see this is the summary generated by the AI and it's really good guys. Now we're going to learn how to generate the study guides
of a given document. Okay. Now you can see in here I'm going to go back to escalator.com and in here you can see actually we finished generating the summary. Now we're going to generate the
summary. Now we're going to generate the study guide using the same technique.
Okay. We're going to use the map reduce technique in order to generate this study guide. Okay. Now I've already do
study guide. Okay. Now I've already do that. Now I'm going to copy the stud
that. Now I'm going to copy the stud guide. Okay. I'm going to copy
guide. Okay. I'm going to copy everything in here and then we're going to the source folder. I'm going to put in the static pass here static. Yeah,
we're going to pass a stud guide the TS like this. And then I'm putting this
like this. And then I'm putting this code is the same thing, the same logic in here. I just modify only the prompts.
in here. I just modify only the prompts.
Okay. Now you can see in here we I just modify here the prompt. You can see create a structure study notes for the following for the following text
includes key concepts for or definitions example or illustrations important points format as bullet points. Okay.
And in here just modify only the prompts. Okay. The technique is pretty
prompts. Okay. The technique is pretty much the same thing. Okay. And we're
going to generate here the briefing talk. Now I'm going to copy this file.
talk. Now I'm going to copy this file.
I'm going to copy everything in here and we're going to put it into the source folder and pass here briefing doc.ts like this. And you can see in here guys
like this. And you can see in here guys I just modify only the prompt inside the briefing docks but also inside the studs only the prompts. And here you can see create a professional briefing documents
for the following text include summaries of main ideas few takeaways actionable insights or recommendations. Okay, this
the we use the same technique in here guys. But also inside the study guide
guys. But also inside the study guide here I just modified to the prompt.
Yeah, you can see the following are the study guide chunks. Okay, distill these into a single coive study guides.
Maintain key concepts, examples and main points. Yeah, I just modify only the
points. Yeah, I just modify only the prompt in here too. Now you can see in here I've already run the study guide here. I run it. Okay. And we have here a
here. I run it. Okay. And we have here a study guide of this document. You can
see this these final study guides include the reasoning of the AI and the user wants the user wants me to distill multiple study guide chunks into a
single query version. The original
content covers prompt engineering techniques, general thoughts, augmented models, instruction tuning and some JavaScript snippets. Okay, you can see
JavaScript snippets. Okay, you can see this is the final study guide generated by the AI. And now we're going to generate to the FAQ. I'm going to pass
here generate FAQ.ts.
In here too, I modify only the prompts.
Okay, I'm putting this code. And here
too, I just modify the prompt. Create a
set of FAQ questions questions and answers from the following text. Each
FAQ should include a clear question, a concerned accurate answer. Okay, for
matters, a list of Q&A, okay? And this
the prompts and it's going to works pretty well. Okay, once you run it, try
pretty well. Okay, once you run it, try to run it and see what you're going to get. All right, guys. Now, going to
get. All right, guys. Now, going to learn how to generate a mind map. You
can see that actually we already finished generating an FAQ the summary a sorry guide a briefing do about this p that talks about prompt engineering now
we're going to learn how to generate a mind map on it okay and at the end we're going to learn how to generate an audio and a video and after this after this
section guys we're going to uh work on our back end I'm going to try to finish it we are going to refact our back We're going to build the express server. We're
going to set up the off using Google.
We're going to integrate drive. We're
going to build the use API, not API, set up react projects, build UI, build UI and API integration inside of our React app. And at the end, we're going to work
app. And at the end, we're going to work on the audio and video. So, what is a mind map? A mind map is a diagram that
mind map? A mind map is a diagram that has to visualize a topic in order to make it easy to understand. Now we going to take we going to take a documents and
then we're going to generate a star guide and once we have here star guide we're going to use in order to generate a mindm map. You'll see that actually
I've run this file stud guide we have here at the end a story guide. Okay this
the star guide about this page. Now
we're going to take this target guide and then we're going to pass it to the LLM in order to generate a man map. Now
in order to generate a mind map we're going to use man elix library you can see man elix is an open-source JavaScript library that we're going to use in order to for visualization okay
you can see in here we have a mind map here okay our mind map is going to looks like this and here you can see here's a demo I've generated this mind map on
this page that talks about prompt engineering you can see we have advanced prompt engineering we have advanced reasoning You can see we have chain of thoughts, self consistency. You can see
this is a mind map that that I've generated on the page. Now, in order to generate the mind map, we're going to use my elixir. Mind elixir. We pronounce
it mind elixir. And heading to tutorial, we're going to install it later on.
Okay. Now, to generate the mind map, we're going to force the llm to return this kind of object. Okay. That we're
going to pass to the man elix instance.
Okay, we're going to tell our LLM to return an object that looks like this.
You can see we have here node is an object. We have ID, the topic, the we
object. We have ID, the topic, the we have a children property and this is the a parent node. And then here you can see this parent node can have children.
Okay, we have here children. Okay, this
this is the children. You can see sub one topic sub one and then this children note this ch and then this child node can have also children. You can see we
have here one child okay id and so on and then we're going to pass that object to the man elixir instance to generate the man map. Now you can see here inside
the source folder I've already create the manmap ts and I define here the object that the lm is going to return.
Okay, you can see I pass it the ID topic and then this is the same shape here that we have on my leg documentation.
You can see we have the same object that going to that we're going to tell the lm to return. And then I'm going to to take
to return. And then I'm going to to take it and pass it to to to the man elix data z object and then pass a node data
and we pass my elix node. Okay. And we
pass you the lm but also the prompts.
You are an expert level troer in the education department. Your task is to
education department. Your task is to create a mind map that enhances students understanding and retention of complex concepts. The mind map should be
concepts. The mind map should be visually appealing, organized and comprehensive. Accuracy, clarity, and
comprehensive. Accuracy, clarity, and relevance are called success factors. We
pass some rule. Okay. And you can see we have here the 11th rule. Do not include any text outside of JSON. And we have here pass here O is equal to open Kelly.
Close kelly brace. I don't pass here because if you pass here, they're going to consider it as an input. And in here pass here this style. I pass here OS
open kill brace and cs close cy brace.
And then we pass here the man elixir shape. Okay the node is an
shape. Okay the node is an okay we pass here an open kil brace. We
pass the parent object but also we pass it the children. And here we have here another child and then this child too
can have children and so on because this is a recursive object. And then here we pass it the study guard. And at the end we tell the LLM to output a man map as
JSON o and fully compatible with man elixir.
Now you can see pass the prompt to the llm and then we pass here the generated study guide. You can see I've copied
study guide. You can see I've copied this study guide here. I've copied that and I pass to the llm and then and we
pass here the response for passes z to JSON schema and we pass the man elix and here pass here JSON pass chain result contents and we're going to pass
here JSON stringify in order to see the JSON. Now if we head into the console
JSON. Now if we head into the console you're going to see results of the mind map.ts file. It's going to looks like
map.ts file. It's going to looks like this. The LLM is going to return us this
this. The LLM is going to return us this kind of data. Okay. And we're going to take this object. We're going to pass it to the man instance in order to generate
a mind map. And for demo purpose, I'm going to head into inside my react app here. And then you can see I've passed
here. And then you can see I've passed here this object. And then I pass it into the mans instance. And then with something like this, you can see we have
here a man map. Okay. We going to create an endpoint in order to return this data that we're going to pass to the man index instance. You can see that it
index instance. You can see that it actually is pretty easy. Now we going to refactor our back end but also we're going to create our express save. Okay.
Now we're going to head into the source folder. We're going to pass here app
folder. We're going to pass here app folder and inside the app folder I'm passing HP and inside the HP folder we're going to put in controllers folder. Okay. We're going to put in all
folder. Okay. We're going to put in all our controllers and here I'm pass here off I'm pass I'm pass here off folder and we're going to pass here not folder
okay like this not folder and inside the app folder I'm going to put in exceptions exceptions folder where we're going to put in errors and I'm going to pass here another folder and name it
bootstrap okay and inside the yeah we're going to yeah I'm going to move the exception inside the bootstrap folder but also going to pass here express
folder like this and inside the express express folder I'm pass here express server okay like this this file and
we're going to create here function and here I'm pass here express server okay like this and then we're going to
export it yeah like this and inside the boot folder I'm passing file index ts and I'm going to pass here export
function and I'll pass you bootstrap app bootstrap app and then yeah like this bootstrap bootstrap app and then we're going to export it like this. Now at the
root of the source folder I'm passive the index.ts file index.ts file and let's create here another folder pipelines. I'm going to import the
pipelines. I'm going to import the briefing doc into the pipeline folder generates generate FAQ. Okay. pass it in here everything.
Okay, I'm going to move to the key of a WTS going to move everything there and we have here the pro ring fusion. I'm
going to pass everything in it. Okay,
we're going to put in everything in here. Okay. Okay, like this. And here
here. Okay. Okay, like this. And here
I'm going to import express. We already
installed it. So we want to pass import express from express and pass here cons app is equal to express. Yeah, like
this. And here I'm passport port is equal to process dam.
Yeah, we're going to pass it the ports.
You can see if we head into the dam, we don't have here the ports variable and pass here ports like this. And we're
going to pass here 8,000. 8,000 like
this. Yeah, I'll pass the ports. Yeah,
like this. And we're going to import also the here and pass here like this to get access to our environment variable.
Okay. Now, let me check here. We pass
here for/config. That's what we're going to pass in here.
SL config like this. And in here we're going to call the function bootstrap app. Okay, like this. We're going to
app. Okay, like this. We're going to pass it the express app and I'm pass it the ports. Yeah, I'm pass here the ports
the ports. Yeah, I'm pass here the ports like this. Okay, now let's head into the
like this. Okay, now let's head into the bootstrap. TS file and then we're going
bootstrap. TS file and then we're going to pass it the express app and pass the express. And then pass here the port.
express. And then pass here the port.
The port is a number. Yeah, like this.
And here. Yeah, you can see actually it can be a string and here I'm going to pass here pass in okay like this and then I'm set it to a string like this
and now let's go back in here and here I'm going to pass the type and pass the type is express app and pass express
and pass import we are going to import the express type express from and passive from express Yeah, like this.
And then we're going to pass it. Yeah.
And pass here express. Yeah, like this.
Okay. And here express.
Yeah, like this. Yeah, actually we actually we have an gas. And you can see we have here installed the express stats. Okay. Now, in order to install
stats. Okay. Now, in order to install the express tab, we're going to copy this line and then we're going to head into our console. I'm going to pass it
in here. Okay. npm install d-save and
in here. Okay. npm install d-save and then add tabs for /express. Okay. We're
going to type in. Now let's head into the express server. TS. In here we're going to pass to the express server function the express app but also the ports. We're going to enable course by
ports. We're going to enable course by importing the course module. And here
we're going to pass it to ma the express that JSON and the express URL encoded to parse incoming request. And we're going to pass an end point. Once we tap the base URL of our express app, we're going
to send a message express is app and you're going to pass here after the listen in order to spin up our express server. Now in here I'm going to import
server. Now in here I'm going to import the course module and pass import from course. Okay, in order to enable course
course. Okay, in order to enable course and if you you haven't already installed the course module, you're going to tap npm install course. And here let's go
back here. I'm going to import here. I'm
back here. I'm going to import here. I'm
going to import here express. Yeah,
we're going to import here express like this from express. Yeah, like this. And
now we're going to head into the exception folder. I'm going to pass in
exception folder. I'm going to pass in if I want to pass handle express error like this. The TS and then I'm going to put in this code. Okay, handle
express error. And you can see plus seats free parameter the error the request the response but also the next function if the status is different from 200 we're going to return the status
else we're going to return 500 which means save error okay and then we are going to return here the error now we're going to import the handle expressive
function into the express save at the ts and here I'm pass it to the express app going to pass app the use and I'm
passing endo Express error like this.
Okay. And also let's import the express type and pass import. And then we're going to import here the express
the express tab from express like this.
Okay. And we're going to import also the request type but also the response type.
Okay. I'm going to copy that and then I'm going to pass into the express servers in here like this. And
everything is and everything is okay in here. And now we are going to go into
here. And now we are going to go into the index.ts and then we're going to call the expressive again. Okay. And
here we're going to pass you this function expressive. We're going to pass
function expressive. We're going to pass it the app but also the port like this and then we're going to import it. Now
we're going to install another module which is the TS config path. And we're
going to use this module in order to define path alias for module resolution in Tcript projects. And you're going to cap this command in order to install it.
And then we're going to head into inside the I'm going to head into the packet JSON file. And here I've already
installed it. Okay, you can see TS
installed it. Okay, you can see TS config. I got the module. Now I'm going
config. I got the module. Now I'm going to use the module in order to run our express save. Okay, I'm going to copy
express save. Okay, I'm going to copy this command here and then we're going to pass it in here inside the script section. Okay, and pass it in here
section. Okay, and pass it in here [clears throat] like this. And we going to pass here node mode- exec ts node and
then r tsconfig path /register source folder for/index.ts file and then we're going to run express safe. Now
we're going to try this and we're going to type here npm rundev to run safe.
Okay. And yeah, you can see actually I have an error. And to get rid of this error, I'm going to pass here. Here I'm
passing common JS. We're going to tell NodeJS to consider our JS files as common JS. Okay? Because we're going to
common JS. Okay? Because we're going to compile our TS files to common JS. But
also going to ahead into the TS config.json.
config.json.
And here too, I'm going to pass here common JS. We're going to compile to
common JS. We're going to compile to common JS. Okay? Like this. And I'm pass
common JS. Okay? Like this. And I'm pass ES6. Okay? like this. Now, let's see
ES6. Okay? like this. Now, let's see what we're going to get in here. And
guys, don't forget to install something here. Let me show you. Yeah, here we
here. Let me show you. Yeah, here we have an error. Yeah, nothing here. We
are going to head into the package again. And you're going to install tabs
again. And you're going to install tabs for tabs for/course. Okay. Now, we're
going to set up the authentication.
We're going to install some package here like extra session. We're going to install passport but also we're going to install passport Google off. Okay.
Install this free package. Okay. Now in
order to get the API keys we are going to hit up here. We are going to type Google of and then we going to you're going to click here using Google using o
of tool. Okay. Click here and then
of tool. Okay. Click here and then you're going to move to this page here.
Okay. Once you move to this page, you're going to scroll a little bit and then you're going to click here Google API console. Now once in here you're going
console. Now once in here you're going to click here and then you're going to create a project and here I'm going to create a project and I'm pass a note I'm
pass notebook alarm clone like this and then yeah we are going to click here create and once you choose the projects
guys you're going to look you you're going to get you're going to see this menu and then you're going to look for Google APIs. Okay, I'm going to scroll
Google APIs. Okay, I'm going to scroll down and then let me go here. You can
see we have here at the left we have API and service. Click there. You're going
and service. Click there. You're going
to see this interface and head into credentials. And actually you can see we
credentials. And actually you can see we have here a warning and in order to get API keys we are going to head into first
in the of console screen and then in here we are going to set up something in here and I'm going
to click here get started. You're going
to head into click here get started get started and then here you're going to pass here the app name again I'm passing notebook alarm and yeah I'm
passing my email and then next here I'm going to pass here internal yeah I'm pass external and then next again and here we're going to pass I'm pass here
my email again okay I'm pass this andgmail.com account. We're going to
andgmail.com account. We're going to click next. And here I'm going to click
click next. And here I'm going to click agree. Continue create. Okay.
agree. Continue create. Okay.
Once done, you're going to click here data access. Okay. And once you click on
data access. Okay. And once you click on data access, we going to add here scope.
We're going to click here add. And we
going to select here email and profile.
Okay. And I'm going to ch I'm going to pick here to this. I'm going to copy this. And then I'm going to pass it
this. And then I'm going to pass it right here. Okay.
right here. Okay.
We're going to add here another scope which is drive read only because we need to get access to drive files. Okay,
we're going to pass this. We're going to tap inner. Okay, let me first let me
tap inner. Okay, let me first let me first select this one. I'm going to click here. Add. Okay. And then I'm
click here. Add. Okay. And then I'm going to click here again. I'm going to click here again. Add scope again. And
here I'm going to add this one here.
Okay. I'm going to I'm going to copy.
Let me pass these two line here. And
then we're going to add here.
We're going to add here Google Drive.
Let me pass them at the bottom. We're
going to pass here drive down read.
We're going to pass here drive down read only but also drive that file. Okay. In
order access to get access to drive files. Okay. And then I'm going to click
files. Okay. And then I'm going to click here add to tables. Add here scopes.
You're going to click here save and then you're going to get into and then here we're going to click here create clients and once done we're going to pass a web application and then we're
going to pass here the override JavaScript URL. We're going to pass here
JavaScript URL. We're going to pass here this URL. I'm going to head up into my
this URL. I'm going to head up into my file and then we're going to pass here the base URL of our expressive. I'm
going to copy that and then we're going to pass it in here.
Okay. And pass it in here. Add Yuri and add authorize redirect. And here we're going to pass this URL where they're going to redirect us once the authentication pass. I'm going to cap
authentication pass. I'm going to cap this. And then I'm going to pass it
this. And then I'm going to pass it there.
Yeah, like this. And then I'm going to add it. And then I'm going click here
add it. And then I'm going click here create. Then in here we have an error.
create. Then in here we have an error.
And I'm going to remove this. And then
we're going to add this. Yeah, I'm going to remove this. And then I'm going to remove this two. And then we're going to click here create. And once you click on create, you're going to see your client
ID. You're going to copy that. And then
ID. You're going to copy that. And then
you're going to head into in here.
You're going to pass it in here. Google
client ID. Okay. And pass it in here.
Yeah. Is equal to this. But also we're going to pass here our Google client secrets and I'm going to copy it.
I'm going to copy that and then I'm going to click okay and then I'm going to pass it in here. Now let's head into the expressive that and we're going to
import the passport the express session and Google strategy. Now let's start with express session. Now in order to use express session we going to move
here and here they give us an explanation how to use express session.
Okay and here in order to use it we're going to pass here the use and then we're going to pass here session the we're going to pass the session function and then we're going to pass in this object. Okay, you can see in here we
object. Okay, you can see in here we need to pass here this the secret key receive is equal to false save and save and initialize true and cookie is equal
to true. Here you can see we pass here
to true. Here you can see we pass here cookie we pass an object secure is equal to true in production and you can see we need to set secure to true if our app is
in production. Okay. And then we pass
in production. Okay. And then we pass here that object. Okay. Now we are going to do that inside of our app and here pass it that object and then I'm
checking here if the note ar is equal to production. We're going to pass here set
production. We're going to pass here set trust proxy and here we're going to pass here secure is equal to true and we pass the express session to the express app.
Now we're going to initialize here the passport by passing app use passport initialize and passport session and then here we are going to pass here passport
that use okay and here you can see in here if I click here okay I'm going to scroll up you can see in order to use passport yeah I'm going
to click here you can see we need to pass here passport use and then we're going to pass in new Google strategy we're going pass the client ID, the client secret, but also the callback URL
and we pass it to a function and inside of this function we're going to put in a function in order to store the user inside database. You can see I pass that
inside database. You can see I pass that here client ID client secrets callback your okay and we already define these environments into we and we already
define this environment variable into the data file. Okay. And here once we authenticate, we're going to pass here create user. Okay. We're going to
create user. Okay. We're going to console the user. And here we're going to pass here passport the serialized user and passport the serialized user.
And then here we pass here app.get/g
Google. And then we pass here our scope profile email. And pass it drive read
profile email. And pass it drive read only and drive file. And here we're going to pass here in our endpoint of slashgoogle/cback.
And once we authenticate they're going to redirect us to this page and we pass here process react app euro. We are
going to head into the datam file and then we're going to define it. We're
going to define first the cookie key but also we're going to define the the node and react app euro. Then we're going to pass here another endpoint of /me in
order to retrieve the authenticated user into the session and you can see the tab here we have some typing error and to fix that we're going to install express session tab but also passport google
tabs and in order to install that you're going to get into a command line and you're going to run this command npm install-d tabs for/express session tabs
/ passport and then you're going to tap enter. Now, in order to test the
enter. Now, in order to test the authentication, you're going to get into the audience menu and you're going to add here test user. You're going to pass here the email address that you want to
authenticate with. Okay. Now, pass here
authenticate with. Okay. Now, pass here the email address and then you're going you're going to use it for testing purpose. Now, I'm going to try to
purpose. Now, I'm going to try to authenticate. I'm going to pass here
authenticate. I'm going to pass here localhost. And then local host, we're
localhost. And then local host, we're going to pass here the ports 8000/ Google. Yeah, I'm pass
Google. Yeah, I'm pass Google like this. They're going to redirect us on Google. Okay, you can see we are going to choose an account. Okay,
I'm going to click continue. I'm going
to click here again continue. And then
we are going to you can see in here select what notebook alarm can access.
Okay, this is the name of our app. And
then here I'm going to click here select all. Okay, and then here I'm going to
all. Okay, and then here I'm going to click [clears throat] here continue.
Okay, click continue. Yeah, you can see actually we have here data. You can see this is the created user. You can see we have here the Google ID, the username, the the name. You can see we have here
the family name, given name, the email and you can see this is my email I provided into the audience menu. And I'm
using that email for testing purpose.
Okay. Try to add here an email that you're going to use for testing prepares. And here you can see that
prepares. And here you can see that actually we have here a user. Yeah,
that's good. And now it's time to store the user data into the database. You can
see actually we have the possibility to get access to the user data. Now we're
going to store the data into the database. Now you're going to type here
database. Now you're going to type here mongus.js.com
mongus.js.com and then you're going to get into connections.
Yeah, you're going to get into connection. First of all, we need to
connection. First of all, we need to install it and click here quick. And
then you're going to type npm install mongus here and you're going to copy this line in order to set up the DB connection. Okay. And then we're going
connection. Okay. And then we're going to pass you the name of your database.
And if you don't have MongoDB installed on your computer, you can type here mongodb.com.
mongodb.com.
And then once in here guys, you're going to tap this keyword download MongoDB.
And then they're going to redirect they're going to take you to this page.
And once in here, you're going to choose a MongoDB related to your brain system.
And you can see actually I've already installed Compass. You going to
installed Compass. You going to download it. Okay? And if you don't want
download it. Okay? And if you don't want to download it, you can use the cloud MongoDB. Okay, you can just create an
MongoDB. Okay, you can just create an account and then once you have an account, you can come here and create a project. Okay, and once done, we are
project. Okay, and once done, we are going to head into the app folder. You
can see we have here the app folder here. And in here, I'm pass
here. And in here, I'm pass I'm passing motors. Okay. And I'm like heading to the BRA folder again. and
pass here mongos. Okay, like this. Yeah,
mongos. And we're going to pass here file DB connection. DB connection the TS like this. And here I'm going to copy
like this. And here I'm going to copy here my DB connection. Copy that. And
then I'm pass it in here. Now we're
going to head into the app folder. And
here you can see we have here models.
I'm going to rename it models. Okay. And
inside the models folder, we're going to put in our schemas. Now I'm going to pass the first schema. user schema pass the user schema like this the TS and I
have here the user schema and yeah we have here the user schema okay user schema I'm going copy that I'm cop that and then I'm pass it in here user schema
and for the user schema we have here the name email image Google access token Google refresh token the Google ID okay and now let's create you the node schema
passing node schema yeah node schema ts And I'm going to cop it in here. We have
here. Yeah, this is the note schema. I'm
going to copy that. And then I'm going to pass it in here. For the note schema, we have the name, image, description, user ID. And then here I'm pass here the
user ID. And then here I'm pass here the last schema. Dog schema. Do I'm pass
last schema. Dog schema. Do I'm pass here dog schema.ts like this. We're
going to copy it in here. Yeah, dog
schema. Now I'm going to copy that. And
then I'm pass in here. That's great. And
now let's head into the HP folder. And
you can see actually we are we already create the off folder inside the controllers folder. I'm pass here now
controllers folder. I'm pass here now folder repository.
And we going to pass here of and pass here of controller like this. The TS. Yeah. And pass here. Yeah.
this. The TS. Yeah. And pass here. Yeah.
We're going to pass and pass here.
Create user. Create user controller.
TS like this and inside the repository you're going to pass here user repository and pass here user repository like this TS now inside the user
repository you're going to put in database operation like create update user delete user okay now we're going to pass you user repository and this is a
singleton and we're going to use the singleton to create a single instance of the user repository and I'm going to pass you this okay public static
instance user repository and then we're going to pass user repository that instance is equal to new user repository and this is a singletonone design pattern okay if you don't know what is a
singletonone design pattern you can go learn about it okay and pass singleton design yeah singleton design pattern okay try
to learn it if you don't know how it works okay Now in here we are going to use the get instance function in order to create a single instance of the user
repository. Now in here I'm passing a
repository. Now in here I'm passing a function. We're going to pass here a
function. We're going to pass here a sync function. Yeah, we're going to pass
sync function. Yeah, we're going to pass here a sync create use. Okay, like this.
Okay, and I'm passing some props. We're
going to pass here user props. And I'm
going to define this TS object. I'm
going copy this. And then we're going to head into the tabs folder. And I'm pass here tabs folder. And inside of the tabs
folder, I'm pass here user tabs. Okay.
TS. And in here, I'm passing this objects Google use. Okay. And the Google user we have here the ID. You can see in here we have here the ID. This is a
string. The display name is a string.
string. The display name is a string.
Here you can see we have a display name string. For the name, we have family
string. For the name, we have family name and given name. You can see in here we have the family name and given name.
For the email we have here an array and a pass here for the email we have an array. We pass the value string verify
array. We pass the value string verify is a boolean value. We have here photo is an array. We have here provider and also we have here another JSON property.
Okay, we have here the sub, the name, the given name, family name. Okay, but
also we have here the picture. And now
we're going to tap this property right here. I'm going to copy this object.
here. I'm going to copy this object.
Going to head into the user repository that is I'm going to tap this user props here with the user user Google type.
Okay, like this. I'm passing us a Google type like this. And we can go back in here and then I'm pass here user Google type. And then we going to pass it in
type. And then we going to pass it in here like this. And now let's create the user. Yeah, we can we can head into the
user. Yeah, we can we can head into the user schema. Pass here user schema. We
user schema. Pass here user schema. We
can copy this. And I'm going to pass it in here. Okay. And then I'm going to
in here. Okay. And then I'm going to comment this one. Okay. I'm pass this here. And then I'm going to pass it cons
here. And then I'm going to pass it cons is equal to user props.json.
Yeah, like this. JSON like this underscore JSON. The sub here and pass
underscore JSON. The sub here and pass here this the ID. Going to pass it the name. And we can pass here the we're
name. And we can pass here the we're going to pass here the picture. And
we're going to extract to here the email like this. And then we're going to get
like this. And then we're going to get rid of this object. And then we're going to pass here access token and refresh token. I'm going copy that. And then
token. I'm going copy that. And then
we're going to pass it in here. Yeah,
like this. And I'm going to pass here another props token like this. And here
we're going to pass here token. And pass
it token. And then pass here access token. And we're going to pass it token.
token. And we're going to pass it token.
And then option training refresh token.
Yeah. Like this. Yeah. And everything is okay in here.
Yeah. And also we we need to pass here the Google ID. You can see we have here the Google ID and pass it in here ID like this. Yeah. And now we're going to
like this. Yeah. And now we're going to create the user here. I'm going to create the user and pass here cause
created and pass here new user is equal to awaits and I'm pass user save like this. And once we create a user, we need
this. And once we create a user, we need to generate the access and refresh token. And in here guys, we are going to
token. And in here guys, we are going to install JSON web token. Okay, we're
going to copy this and we're going to head into the command prompt here. I'm
going to shut it down. And then we're going to tap here npm install JSON web token. I'm copy that. And then we're
token. I'm copy that. And then we're going to pass it in here. And then
you're going to tap in. And now what I'm going to do, I'm going to create the helpers folder. I'm going to pass here
helpers folder. I'm going to pass here I'm Yeah, we going to pass here. Yeah,
let me head into the app folder and pass here helpers helpers. And then we're going to pass a JSON web token. Okay,
JSON web token.ts like this. Now in
here, we're going to define a function JSON web token payload. and we pass it the user ID and then we're going to return the payload. Okay. And the the payload is an object that we're going to
use in order to generate the sign in token but also the refresh token. And
you can see in here this says this when we call the signing function we need to pass it the payload. And then after the payload we're going to pass here the
secret key. And now here I'm going to
secret key. And now here I'm going to define a function sign access token.
We're going to pass the user ID. The
type is a string. We're going to pass here JSON web token in order to get the payload. We pass that here and pass your
payload. We pass that here and pass your process JSON JSON web token key. And we
are going to head into first inside the data file. And here we're going to
data file. And here we're going to define the JSON web token key and the refresh token key. And in here we are going to pass here a promise. We're
going to return promise. Going to pass a JSON web token. And we're going to pass the sign function. And we're going to pass the payload in order to generate token the key. And here we pass the
callback. And in here we check if we
callback. And in here we check if we have an error. We're going to reject an error. And if we have an [clears throat]
error. And if we have an [clears throat] error, we're going to resolve the token.
And we define in our function sign refresh token in order to generate the refresh token. And we pass here the
refresh token. And we pass here the payload the key. And we define if promise. And then we pass here JSON web
promise. And then we pass here JSON web token sign. We pass the payload, the key
token sign. We pass the payload, the key and the callback. And if we have an error, we're going to reject it. If you
don't have an error, we are going to resolve the token. We're going to define another function verify express token.
And we're going to pass it try catch.
And here in case the token is invalid, we we are going to return message and authorize. And here we're going to pass
authorize. And here we're going to pass the token. We going to get access the
the token. We going to get access the token. We're going to pass here the
token. We're going to pass here the headers. And we're going to pass the
headers. And we're going to pass the authorization because we are going to send the the token into the authorization errors. Okay. And then
authorization errors. Okay. And then
we're going to extract the token by passing your token.plit and then we're going to extract it. And we're going to pass here the JSON web token key. And
then we're going to pass here JSON web token verify. We're going to pass the
token verify. We're going to pass the access token the key, but also the payload. We're going to check if we have
payload. We're going to check if we have an error. We're going to f error. And if
an error. We're going to f error. And if
you don't have an error, we're going to continue. Okay. We're going to override
continue. Okay. We're going to override the user to get access to a particular resource. Now you can see in here guys I
resource. Now you can see in here guys I just did copy paste everything is from here guys. Okay you can see in order to
here guys. Okay you can see in order to generate token we need to pass here JSON web token that's sign we pass the payload but also the key. Okay. And in
order to verify the token, we need to pass here this code JSON web token that verify we pass token and you can see we pass here the the JSON web token key in
order to verify the key and pass here the payload is pretty easy guys and try to implement this. Okay, now we're going to head into the user repository. I'm
going to pass user repository and in here you can see we already pass here this code in order to create the user.
Now I'm going to check if the user exists inside the database and we're going to pass here wait and pass here the user schema find one function and
we're going to pass here the email and pass here the email like this and here if and here we're going to check if the
user doesn't exist inside the database.
Okay, if the user doesn't exist we're going to create the user and we are going to generate the access and refresh token. Okay, pass here cons. We're going
token. Okay, pass here cons. We're going
to pass here create I'm pass created user like this and we're going to pass here created user and I'm passing access
token and here I'm passing refresh token like this. Okay, and is equal to a
like this. Okay, and is equal to a weight. We're going to pass here I'm
weight. We're going to pass here I'm passing parame and here we're going to pass here an array. And now what I'm going to do,
array. And now what I'm going to do, we're going to pass here access token and pass here sign access token like this. And here going to pass here new
this. And here going to pass here new user new user object id. Okay, you can see guys that actually have here a typing error. And if you put our cursor
typing error. And if you put our cursor over the underscore ID, you can see tab screen infers it to be a tabs of tabs object ID. Okay. Now what I'm going to
object ID. Okay. Now what I'm going to do, I'm going to head into the access token and in here I'm going to pass here this type. Okay. And then I'm going to
this type. Okay. And then I'm going to import types from mongus. Okay. Yeah,
like this. And here too I'm going to pass here this types. Okay. Like this to remove the error. And let me pass it here. JSON web JSON web token payload
here. JSON web JSON web token payload pass there. And here too I'm pass it in
pass there. And here too I'm pass it in here. Okay. like this and everything is
here. Okay. like this and everything is okay. Now if head into the user
okay. Now if head into the user repository user repository and here we don't have here an error.
Now we're going to generate the access token the refresh token pass here sign refresh token pass it here and we're going to pass here the ID like this and
once we generate the access and refresh token we're going to use that in order to authenticate the user going to pass of data this property. I'm going to copy the mongos instance which is the new
user. Okay, we're going to pass here to
user. Okay, we're going to pass here to object to convert the mongus instance to a plain JavaScript object and pass it to object and we're going to pass here the token key pass token and inside of it
we're going to pass in the access and refresh token. pass here access token
refresh token. pass here access token like this and then pass here refresh token like this and if the user exists inside and if the user exists inside the
user table we are going to return the existing user and here I'm passing and pass existing user like this and then we're going to copy that and pass it in
here okay like this and I'm pass going to return this object okay and we're going to pass you to this line okay we're going Copy that. We're going to
pass it in here. Now, instead of doing this, we're going to head into the JSON web token. TS file. We're going to
web token. TS file. We're going to define a function generate token. So,
we're going to pass the user ID and then we're going to pass here a weight. And
inside of it, we're going to pass a sign access token. And we're going to pass
access token. And we're going to pass here sign refresh token like this. And
now we are going to return here. We're
going to return here these two. We're
going to return here the access and refresh token. I'm copy that. And then
refresh token. I'm copy that. And then
we're going to pass it in here. Now
we're going to go back into the user repository. And then I'm going to get
repository. And then I'm going to get rid of this function here and pass here.
And I'm passing generate tokens.
Generate tokens like this. And we're
going to extract here the access and refresh token. Okay. Pass here this. We
refresh token. Okay. Pass here this. We
have here the access and refresh token.
Okay. Like this. And yeah. And we are we need to pass here the user ID and pass in new user. Yeah, I'm pass here new user like this. And then I'm pass here
underscore id like this. And we're going to copy that. We're going to pass it into the else statement. And I'm pass it in here. Okay. And here we're going to
in here. Okay. And here we're going to pass here existing use and pass here existing use like this. And here we're going to pass here existing use ID like
this. And everything is okay so far. Now
this. And everything is okay so far. Now
we're going to head into the index.ts file. You can see if we head into the
file. You can see if we head into the app folder, we have here inside the app folder, we have boost wrap folder and we have an index.ts file at the root. Now
we're going to import here the database connection. We're going to pass here a
connection. We're going to pass here a weight. Okay. And then pass a db
weight. Okay. And then pass a db connection like this. And then we're going to initialize database connection.
And now let's head into the express server the TS and in here you can see we have here we have here the Google
strategy I'm going to pass here user repository user yeah I'm pass user repo user repo like this is equal to
user repository and then get instance okay we and then we're going to pass user is equal to user repo create use okay like this and I'm pass here the
profile and the token and we should pass here a weight because the create the create function returns a promise and now we're going to try to authenticate
the user and pass here the user and we're going to run the server here mpm rundev and then we going to try to check
if we going to create a user okay now let's wait a bit and then here we are going to yeah I'm going to head into the browser. I'm going to copy this the base
browser. I'm going to copy this the base URL of our express server. We're going
to get into the browser and I'm I'm pass here. I'm pass it in here. We're going
here. I'm pass it in here. We're going
to pass forward slash/ Google and then we're going to tap enter. And you can see we have here
enter. And you can see we have here another endpoint in order to retrieve the data of the authenticated user inside the session. And I'm going to copy this endpoints. We're going to use
it. Okay. And then here I'm going to
it. Okay. And then here I'm going to click here to continue.
And here I'm going to click here continue again. And I'm going click here
continue again. And I'm going click here continue.
Okay.
Click continue. And then I'm click continue again.
And here we're going to continue.
Yeah, we finish. You can see actually the redirects on this endpoint. You can
see this the base URL of our react app.
And here I'm going to try to check here if we store the user data into the session. And then here we're going to
session. And then here we're going to pass here localhost port 8,000 8,000 for/ of me. Tap enter. You can see actually we have here the name, email,
and the image of the authenticated user.
And we're going to use the Google access token and Google refresh token key in order to get access to drive files. And
at the bottom here we have another object we having in the access and refresh token generated by JSON web token package. Now we are going to use
token package. Now we are going to use the Google API keys package and then we are going to have the possibility to get access to the user draft files. Okay.
Now we going to install this package.
We're going to get into our command prompt and then type in npm install and then pass Google API and then I'm type in. Yeah, let me see the name Google
in. Yeah, let me see the name Google APIs. Yeah, we have here an S and then
APIs. Yeah, we have here an S and then here plus here Google APIs and then we going to tap in. Yeah, like this. Tap
this command. Now we're going to head into the controllers folder and pass here drive. Pass it and pass here drive.
here drive. Pass it and pass here drive.
And here we're going to pass in a controller get us use yeah get user and pass here controller get user drive
files like this. the TS and then here we're going to import express we're going to import Google APIs and we're going to create a function get user drive files we're going to pass the free parameter the request the response but
also the next function and in here we're going to pass it try catch in case we have an error we're going to catch it okay and in here we are going to retrieve data or the authenticated user
from the session we're going to pass the user and then we check here if the Google access token is undefined if is undefined we're going 10 no Google
access token found and in here you can see I instantiated here the O of two and everything is from here guys okay I copy
everything from here okay I don't modify anything and then here we're going to set here credential pass here of to client that's set credential we're going to pass here the access and refresh
token that we got into the session we're going to pass here these tokens here we're going to pass there the Google access token and the Google refresh token. And after that, we're going to
token. And after that, we're going to get access to drive file. We're going to pass here Google. Drive. We're going to specify here the version and we're going to pass here the off client. And then
here we are going to return here an array of 10 files. And then in case we have an error, we're going to catch it.
And now we're going to create another file into the drive folder. I'm pass
here drive roots. Okay, I'm passing roots folder first. And in here I'm pass.
Yeah, I can just pass it. Yeah, I'm pass it drive roots the TS. And in here we're going to pass the expo function. And
then I pass it drive roots. And we're
going to pass it the router. We're going
to we're going to tap it. And we're
going to And here we're going to import router from express. Let me import it from express like this. And here I'm
passing router dot get here pass here I'm pass here user for sl users for slashfiles okay like this and here we
going to pass here the function and we're going to import here get use drive files going to pass it in here and then I'm going to return the router yeah like this and now we're going to head into
the app folder you can see this the app folder And here I'm going to move here at the root of the source folder and
pass here roots. Okay. And here I'm pass here API v1 v1.ts like this. And in here
we're going to create to a function API v1 and I'm pass it the express app and I'm pass express like this. We're going
to import a type and we're going to pass it the router and we're going to import to the router from express and here what I'm going to do in here and pass here
draft roots drive roots like this is equal to drive I'm going to import draft roots and we're going to pass it the router and then here what I'm going to
do I'm going to return here I'm going to pass here app use you can see we have here the express app We are going to
we're going to pass here app use and then pass here API for slashv1 and then we're going to pass here drive roots like this. Yeah. Okay. Everything is
like this. Yeah. Okay. Everything is
okay in here. Okay. I'm going to pass here drive.
Yeah. Drive roots like this. Okay. Drive
roots like this. And yeah, everything is okay. Now we're going to import here the
okay. Now we're going to import here the router type. And we're going to import
router type. And we're going to import here the expert type and pass here express type. Okay, like this. Yeah,
express type. Okay, like this. Yeah,
everything is okay in here guys. Now
we're going to head into the express server thetas and here I'm pass here if I'm and pass here I'm and here I'm going
to create an instance. I'm passing cons router is equal to router. Okay, we're
going to import the router instance from express. Yeah, I'm going to import it
express. Yeah, I'm going to import it from express. And then what I'm going to
from express. And then what I'm going to do, I'm pass API v1. We're going to import it. And
API v1. We're going to import it. And
then you can see that actually it takes two parameter. We're going to pass it
two parameter. We're going to pass it the express app. And also I'm going to pass it the router like this. Okay.
Router and express app. Yeah, that's
good guys. And now I'm going to run this and see we're going to get some passes in here. Okay. like this and we are
in here. Okay. like this and we are going to head into the drive roots and pass the drive roots and we're going to try to eat this endpoints and let's head into the browser. Yeah, we forgot to
pass here the access the Google access token and the Google refresh token. Now
let's pass these two keys before we try before we test this endpoints. And here
you can see we have here the user and I'm going to pass here if we pass here user rect the user we get something like this we have here an object and here I'm
going to cut this and then we're going to pass here and pass user yeah we're going to pass here user option chaining and then pass
here of data and we going to copy here the Google access token but also we're going to copy the Google refresh token. Okay. And I'm
going to cop here the Google refresh token here. And I'm pass user of data
token here. And I'm pass user of data like this. And then pass here Google
like this. And then pass here Google refresh token like this. Okay. And here
too we should pass here of data. Okay.
And guys, make sure you pass option change. In case we don't have the of
change. In case we don't have the of data property, we're going to get here and define. Okay. If you don't pass
and define. Okay. If you don't pass this, they're going to throw an error in case this property doesn't exist. Now,
let's head into the brows and try this.
I'm going to refresh this end points here and try to see if we're going to get data. Okay, if I tap enter, you can
get data. Okay, if I tap enter, you can see actually we don't have the data into the session because in here guys, we we restarted our express server. If I shut
down or I tap here, if I shut down or I rerun our Excel server, we're going to lose data into the session. Now, in
order to keep the data from the session, we going to install in our package here.
The name is connect Okay, you're going to type here npm install connect And once you and once you install connect you're going to copy. You're going to
pass this in here. We are going to head into the express server and then in here I'm passing this object. You're going to pass here store store that creates
okay like this and we're going to import [clears throat] that here and I'm going to copy Okay, we're going to import it from the connect and I'm
pass it edit type in here and again if we have data into the session and we restart it here our express server we aren't going to lose data. Now let's
rerun our express save again here. I'm
going to rerun it. npm and pass npm rundev here. And then we're going to get
rundev here. And then we're going to get data. Okay. Now I'm going to tap here
data. Okay. Now I'm going to tap here this. We're going to authenticate again.
this. We're going to authenticate again.
And here I'm pass here this pass loc/ Google. And then we're going to tap
Google. And then we're going to tap enter. And then here I'm going to click
enter. And then here I'm going to click continue. And we're going to click here
continue. And we're going to click here again continue.
And then here I'm going to click continue. Then we're going to be
continue. Then we're going to be authenticate. And I'm type here loc
authenticate. And I'm type here loc 8000/ of meme. And then I'm tap enter.
And then you can see in here we are authenticated again. We're going to type
authenticated again. We're going to type here loc/ API/v1/ users/files.
And then we're going to tap in. And
we're going to have your data. Okay. We
don't have data in here. Let me head into here. You can see that actually we
into here. You can see that actually we have here an error and Google Google Drive API has not been used in this
project before or it is disabled. Enable
this project by visiting we going to visit this endpoint and then we're going to enable Google Google Drive API. Okay.
Now we're going to head into this browser and then I'm taper.
Okay. And we're going to enable Google Drive. Okay. You're going to head into
Drive. Okay. You're going to head into enable APN service and then here we are [clears throat] going to fix that error. Okay. And here
I'm going to click here enable. Okay.
And once we enable here we can get access to files. Okay. Now what I'm going to do I'm going to go back in here and then I'm tap enter and see what we're going to get. Yeah. You can see in
here that actually we have here an array of files. Okay. We have here data. Okay.
of files. Okay. We have here data. Okay.
From Google Drive. Okay. And you can see this is a SQL file. And yeah, you can see this the M tab. And if I scroll at
the bottom here, okay, we have here data. Okay, I'm going to try to click here.
Okay, I'm going to click here on this file and see what we're going to get here.
And you can see guys that actually we have the possibility to view a file.
Okay, we have the possibility to view the contents of a given file and we can edit it too. Now we're going to move to
not API and in here you can see this is the UI of notes and in order to create a note we're going to run through some steps and you can see in here a note an
image but also the title. Now in order to create a note we are going to upload a file.
>> [clears throat] >> This file can be a PDF or web file and then we're going to pass it to the file loader in order to extract the content.
And once we extract the content, we are going to pass it to the text splitter in order to split this document into chunks. And then we're going to use the
chunks. And then we're going to use the first and the second chunk in order to generate the title. We are going to pass these chunks, the first and second one to the LLM in order to generate taro.
And once we have the taro, we are going to take this tar. We're going to pass it to the prompt generator. The prompt
generator is an agent that is going to generate a prompt that we can use in order to generate an image about this title. And then we're going to pass this
title. And then we're going to pass this prompt to the image generator. And then
we're going to get the image. Okay. Now,
we're going to head into the controllers folder. You can see we have a
folder. You can see we have a controllers. And what I'm going to do
controllers. And what I'm going to do here, I'm passing notes like this. And
in here we're going to pass here repository.
Repository like this. And I'm going to head into in here we have a repository.
I can cut everything in here. And we're
going to put it into the notes for / repository. I'm pass here nodes repos.
repository. I'm pass here nodes repos.
Yeah, I'm passing not repository.ts like this. And then I'm going to put in
this. And then I'm going to put in everything. And now what I'm going to
everything. And now what I'm going to do, I'm going to modify in here the name of this repository. I'm click here Ctrl F. And here I'm pass here not
F. And here I'm pass here not repository. And then I'm click here
repository. And then I'm click here replace all like this. Now we are going to pass here a function create note
here. We're going to pass here
here. We're going to pass here create note like this. And to create a note we're going to pass here the name.
Yeah, I'm going to pass here. Yeah, I'm
going to remove this. I'm remove this.
I'm going to pass it the name only. Let
me check here. We are going to head into the note schema. Node schema. And you
can see in order to create a note, we have here name, image, and description.
For the description, I'm not I'm going to remove that. I'm going to remove that. Okay. Going to remove that. We're
that. Okay. Going to remove that. We're
going to stay only with the name, image, but also the user ID. Now let's go back in here passing the name.
In here we're going to pass here props and pass here props like this. And then
we're going to pass the name is a string and we're going to pass here the image and use yeah and pass here the we're
going to pass the image and the user ID like this and I'm pass string too. We
are going to copy these props here and pass the props like this and see pass here.
Yeah, we are going to pass here notes now and some pass I'm passing new notes and then is equal to a weight not save
like this. Okay, let's remove everything
like this. Okay, let's remove everything else here. Okay. Yeah, I'm going to
else here. Okay. Yeah, I'm going to remove that here.
Okay, and we are done in here. which
just create a note here. And then I'm going to return here a created note and pass here not like this. Yeah. And then
pass here to object. Yeah, like this.
And once done, we're going to head into in here again. We're going to pass here get and pass here create note controller.ts.
controller.ts.
And in here, we're going to pass export function. Pass here is sync like this.
function. Pass here is sync like this.
function create notes and we are going to pass it some parameter. Let's head
into the create user control ts. I'm
going to head into in here guys into the draft folder and then we're going to cut the we're going to copy this express types and then we're going to pass it in
here. Okay, let me pass that here and
here. Okay, let me pass that here and then I'm going to go back again into the get get used drive files. Okay, in here
we are going to cap this parameter. We
are going to pass it in here to the nodes controller right here guys. Now
we're going to pass it right catch. In
case we have here an we're going to pass it to the express passing next function and then pass the error and we're going to call here the not repository. Not
repo is equal to I'm passing not repository and we're going to pass here that get instance. We are going to pass here new nodes is equal to await and
pass here nodes repo create not and we're going to pass to the create function. We're going to pass the name of the node which is the taro and we going to we're going to pass the
name and the image but also the user ID.
Okay, like this inside the note folder we're going to pass here loader. Okay,
loader is the TS and in here we're going to import here text loader recursive text splitter GD web as loader and we're going to pass here the PD and we're going to pass here the PDF loader and
we're going to create a function split docs to chank. [music] I've already explained you what is the recursive character class. It allows to split an
character class. It allows to split an array of documents into chunks. And then
here we're going to pass here webbased loader. We pass here the PDF loader. We
loader. We pass here the PDF loader. We
pass here the text loader by passing here by instantiating the new text loader class. And here we define a
loader class. And here we define a function load documents. And then we're going to pass it the file path do type and we pass it the chart and check
overlap. And then in here we have a
overlap. And then in here we have a condition. We check if the file type is
condition. We check if the file type is equal to PDF. We're going to we're going to call the load PDF function. If is
equal to HTML, we're going to call the load web function. If is equal to a txt we're going to load we're going to call the load text function. Okay. Else we're
going to throw an error and support a file and then we are going to take the file we're going to split it into chunks by calling the split do to chain function. And in here we're going to
function. And in here we're going to create the title generator pipeline in order to generate title. And we're going to import here some class. We're going
to import here first some package. And
we're going to define here prompt in order to generate title based on the do content. You can see you are helpful
content. You can see you are helpful assistant that generate concise and clear titles based on the following document content. Create a single title
document content. Create a single title that captures the main theme or subject of the documents. Okay. And we pass the documents and we're going to create a
function direct title. We pass the llm and an array [clears throat] of documents. And we take this array of
documents. And we take this array of documents. We're going to convert it to
documents. We're going to convert it to string by passing here format document as string and then we pass it to the lln. And here we call we invoke the llm
lln. And here we call we invoke the llm pass here change invoke we pass here the document and then here we force the llm
to return a taro. Okay. And here pass the mean the min length is 40 and max length is 60. And then we're going to return the title by passing here JSON
pass chain result contents and then pass here result title and we are going to return the generated title. Now we are going to use the title in order to generate the image. Okay. And here we
are going to create first of all we need a prompt generator. We are going to use the prompt generator in order to generate a prompt that we're going to use in order to generate an image. And
here we're going to import some package and we're going to define a function generate prompts. Okay, we're going to
generate prompts. Okay, we're going to pass the llm. And here here's the prompts and we pass the llm a specific ro you are expert prompt engineer for an
for an for an image generator. Your task
is to take the user's input which is a document title and create a single concise prompt to to and create a single concise prompt to generate a logo for
it. Okay. And the prom you create must
it. Okay. And the prom you create must instruct the image generator to produce a minimal list and modern vector icon
that visually represent the title. The
sty should be flat design with a clean with clean simple lines. The final image must be only the logo with a transparent background. Your output should be the
background. Your output should be the prompt itself and nothing more. Here's
the user's input and we're going to pass you the llm the prompt. We're going to invoke the llm and and here we are going to force the
llm to return only the prompt and then we are going to return here the prompt.
We are going to create here another function generate image. Okay. And we're
going to import the the file system module but also the node fetch. And then
we're going to create a function generate image. And then we're going to
generate image. And then we're going to pass here the API key. And then here's the code. Now, in order to get this
the code. Now, in order to get this code, the last to generate an image, you're going to head into your Fireworks account and you're going to click more library. Scroll a little bit. You're
library. Scroll a little bit. You're
going to see image section and you're going to pick here more the last to generate an image. I'm going pick this one, the first one in here. And click
there. And they're going to take you to this interface. You're going to click
this interface. You're going to click here try. And once in here, you can see
here try. And once in here, you can see on this interface, you have the possibility to pass your prompts and generate an image. You can see if I reduce the zoom and at the bottom right
corner we have here generate image at the bottom here. Now at the top right corner we have inner button view code.
Click there you're going to pick this TS code. Copy everything in here and you're
code. Copy everything in here and you're going to put it into you're going to put it into your generate image TS file.
Okay. And once in here guys we're going to pass here. We're going to wrap that code into a function but also don't forget to pass you your API key. And the
first parameter that we're going to pass to the generate image function which is the prompt and we're going to pass the path we're going to pull the image the file name but also the callback in order to get get access to the file name. And
at the bottom here we're going to pass here fs write file in order to write this file to the disk. Okay. Else we're
going to pass this. And now we're going to head into the prompt generator tears.
Prompt generator ti. And in here I forgot to pass here the title. I'm pass
the tar like this and here too I'm going to pass here the tar okay we are going to use the t in order to generate an image okay like this okay now we going
to head into the create note thets and in here we going to check here first if the user send a file if the user doesn't send a file we're going to send this
message no file uploaded okay we're going to pass here no file uploaded okay and we're going To get access to the user ID, we're going to pass here the
current day and we assign it the current working directory function and we pass a path that John pass the current working directory and we going to call the generate title function. We're going to
pass the yellow l but also display document. Okay. And here
document. Okay. And here
we are going to pass here generate image prompts. And we're going to pass the llm
prompts. And we're going to pass the llm but also the taro. And we're going to call the generate image function here.
Okay, like this. And we're going to pass here the generate image prompt. We're
going to pass the prompt the the uploader where the path where we're going to upload the image, the random name of the file, but also the callback.
And in here, we're going to copy this code. We're going to pass it in here. We
code. We're going to pass it in here. We
going to pass to the create, we're going to pass to the create node function. And
we're going to pass it the title. I'm
going to modify here instead of passing here name and pass it the title. Okay.
And here I'm going to pass here the sync like this. Okay. And we're going to head
like this. Okay. And we're going to head into the note schema. Note schema. And
in here I'm pass the taro instead of the name. Okay. The taro like this. And
name. Okay. The taro like this. And
we're going to head into the note repository. We're going to pass here to
repository. We're going to pass here to the taro. Okay. Pass the taro like this.
the taro. Okay. Pass the taro like this.
And now let's go back in here. We're
going to let's import the the current working directory function. We're going
to import here path. Okay, from path and we going to import the generate title function. Okay, we're going to pass it
function. Okay, we're going to pass it we're going to pass the splitting dock but also the llm and I'm going to import here generate prompt function
and here we're going to import generate image function. Okay, like this. Now,
image function. Okay, like this. Now,
I'm going to create here a function that we can use in order to generate a random name that we can pass to an image. And
I'm going to head into my sub text in here. I have this function here. Okay,
here. I have this function here. Okay,
this one here. Okay, I'm going to copy that. And what I'm going to do, I'm
that. And what I'm going to do, I'm going to pass right here. I'm pass it here, guys. And then we're going to pass
here, guys. And then we're going to pass in here random name. We're going to pass it the current date. And here we're going to generate a random number. Okay.
Now we are going to to create here another roots. Here you can see we have
another roots. Here you can see we have here not and pass here roots like this.
And inside the root folder I'm pass here create notes root. Okay. And in here what I'm going to do I'm going to cop some code in here. I'm going to copy
everything in here because all these codes I copied from Malta. You're going
to see, let me pass it first. In here,
you can see in here, I pass the current working directory. And I'm checking if
working directory. And I'm checking if we have the uploads folder into the public folder. If it doesn't exist,
public folder. If it doesn't exist, we're going to create it. And then I pass this malt configurations in order to upload an image. Okay, we got this code in here, guys. We have this code in
here. You can see this the code. I don't
here. You can see this the code. I don't
modify anything. I just copy that. Copy
that, guys. And then you're going to pass it in here. Okay. And we're going to create an endpoint.
I'm going to copy that to here. I'm not
copy that. And then I'm pass it in here.
Let me pass it in here. Okay. Pass it in here. And we pass a router the post
here. And we pass a router the post upload document. We're going to pass the
upload document. We're going to pass the upload. And we're going to invoke the
upload. And we're going to invoke the single function. We're going to pass the
single function. We're going to pass the name of the file. Okay. And we're going to call this function create note here
and pass here and yamna import it in here. Okay, you can see guys I don't
here. Okay, you can see guys I don't modify anything. If you want to tap the
modify anything. If you want to tap the code, you can tap it. And if you want to copy it, you can come here and then you're going to copy it. Okay,
everything comes from here. You can see even for the endpoint pass upload and then I invoke the single function. We
pass it the name of the function and we pass here the express callback. Okay.
And now we are going to continue. I'm
going to head into now into the express server and pass express. And in here I'm going to pass the car working directory.
And then I'm going to expose the public folder. Okay. And I'm going to import
folder. Okay. And I'm going to import here the process but also the path the path match. Okay. Like this. Now we're
path match. Okay. Like this. Now we're
going to create another folder. inside
the app folder I'm going to name it llm and we're going to pass it the llm class in order to return a single instance of the child fireworks class and I'm pass
lmts like this and then we're going to pass in this code we are going to use this class in order to return a single instance of the char fireworks class
okay we pass here cha fireworks okay everything is okay in here now what I'm going to do we're going to go back into the create node.ts CS and in here I'm
going to create a constant lm and name it llm is equal to llm class we're going to import it in here and then pass here
get instance okay and let me check go import here we are going to let me first check here we're going to pass here llm
and then we're going to pass here that get instance okay like this and then we're going to pass here the llm and we're going to call here in our function
I pass con dosplit like this is equal to a weight going to pass you load documents and in here we're going to
pass it the file path and to pass it the file path we are going to pass you the upload I'm pass uploader forward slash and then we're going to [music] pass
here the file name okay and I'm pass here the file name pass here this okay I'm pass here rec and here I'm pass that
file file name like this and yeah we need to pass parameter and for testing purpose I'm going to just pass here a
txt we're going to upload a for testing purpose we're going to pass here a txt I'm going to try to upload a txt file and then we're going to check if they're
going to generate an image and they going to create a note into the notes model okay now we're going to for testing purpose we're going to just pass
txt and yeah everything is okay but also in here we're going to create a constants for the email pass image is equal to process I'm passive process
and we're going to pass the app euro app euro and we going to up and then we're going to pass here the folder where we going to upload the image and I'm going
to pass here the generated name here which is the random name variable we're going to pass that here png. Yeah, I'm
pass here. PNG like this. Okay. And
everything is okay so far. And actually
we have here typing error. You can see the title. Okay. We are going to head
the title. Okay. We are going to head into the not repository. And in here you can see we still pass user user schema.
We are going to pass note scheme. Okay.
Passing not passing not. And we are going to remove the error. Now let's go back into the gray node. TS and here we're going to return a response return
pass status we're going to pass here you one and here I'm going to send a message and pass here message is equal to not
created successfully and pass here successfully like this okay and here we remove this error we still have here an error okay let me go back again to the
not repository and here pass not let's import Okay, like this. And then we're going to remove this typing error. Okay,
everything is okay so far. And actually
we still have here this error. Okay, let
me go back again in here. Let me remove everything in here. And I'm going to import here right now the note schema
like this. Okay, and here we pass you
like this. Okay, and here we pass you the title like this. Okay, everything is okay. Now we going to head into the data
okay. Now we going to head into the data file and in here we're going to pass here the app euro is equal to the base eurova express app and we going to head
into now the API v1.ts and in here we're going to import the create note root cause create note is equal to create nodes root like this. We're going to
pass the router and then we are going to pass here create note. Yeah, like this.
And here guys, I'm going to pass here another function in order to check if the uploaded file is equal to one of these allowed tabs here. If is equal to
PDF, doc, HTML, CSV, txt. And also we pass the maximum file size is equal to 2 MB. And now we're going to head into the
MB. And now we're going to head into the command prompt. We're going to type here
command prompt. We're going to type here npm. Pass here npm rundev.
npm. Pass here npm rundev.
And we're going to head into postman.
And in here we are going to you're going to select you're going to pass the first of all for the endpoint is post. And
you're going to pass api/v1/upload documents. You're going to choose it
documents. You're going to choose it body. And you're going to pass the form
body. And you're going to pass the form data to upload a file. You're going to pass in the user ID. I just copy the user ID into my database. Here you can
see here I have the note schema here.
You can you can copy here the user ID and then you can pass it in here and you're going to pick a file. I'm going
to pick a file into my downloads folder here. I'm going to pick a file send.
here. I'm going to pick a file send.
Okay. And see what we're going to get.
And actually they uploading the file.
We're going to head into the public folder. You can see we have here public
folder. You can see we have here public folder but also we have here upload. We
have here the file and this the content here is about how to install Call of Duty and here we have here these instructions. Okay, that's what we
instructions. Okay, that's what we upload. Okay, we're going to pass that
upload. Okay, we're going to pass that to the LLM. And here, let me check here.
You can see actually they are generating the image. And yeah, you can see we have
the image. And yeah, you can see we have a message not created successfully. And
what I'm going to do, we're going to head into in here. You can see we have the upload folder. We have here the generated image, but also we have here the document. Okay. All right. Now,
the document. Okay. All right. Now,
we're going to be talking about background ch for processing longunning task. Now we are going to take a look to
task. Now we are going to take a look to these endpoints. We're going to try to
these endpoints. We're going to try to check this endpoints and see what's going on. Okay. Now we use the uploads
going on. Okay. Now we use the uploads notes the upload document endpoints in order to upload a in order to create a notes. Okay. Now I'm going to simply
notes. Okay. Now I'm going to simply pass notes. I'm going to modify the name
pass notes. I'm going to modify the name of the endpoints like this notes like this. Now in order to create a notes
this. Now in order to create a notes first of all we pass the documents. Then
we generate the title. And here we generate a prompt for the image generator. We take this prompt, we pass
generator. We take this prompt, we pass it to the image generator. And then the image generator is going to generate an image. And finally, we're going to run a
image. And finally, we're going to run a database operation in order to create a note. Now you can see in these listed
note. Now you can see in these listed steps here, we have a steps which takes a lot of time in order to finish. Now
what I'm going to do I'm going to take this task and then I'm going to run it in the background. Okay. And we going to use agenda agenda package in order to
run background jobs. Now you're going to type npm install agenda. And then we are going to head into the app folder. You
can see we have here app folder. Okay.
Boost app folder. And here I'm passing agenda like this. And inside agenda I'm pass here agenda. agenda instance the TS we're going to instantiate agenda we're
going to pass this and we going to copy this we are going to pass it into the index ts file and pass it here okay and
I'm going to import here agenda yeah like this yeah I'm going to import it from the agenda tsk pass it here and in here we're going to
go back into the agenda you can see pass the Euro. We're going to head into the
the Euro. We're going to head into the MV file. We're going to pass it in here.
MV file. We're going to pass it in here.
And I'm going to go back into the DB connection. And then I'm not I'm going
connection. And then I'm not I'm going to copy this and pass here process DM.
And then I'm passing DB. I'm pass DB like this. And then we're going to pass
like this. And then we're going to pass it in. And then we're going to head into
it in. And then we're going to head into the DM. We're going to pass it in here
the DM. We're going to pass it in here like this.
And also we're going to into the express server tiers we have here this string.
Okay, I'm going to pass here to process the ramp and then I'm going to pass here db euro and pass it db euro. Yeah, euro
like this. Now we going to head into the agenda folder and pass here folder jobs and we're going to pass in our first job. We're going to name it image job.
job. We're going to name it image job.
Okay, image job.ts Yes. And here we're going to define here job. Okay. And in
order to define a job, we pass here agenda define generate image and we pass here callback. And we're going to
here callback. And we're going to extract this property. That's what they said in here. Let's move here. You can
see in order to define here a job, we are going to pass agenda define and then we pass the name of the job and then we pass here callback and we are going to
extract here some properties by doing job.s others data. Okay, we're going to
job.s others data. Okay, we're going to extract here some property. We're going
to pass the note ID, the generate image prompt, the uploader, but also we're going to pass here the random name.
Okay, the random name of the image. And
I'm going to import here agenda. Yeah,
I'm going to import it in here. Now,
we're going to head into the not repository. Not repository. And in here,
repository. Not repository. And in here, we're going to pass we going to invoke here a jam. Okay. And I'm going to pass here. Once we finish creating the note,
here. Once we finish creating the note, we're going to invoke the job here. And
in order to invoke the job, we're going to copy a function agenda now. Okay, I'm
going to copy this. And then we're going to pass it in here. Agenda now. And then
we're going to pass here the name here.
Let me pass here the name of the job.
You can see if we head into the image, this the name of the job. We're going to invoke it. Okay. And we are going to
invoke it. Okay. And we are going to pass it in here. Okay. And um pass here, we're going to pass here generate image.
And I'm going to import here agenda.
Okay. Like this. And I'm going to pass here some property. And you can see we have here these props. I'm passing not props. We use these props in order to
props. We use these props in order to create a notes. And I'm going copy that.
I'm passing here. And I'm passing a property. I'm passing image props image
property. I'm passing image props image props. And here I'm going to pass here.
props. And here I'm going to pass here.
I'm going to pass it some property. Now,
in order to get this property, we're going to head into the create ts. And
I'm going to copy this property. I'm
going to pass it in here. Okay, pass it in here. And the prompt is a string. The
in here. And the prompt is a string. The
upload directory is a string. The random
name is a string. We're going to pass here a string like this. And we're going to pass here these props. Okay, we're
going to copy this image. We're going to pass it in here like this. And in here, we're going to pass here nodes ID. And
I'm going to pass here new nodes to objects object. And then I'm pass here ID. Yeah, like this. We going to go
here ID. Yeah, like this. We going to go back again into the create tiers. And in
here, guys, we're going to copy the generate image function. and we're going to pass it into the image app and pass image app and we're going to pass it in here and we're going to import the generate image function. We're going to
import it and we're going to remove this here. And when they're going to finish
here. And when they're going to finish running this job, we're going to pass here the con.log finished passive finished generating the image. Okay.
Like this. Okay. Now we are going to go back into the create nots. Create note.
TS. And in here I'm going to get rid of this function in here. I'm going to remove it in here guys. We're going to pass this. And we're going to return
pass this. And we're going to return here the the created note. I'm passing
new notes like this. And yeah, here we are going to pass here the generate image prompt the uploader but also the random name which is the the name of the image. Now let's head into the boost
image. Now let's head into the boost folder. And in here we're going to
folder. And in here we're going to import the job and pass here index.
We're going to head into the boost folder. Okay. In here and we're going to
folder. Okay. In here and we're going to use side effect imports. And then we're going to import the job. You can see we pass agenda for/ jobs for/ image. Okay.
and we pass you the job. Now we're going to go back into the create node controller and in here guys you can see we have the generate taro. We take an
array of splitting documents we pass to the generate t function and now as I said before we going to pass it two pieces of documents. Okay. And the first
one is 100 chunks 1,000 chunks. And the
second one is 1,000 ch. And what I'm going to do now, I'm going to pass here only one change because you can see if we head into the load document function
and here you can see the ch size is 1,000 by default and 1,000 is a chunk size is enough for the LLM in order to
generate the tar for the documents.
Okay. Now what I'm going to do I'm going to create here function pass here get dog chunk here like this and then I'm passing this code and here we're going
to pass here you an array of documents I'm cap this do split and pass this and then I'm passing like this okay and we're going to copy
the and here I'm passing return dog chunk like this okay and let's call the get dogch function we're going to copy that and in here and pass here cause dog
chain here. I can just pass it first
chain here. I can just pass it first chunk. Okay, like this is equal to get
chunk. Okay, like this is equal to get dog chank and pass dog split array.
We're going to pass here the dog splits array like this. And then we're going to take here the first ch. We're going to pass it in here like this. And we're
going to head into the load documents.
And then we're going to remove this extension in here because we're going to head into in here. And we're going to use the file name here in order to track the file extension. And I'm going to
comment the do type. And here I'm passing cons do pass here do type like this. Do type is equal to f. We're going
this. Do type is equal to f. We're going
to pass it path module. And then pass extension name. We're going to pass here
extension name. We're going to pass here the file name. Okay. Yeah. We're going
to pass it the file path. File path. And
I'm pass here replace and pass here this. I'm going to get rid of the dot
this. I'm going to get rid of the dot inside the extension name. Okay, like
this. And here I can pass here extension.
Yeah, I'm pass ext. Yeah, I'm going to pass extension with dot like this. And
I'm going to take this. I'm going to cap that and pass it in here. And we're
going to check if the extension is equal to PDF HTML txt. And if is equal to one of these predefined extensions in here, we aren't going to throw an error. Else
we're going to throw an error on supported file. And here I'm going to
supported file. And here I'm going to pass here trim to get rid of the space like this. Yeah. And we are done. Now
like this. Yeah. And we are done. Now
let's head into postman and try this.
And let's make sure our expressive is running. Our expressive is running. Now
running. Our expressive is running. Now
let's pass here the endpoints. You're
going to pass here the locals API for/v1 for/notes. Okay. And you're going to
for/notes. Okay. And you're going to pass the user ID but but also the dog here. And I've already select dog here.
here. And I've already select dog here.
And then I'm going to click here send.
And now let's see what we're going to get in here. Okay, we're going to wait a bit.
And yeah, you can see in here we already created a note. You can see me not created successfully. But also we have
created successfully. But also we have here created note. Okay, you can see the the title Call of Duty Modern Warfare.
Okay, installation guide. This is the title generated by the AI. Okay, but
also we have here the image. And here we have the image name. But actually
they're still generating the image. You
can see starting image generation for not. Okay, they kick off the job. Okay.
not. Okay, they kick off the job. Okay.
Yeah, you can see actually they're generating the image. Okay. If we head into the public folder, you're going to see that actually we haven't already create the image. We don't have here the
image. You can see we still have here
image. You can see we still have here only the file. And you can see the this is the benefits of using a background tab. Okay. And if we have a heavy
tab. Okay. And if we have a heavy operation and it's better to give the user the feedback. Okay. And then we're going to process this heavy operation in the background. Okay. Now let's wait a
the background. Okay. Now let's wait a bit until they finish generating the image. You can see image downloaded and
image. You can see image downloaded and saved as PNG. Yeah, actually they finished generating the image. And here
if we head into the upload photo, you can see actually we have here a generated image. Okay, this the image
generated image. Okay, this the image generated by the AI. Okay, and it doesn't looks beautiful this one. And
okay, we're going to stay with this kind of image. And let me try to see here if
of image. And let me try to see here if I cop this link here. I'm going to preview this image inside the browser.
Let me check. I'm going to copy that and then I'm going to pass it in here and see. Yeah, we got here the image. But it
see. Yeah, we got here the image. But it
doesn't looks beautiful. Uh we're going to stay with this image like it is. And
now let me try to run this again and try to see if we're going to get another image in here. Okay, I'm going to click here again. Send. And in here, we're
here again. Send. And in here, we're going to create another note in here.
Let let me check here the title. And
yeah, we got here another title.
Instructions for running a pre-installed Call of Duty. Now, let's head into the public folder. And in here, let's see
public folder. And in here, let's see what we got here. Okay. And in here you can see we have here another image. This
one is beautiful and this the title the LLM used in order to generate the image.
Call of Duty Modern Warfare installation got from Stream R. Okay. And you can see actually we have here beautiful image we have here soldier we're gone. Okay
that's cool. And now we're going to work on another endpoint which is the update endpoint. Okay. Now in here we're going
endpoint. Okay. Now in here we're going to pass a function update not. And we're
going to pass a note find by ID and update. We're going to pass it the ID of
update. We're going to pass it the ID of the note but also the title and pass it the new property in in order to return the updated notes and we pass the run
validators. In case we don't pass the
validators. In case we don't pass the title, we're going to throw an error and we're going to head into the note folder. You can see we have here one
folder. You can see we have here one controller create note root. Yeah, we
have here one controller create note.
I'm pass here another controller and pass update nodes like this the TS.
Okay. And in here we're going to pass a sing. Yeah, let me cap everything inside
sing. Yeah, let me cap everything inside the gray node. Cop everything in here and I'm put it into the update note.
Okay, like this. Pass this. And we're
going to get rid of this function. And
I'm going to get rid of this code here.
Okay. And in here, we're going to pass here course. We're going to pass it the
here course. We're going to pass it the ID, but also the title like this is equal to rake. And then I pass the body.
We're going to retrieve the ID but also title. And here I'm going to check if we
title. And here I'm going to check if we provide the ID but also title. Okay. And
if the ID pass is different from endine.
If the ID is different from endine and also the T is different from end pass it t.
Okay. Yeah. Let's pass here. If the ID is end, we are going to throw an error. Okay.
And I'm pass here for no error and pass. Please pro. Yeah,
please provide provides the title and the ID.
Please provide the title and ID. Yeah,
we're going to pass. Please provide the t provide the ID and the title. Please
provide the ID and title. Yeah, like
this. And in case we run an error we going to pass here conso is equal to not repository and pass here
is equal to note repository get instance we going to pass here cons update note is equal to a then pass here not repo
passing note I'm going to pass here not repo like this update and we're going to pass here a prop we're going to pass the
ID but also the title like this and I'm going to pass here return response reg status and pass here 200 and I'm going to pass here send we're going to pass
here a message okay like this not updated successfully successfully like this and we're going to return here the
updated note like this okay and as we have here the function as we have here the update note controller. We're going
to cap that and we're going to create here in our roots and pass it update update note roots. Yeah, like this the
TS and in here we're going to pass in exports function update nodes roots and we're going to pass the router and we
going to pass a router and here I'm pass I'm going to return the router and we're going to pass here router puts and we're going to pass here for/
nodes and we're going to pass the function and we're going to import the router from express this the tag And I'm going to import from Express. And we're
going to import the note controller, the update note controller. We're going to import it in here. And we're going to head into the API v1. And I'm passing cons
is equal to this. And I'm passing the router like this. Then we're going to cap this route. We're going to pass it to the express app. Okay? And pass it in
here. And we're going to import the
here. And we're going to import the update not root here like this. And you
just finish. And I'm going to head into in here. We're going to modify here the
in here. We're going to modify here the ATP v. Going to pass a put. And I'm
ATP v. Going to pass a put. And I'm
going to head into compass. I'm
going to click here not. And you can see we have here these notes here.
I'm going to click here refresh. You can
see we have these notes. You can see the taro is hello world. And I'm going to modify the tar. I'm going to copy the ID of the note. I'm copy that. And then
we're going to pass it in here. Okay.
And I'm going to head into we are going to head into body and I'm going to choose here x www form euro encoded. I'm passing the ID of the note.
encoded. I'm passing the ID of the note.
And I'm passing this ID. And here I'm passing the title like this. And I'm
pass here how to yeah I'm passing what is JavaScript. Okay. to to test if we're
is JavaScript. Okay. to to test if we're going to update a not and now let's click here send okay you can see not updated successfully what is JavaScript
and let's head into mong compass and see what we got here I'm going to refresh here you can see the actual value of the title is what is JavaScript we just
modify the title now in here I'm going to modify something this operator you can see we are checking if the ID title is invalid if the ideal title is invalid
you're going to throw this error And I'm pass the or operator instead. We are
going to check if the ID or the taro is invalid. We going to throw this error.
invalid. We going to throw this error.
Now we're going to head into again inside the not repository. We're going
to pass in another function in order to return a list of all created notes and I'm pass here get notes function. We're
going to pass a free property the set pay limit. And we're going to pass the
pay limit. And we're going to pass the skip in order to skip rows inside the note table. And we pass it the filter.
note table. And we pass it the filter.
And then we are going to pass away promise that row and we pass you the first query here in order to return here list of nodes. And then we pass a node
count in order to count not inside note table. And then here we're going to
table. And then here we're going to return here list of nodes but also the pagionation. Now we're going to create
pagionation. Now we're going to create here another controller inside the note folder and pass here not controller.
Yeah, I'm going to pass here get or not get or not like this. CS and here I'm passive function export. Yeah, we can
just copy something inside the updates not. I'm copy everything in here and
not. I'm copy everything in here and then we're going to put it in here.
We're going to modify here the name of the function like this. And here we're going to pass it G not like this. And then we're going to
get rid of this property in here. And
I'm going to pass here and pass here query is equal to rake.
Yeah, I'm pass query. And I'm pass page and pass search is equal to query search
like this. And we're going to pass a
like this. And we're going to pass a cons page is equal to parint.
And then pass here query page. Yeah.
Yeah. I'm pass that page is is string.
And then I'm going to pass here a default value of 10. Okay. Like this.
And pass here 10. And here we're going to pass here we going to pass a note.
I'm passing out not repo con not repo is equal to not repository get instance okay like this and then
we're going to pass here then we're going to pass here cons not is equal to a weight and we're going to pass not repo gh and we're going to pass
it a property and we're going to pass it the s the page and limit and then here we're going to pass it the search value and let me check here now property we're
going to pass it the page but also the limit and pass it the page pass the page and here I'm passing the limit I'm passing for the limit going to pass 10
and actually we have here typing error and yeah I'm going to assert here the search is string okay in order to remove the typing error like this and then
we're going to pass you return rest status is equal to 200 200 100 and then I'm passing send. We're
going to pass in notes like this.
Okay, like this. And now we're going to head into the root folder. We're going
to pass another endpoint gate on nodes roots like this and copy that. We're
going to pass the TS and we're going to export the we're going to export this roots pass notes roots. We're going to pass it the router and I'm going to type
it with the router router type and we're going to return it and pass here return router. Yeah, like this. And then we
router. Yeah, like this. And then we pass here then we're going to pass router dot. Yeah, router do get. And
router dot. Yeah, router do get. And
then here I'm pass the Yeah, I'm going to pass notes. Yeah. And then we're going to pass in notes. And here I'm passing zero notes. Yeah, we're going to
pass in zero nodes. Yeah, like this.
Okay. Yeah, like this. We just get rid of the yellow. And now let's import the router type. And we're going to export
router type. And we're going to export this root. I'm going to head into the
this root. I'm going to head into the API v1. And then I'm pass it in here.
API v1. And then I'm pass it in here.
Pass it con get all nodes is equal to g not roots.
We're going to pass the router and then we're going to pass it to the express app. Okay, I'm going to import it. Yeah,
app. Okay, I'm going to import it. Yeah,
like this. And then we're going to copy that. We're going to pass it in here
that. We're going to pass it in here like this. Pretty good. And now we are
like this. Pretty good. And now we are going to head into the postman and I'm going to try to eat this endpoint in order to get list of created nodes. And
I'm going to click here send.
And actually our server is running. And
I'm pass the page pass page is equal to one and I'm pass search. Yeah, we're
going to pass you search is equal to nothing. Okay. And let's wait a bit and
nothing. Okay. And let's wait a bit and see what we're going to get.
Our save is running. I'm going click here send.
Okay. You can see actually we have here list of created notes. Okay. We have
this the first one, second one and so on. Okay. but also the pagenation
on. Okay. but also the pagenation property here and I'm going to try to look for this title pass here call coloff and see what we're going to get.
Okay, you can see yeah actually this search is working and if I pass here you t like what is let me see what we're
going to get here. Yeah, you can see actually we have here one note, one note here and you can see that actually we have here one note and it works pretty
well guys.
All right guys, now going to work on the summary endpoints, briefing doc endpoints, FAQ endpoints, ta endpoints and myma endpoints and once we eat let's
say we eat the notes for slash summary, we going to return the summary of a given document. Now we are going to head
given document. Now we are going to head into in here and you can see we have here roots. I'm pass get summary sum.
here roots. I'm pass get summary sum.
Yeah I'm pass here you summary summary roots. Okay. And here I'm passing the ts
roots. Okay. And here I'm passing the ts and in here you're going to pass export function and I'm pass you get summary.
I'm pass get summary roots. Okay we can pass like this. We're going to pass the router and the router. Here we're going to tap this and pass the router router
router. And here we're going to return
router. And here we're going to return here the router pass router. And I'm
going to pass here get and pass here router.get
router.get and pass here for slash nodes forward slash summary. Once we eat this
slash summary. Once we eat this endpoint, we're going to return the summary of a given document. And I'm
passion. I'm passing the controller get do summary get g get do summary and I'm going to go ahead and in here I'm pass here I'm pass g get g get g get g get g get g get g get g get g get g get g do dog do s s s s s s s s s s s s s s s s s
s s s s s s s s s s s s s s s s s s s s s s summary and pass the ts like this now I'm going to copy content inside the update not the TS I'm copy everything in
here and put it into the G do summary TS and I'm passing G do yeah I'm pass G do summary like this and now we are going
to get rid of these functions in here.
Okay. And I'm going to get rid of this code here like this get do summary. And
that's good in here guys. And now let's head into the roots here. I'm going to head into the summary roots. And here
I'm going to import here the router from express. We're going to import here the
express. We're going to import here the controller get dog do summary like this.
And now we're going to go ahead and going to get into the API if you want.
And I'm pass here call summary roots and I'm passing here. We're going to pass here first the router. And we're going to import this.
We're going to import this roots get summary. I'm going to copy that. We're
summary. I'm going to copy that. We're
going to pass we're going to pass to the express app like this. And now we're going to get into in here. We're going
to head into the repository and pass here doc repository. doc repository
repository thets like this. Now in order to get the summary of a given doc what I'm going to do in here I'm going to create here another function create doc.
We're going to pass the file name but also the node ID and the user ID. Now
we're going to head into we're going to head into the dog repository. Let me
copy everything in here and pass it into the dog repository.
And here I'm going to remove I'm going to get rid of this function.
Let's get rid of the get or not function. We're going to get rid of the
function. We're going to get rid of the updates not function. And we're going to pass here doc repository. I'm going to click here replace. So pass do reposi.
Yeah, we're going to pass here doc repository like this. And then we're going to click
like this. And then we're going to click here replace like this. And we're going to pass here create dog function. Create
dog. And I'm passing dog props. We're
going to pass it the file name. File
name. We're going to pass here the user ID and the note ID. I'm pass here user ID and not ID. And we're going to get
rid of the image prop like this. And
here we're going to import here do.
Yeah, I'm going to pass it doc schema.
And if we head into in here, I'm going to click here. We're going to head into in here. You can see this is the doc
in here. You can see this is the doc schema. We have here the file name, the
schema. We have here the file name, the summary, sty, briefing, doc, v, the fq, but also the mama column. And we have here the note ID and user ID. Now, let's
go back in here. We are going to pass here these props. I pass it in here and pass here dog. And I'm going to pass here dog.
Yeah, I'm pass dog like this. Doctor
save and here you should pass a doc and we're going to return here a new created document. So pass here. Yeah, we're
document. So pass here. Yeah, we're
going to pass here new dog like this.
Yeah, like this. Now let's head into the create nodes controller and in here once we just finished creating nodes, we're going to take the node ID but also the user ID. We're going to pass it to this
user ID. We're going to pass it to this function and pass here con do repo is equal to doc repository doc repository
that get instance and pass here a weight and pass a cons no dog is equal to we're going to pass a weight do repository dot
create do we going to pass it the file name and you can see at the top here we have the file name I'm going to create here constants
I'm I'm going to copy this and then we're going to pass here cons and then say file name is equal to this and then we're going to pass here this constant
file name. We're going to copy the file
file name. We're going to copy the file name. We're going to pass it to the
name. We're going to pass it to the create doc and we're going to pass here.
Let me see here. We're going to pass here the second property is the user ID and the note ID and pass the user ID user ID and here I'm passing note ID
like this. Okay. And we're going to get
like this. Okay. And we're going to get rid of the error and to get it all to get access to the note we're going to pass here new notes. New notes and then pass here
ID. Yeah, like this. Let me check in
ID. Yeah, like this. Let me check in here. Yeah, we have here underscore id.
here. Yeah, we have here underscore id.
New not nodes. You can see in here once we finish creating notes, we are returning here new notes. Okay, pass
here underscore ID like this. And yeah,
we get rid of the error and then I'm not I'm going to asset it as string. Okay.
And yeah, I'm passing not ID like this.
Yeah. And we're going to get rid of the error. Okay. And I'm going to asset it
error. Okay. And I'm going to asset it as string like this.
Okay. Yeah. Actually we have here typing error. And if we asset it let's see the
error. And if we asset it let's see the type of node id. And you can see the type of ID here is a types of tabs
object. Okay. I can copy this and then
object. Okay. I can copy this and then I'm going to head into the create do here and then I'm pass in here. Okay.
And let me check in here. Yeah, we're
going to import the tabs type and then from mongus. Okay, like this. And then
from mongus. Okay, like this. And then
we're going to get rid of the error. Now
let's create a function to update summary. We're going to pass a sync.
summary. We're going to pass a sync.
Pass a sync. Yeah, I'm going to pass a sync update summary. Pass update
summary. We're going to pass it some props and we're going to pass it the user ID and we're going to pass here the
note ID and also we're going to pass the summary is a string like this and I'm going to pass and pass a cons update
summary update summary we going to pass you a weight and then pass do find one in update fun one in updates we going to
pass it the user ID and note ID node ID and we're going to pass here another object. We're going to pass a set to
object. We're going to pass a set to update the summary and pass summary. And
we're going to pass a props summary like this. And we're going to pass the F
this. And we're going to pass the F object. We're going to pass new and run
object. We're going to pass new and run validators through. And in case we don't
validators through. And in case we don't update it and in case we don't update summary, I'm going to pass here we don't find a row inside the do table and pass
update summary. And we're going to throw
update summary. And we're going to throw an error and pass here for passive row.
no error and no I'm passing no I'm passing no dog found okay like this and then we're going to return here the
updated summary return updates summary like this and yeah here we still have here errors I'm passing I'm going to extract the user ID and ID from the
props object is equal to props pass the props like this and here we've passive string like this now we're going to create here another function
In order to update here the briefing doc let me check here for the summary finish. We going to create another
finish. We going to create another function in order to update the briefing doc the AQ virus study guy and I'm going
to cap this function and we're going to pass here first update briefing doc passive briefing doc like this we're
going to pass this property okay and here I'm passing briefing let me briefing doc and here we're going to cap this property we're going to pass it in
here briefing doc like is okay and we're going to pass here updates. Yeah, I can
pass it just row and like this. I'm
passing row and here too I'm passing row row and here row like this. Now I'm
going to cut this function in order to update now the stud guide. Yeah, we have here the FAQ and then the stud guide and
we're going to copy that again. We're
going to pass it in here. We're going to pass it update. And here I'm pass
update FAQ. And we're going to pass here
update FAQ. And we're going to pass here FAQ and pass FAQ like this. And we're
going to pass here the FAQ [clears throat] property. FAQ. And here going to pass FQ
property. FAQ. And here going to pass FQ like this.
And now we're going to update now the stud guide. I'm going to cut this. We're
stud guide. I'm going to cut this. We're
going to pass here update study guide.
Stud.
Yeah, stud guide like this. And we're
going to pass here for the column. I'm
going to pass the name of the column.
Study guide. We're going to cut that.
We're going to pass it in here and here to study guide. Okay, we just finished.
Let me check in here. What's next? We
are going to move to the mind map. Okay,
now for the mind map, we're going to copy the same function. We're going to modify it. pass update in here update
modify it. pass update in here update mind map here like this. We're going to pass the mind map column props mind map property and in here guys we just
finished. Now we're going to head into
finished. Now we're going to head into the G do summary.t CS controller and in here we are going to give the file name.
We are going to split it into chunks. We
are going to call the generate summary function in order to generate the summary of given file. And then we're going to store the summary inside database. And in here we're going to
database. And in here we're going to head into the summary pipeline. And
here's the summary pipeline we already created. And I'm going to comment
created. And I'm going to comment everything in here. Let [clears throat] me select I'm going to unccomment the the token max. We're going to select everything all the way to the bottom.
And I'm going to export here. function
pass exports is sync function and then I'm pass generate summary generate summary like this and then we're going to pass the lms property and as premier
and here I'm pass here the type I'm passing a generic and the type of t is going to be a runnable okay extends t
extends runnable like this runnable yeah like this and then I'm going to pass here do I'm pass an array of documents.
Okay. And here I'm passing documents is an array. Okay, like this. And then
an array. Okay, like this. And then
we're going to put in this contents. And
we're going to return here the final summary. And I'm going to comment this.
summary. And I'm going to comment this.
And here we should pass here split docs as parameter. Okay, as the second
as parameter. Okay, as the second parameter and I'm pass dogs do like this. Now we're going to head into the g
this. Now we're going to head into the g summary controller. G do summary
summary controller. G do summary controller. And then in here we're going
controller. And then in here we're going to pass here current working directory function. We're going to pass a path
function. We're going to pass a path magic that John we're going to pass the car working directory and I'll pass a public uploads. Okay. So now we are
public uploads. Okay. So now we are going to have the possibility to select a file into the upload folder. And then
we going to head into again insert the dog repository.
Do repository. We're going to create here a function g single dog. And here
we're going to pass here props and I'm passing the user ID and I'm passing the note id like this. And we're going to
pass here cons is equal is equal and pass is equal to a weight is con dog is equal to a weight and pass dog
one. Pass here do find one like this.
one. Pass here do find one like this.
We're going to pass here the props.
Okay. like this and then we're going to return the document. Okay, like this.
And now let's let's go back into the G doc summary controller. And we're going to pass here the not repository. The doc
repository doc repo is equal to do repository get instance and pass here cons do is
I'm pass cons do is equal to do repo.
We're going to pass here pass here a weight pass dog repo is equal to get g get single dog and we're going to pass
here the user ID cons and we're going to pass here we're going to pass we're going to extract here the user ID and
I'm extra here the no ID is equal to rag query like this user ID and we're going to pass here
this property user id and node id and here we're going to get access to the file name okay and I'm passing doc option ching I'm passing file name now
let's get rid of this typing error I'm going to set here the user ID and the note id is record tab string and any and
I'm going to pass you file name and pass it I'm going to pass do full path we are going to take this path we're going to pass it to the document a load. Okay,
I'm passing con splitting pass here splitting doc is equal to a weight and pass load documents a weight load documents like this and we're going to
pass a dog full path like this. We're
going to have here an array of documents. Then once we have here an
documents. Then once we have here an array of documents, we going to take this array of documents. We're going to pass it to the function generate
summary. Okay, pass here summary. pass
summary. Okay, pass here summary. pass
summary is equal to a weight pass generate summary like this we're going to call the function and this function takes parameter we pass it the llm but also an
array of documents and I'm pass here the lm cause llm is equal to llm like this get instance and I'm pass here the llm
and we're going to pass here the splitting documents okay splitting documents splitting doc Okay, splitting docs. Okay, like this. And splitting
docs. Okay, like this. And splitting
docs like this. I'm cap that. Going to
pass it in here. And once we have a summary, we're going to store it inside database and pass here not. And pass
here do repo. And we're going to pass here that update summary like this. And
we're going to pass it to props to props. You can see we're going to pass
props. You can see we're going to pass the user ID, node ID, and summary. And
here I'm passing the user ID, node ID, and we need to pass it the summary.
Okay, I'm passing it the summary like this. And then we're going to remove
this. And then we're going to remove this error. And once we store the
this error. And once we store the summary inside database and I'm going to pass you return pass
you return new I'm passing return is equal to raise I'm going to pass and once we install the summary inside database I'm passing return raise status
and I'm passing 200 and I'm pass 200 and then I'm passing send summary I'm passing message summary passes summary
generated successfully. Success.
generated successfully. Success.
Yeah, pass summary generated successfully. Like this. Okay. And I'm
successfully. Like this. Okay. And I'm
going to modify the name of this controller. You can see we use this
controller. You can see we use this controller in order to store the summary inside database and pass here store and pass here create summary. Okay, I'm
going to rename this endpoint create summary like this. We are going to modify the name of this controller to create summary. And I'm going to pass
create summary. And I'm going to pass here create summary like this. And let me let me pass here another folder inside the
note folder. I'm pass here helpers.
note folder. I'm pass here helpers.
And I'm going to pass here another folder. I'm name it loaders. Loaders.
folder. I'm name it loaders. Loaders.
And I'm going to move here the loaders inside the loader folder. And you can see here we have generate image.
Generate image is a helper function. And
I'm going to copy that. I'm going to move inside the helper folder. We have
here t generation. We are going to copy the taro generation. We're going to pass inside the helper. And we have here prompt generator. This two is a helper
prompt generator. This two is a helper function. We're going to copy that and
function. We're going to copy that and we're going to move it in here. And
we're going to stay with controllers at the root of the notes folder. Create
notes. Create summary. Gear notes. And
here we have updates not. Yeah.
Beautiful. And yeah, we have here create summary. Okay.
summary. Okay.
Like this. I can rename it update summary. We don't Yeah. Update
summary. We don't Yeah. Update
or create summary. I'm going to name it like this. In the end, we're going to
like this. In the end, we're going to modify the name of this file to this.
Create up this summary. And now we're going to create an end point to return now the summary. Okay. Now let's create here now endpoints.
And here I'm pass here summary and pass here now get summary.
Okay. TS like this.
And get summary.
And we're going to let let's copy everything in here. And we're going to put it inside the G sum. Okay. In here,
we're going to remove everything in here. I'm remove Yeah, I'm going to
here. I'm remove Yeah, I'm going to remove this code. And we're going to get rid of this code in here. Okay. I'm
going to stay with express and express tabs. And we're going to import here the
tabs. And we're going to import here the doc repository. We're going to import it
doc repository. We're going to import it in here. Do repository. And we're going
in here. Do repository. And we're going to pass here the user ID, no ID. Let me
go back here and copy this type, this line. And we're going to pass it in
line. And we're going to pass it in here.
We are going to return the summary and pass here return rest status. Pass here
200. And then here pass here and pass that send. And I'm pass here summary. And we're going to pass here
summary. And we're going to pass here doc do summary dot summary like this. Okay,
like this. And I'm going to pass this line edit tab here like this. And in
here too inside the update create summary function we should we should return here the summary and pass here summary like this.
Okay.
Okay. Like this. Okay. And now we are going to check this. We have here the roots. Summary roots and G summary
roots. Summary roots and G summary roots. G pass you only summary roots.
roots. G pass you only summary roots.
Summary roots like this. I'm copy that.
And then we're going to modify here the name G summary. Let me remove this and pass here get summary.
Yeah, let me see the name. Yeah, let me pass here get dog summary. G do summary. We're
going to cut that. We're going to pass it in here. G do summary.
And I'm going to import it. Let me go back in here. And we're going to pass here. G do summary like this. We're
here. G do summary like this. We're
going to pass it in here. G do summary.
Okay. We're going to import it. Okay.
And here I'm passing route router.
Pause. And yeah that puts here we're going to pass you put and then I'm pass you not slash not for/ summary and going
to pass you create I'm pass update or create summary update or create summary. Okay, like this.
Going to pass you this end points. Yeah,
great. Now, let's head into the API v1.
API v1 file. And in here, we're going to pass a summary roots. And we're going to get rid of this line here.
And we're going to pass here summary.
Pass here summary roots. Summary roots
like this. And then we're going to cut the summary roots. We're going to pass it in here. Now, let's try this endpoint. We're going to head into
endpoint. We're going to head into portsman and in here we going to pass you is hpv. We're going to pass you port localhost api/v1
for/notes user ID and I pass here a file vector db. I got the file here. I'm
vector db. I got the file here. I'm
going to pick it in here and then you can see the this is the contents that talks about vector database. Okay. Now
I'm going to close it and then I'm going to upload it. Okay. Our server is running. Now let's upload it. I'm click
running. Now let's upload it. I'm click
here send and let's see what we're going to get in here.
Okay, you can see we have here a note created successfully. Vector database
created successfully. Vector database semantic search for AP application. You
can see this the title generated by the AI. We have here the URL of the image
AI. We have here the URL of the image and actually they kick off a job here.
They're generating the image. And if we head into mono compass, I'm going to click here notes. I'm going to refresh here. I'm going to click here. Refresh.
here. I'm going to click here. Refresh.
And we have here these notes at the bottom here. Yeah, we have here at the
bottom here. Yeah, we have here at the bottom here. We have here Victor
bottom here. We have here Victor database. And we have we don't have here
database. And we have we don't have here the notes name. Okay. I'm going to head into dogs folder. I'm going to refresh database in here. I'm going to refresh
here. And we have here docs. docs
here. And we have here docs. docs
collection and you can see this the file name and now I'm going to try to eat another endpoint in order to create the summary okay and now you can see
actually they finished generating the image and if we head into the public folder okay you can see this the image generated by the AI based on the title
now in order to generate the in order to generate the summary I'm passing create summary updates Okay. And here we are going to pass here
Okay. And here we are going to pass here the going to we're going to send data into the body and pass the body instead of the query. Okay. We're going to pass a rake the body and we're going to
extract the user ID and not ID. I'm not
heading to in here. We for the HP we're going to pass here put and we going to send here the user ID. I'm passing user
ID and we're going to head into body and I'm going to head into X WW for Euro encoded and we're going to pass here the user ID and also we're going to pass the
note ID. Now to get the user ID ID we're
note ID. Now to get the user ID ID we're going to head into mong compass and I'm going to copy here the user the node ID
first and we're going to pass it in here. This is the new ID. And let's copy
here. This is the new ID. And let's copy also the user ID. I'm going to copy the user ID like this. And then I'm pass it
in here like this. And once we click here, send you can see generate summary, generate summary, collab summary. And
yeah, we have here a new object. Okay.
Cast to string files for value. And
let's fix that. And I'm going to copy this and then uh I'm going to shut I'm going to rerun the express server. I'm
going to head into VS code. And in here we have here an object. Okay. Now as we have here an object I'm pass here this
summary passes is equal to summary summary do final summary like this. And
then we're going to return the summary.
Then I'm cut this and we're going to pass here summary. and cap that pass in here and we're going to rerun our express server. Okay. And once we run
express server. Okay. And once we run our express server, we are going to head into again inside Postman and we're going to try this again. Now, as our
express server is up, now let's click here again. Send and we're going to
here again. Send and we're going to generate the summary. Let's check again.
In here, we're going to get in here generate summary. generate summary,
generate summary. generate summary, collapse summary, collect summaries, and generate final summary. Okay, now we got here the summary based on the provided
summary. Here's a consolidated summary
summary. Here's a consolidated summary of the main themes. A vector database is a specialized system designed to store and manage and structured data such as
text, images or audio by converting it by converting it into numerical representation called vectors.
Okay, you can see guys, we have here generated summary and if head into our compass and we head into in here, you're going to see we have the summary
and if we head into shell, you can see if we run this query here, we are going to see the summary. Okay, here is the generated summary guys. Okay, you
can see that actually everything works perfectly. Now, we're going to do the
perfectly. Now, we're going to do the same thing to generate the stud guide.
Okay, I'm not heading to in here. We are
going to do the same process. We're
going to work through the same process in order to generate the briefing dock, the FAQ, star guide, but also the mind map. All right guys, now let's generate
map. All right guys, now let's generate the briefing doc. We already generate the summary. Now we're going to move on
the summary. Now we're going to move on the briefing do. Now you can see inside the note folder, we have here the get dog summary, but also we have the update
create summary. Now what I'm going to do
create summary. Now what I'm going to do in here, we're going to pass here folder. We're going to name it summary.
folder. We're going to name it summary.
Okay, we're going to put in these two files. Okay, I'm name it summary. And
files. Okay, I'm name it summary. And
then I'm going to import the update create summary, but also the G do summary.ts inside the summary folder.
And now you're going to create a briefing dog folder inside the notes folder. You can see that actually I've
folder. You can see that actually I've already created. Okay, you can see we
already created. Okay, you can see we have it in here. Now we're going to head into the pipelines folder. You can see we have the briefing do.ts. Now we're
going to repeat the same process. Okay
guys, you're going to wrap the code into generate briefing do function. We're
going to pass it to parameter the llm and the split dos which is an array of document that we're going to pass to the llm in order to generate the briefing dog and then at the end here we return
the briefing doc. Now we're going to head into inside the briefing doc folder. I'm going to creating I'm going
folder. I'm going to creating I'm going to creating two file. The first one I'm going to name it update or create. Yeah,
update create briefing. I'm passive
briefing like like this the TS and I'm tap in. I'm going to head into the
tap in. I'm going to head into the update create summary. I'm cap
everything in here. And I'm going head into in here and pass that. And in here I'm going to modify going to pass a date briefing doc and pass here briefing dog
like this. And in here we're going to
like this. And in here we're going to pass the llm. We're going to pass do repository get instance. And we're going to pass here get single dog data function. And here we're going to pass
function. And here we're going to pass this function in order to get access to the file. And here I'm going to pass
the file. And here I'm going to pass here function update briefing dog. Okay.
Pass it update briefing dog like this.
We're going to pass it the briefing dog.
Okay. And in here too we need to call generate briefing dog function. I'm
going to call it and then we pass the llm but also the documents and then we're going to pass here briefing doc like this and I'm passive brief. Yeah,
we're going to pass it briefing. Yeah,
briefing dog and we're going to copy that. We're going to pass it in here
that. We're going to pass it in here like this that briefing. Yeah, I'm going to go back into the generate briefing dog function and copy that. And then I'm
going to copy this final briefing doc.
We're going to pass we're going to pass there. And then we're going to pass here
there. And then we're going to pass here briefing doc like this. We're going to copy that. Once we create the briefing
copy that. Once we create the briefing do we're going to return it and pass it in here. Okay. I'm going to copy this.
in here. Okay. I'm going to copy this.
We're going to pass it in here. And here
for the message we're going to modify.
We're going to pass here. Generate
summary briefing doc generated successfully. Pass here. briefing doc
successfully. Pass here. briefing doc
generated successfully and we are done in here guys. Okay, we are done.
Everything is okay in here. Now we're
going to create another endpoints gay briefing dog. Okay, in order to in order
briefing dog. Okay, in order to in order to return the briefing dog now I'm going to copy this code in here. Let me first get rid of this error. We're going to copy everything in here. We're going to
create here another file. We're going to pass here get dog briefing. Yeah.
Briefing dog. Gay dog do briefing. Yeah,
I'm pass briefing dog. Yeah, gay brief.
Yeah, I'm pass briefing dog. TS and then we're going to put in this code. And in
here, we're going to pass a G briefing passive briefing dog. And in here, we're going to pass here doc repository get
instance doc repo get in that get single doc data. We're going to pass. We're
doc data. We're going to pass. We're
going to pass the user ID and not ID.
And here we are going to pass. We're
going to return here the briefing dog.
Okay. Pass here. We're going to pass here briefing. Yeah. I'm pass briefing
here briefing. Yeah. I'm pass briefing dog and I'm pass here dog and then option chaining that briefing dog like this. And we are done. Now we are going
this. And we are done. Now we are going to head into the root folder. You can
see we have here roots and we have here summary roots. Okay. And in here I'm
summary roots. Okay. And in here I'm going to create the briefing dog roots.
Okay. Now I'm going to copy that. Let me
first import this to get rid of the I'm going to copy that. And we're going to create here now root and pass here brief brief briefing doc roots like this. The
TS we're going to head into in here. And
then we're going to pass here this. I'm
going get rid of this. And where we got summary going to pass here briefing.
passive brief briefing doc like this passive hyphen I'm passing hyphen doc like this and I'm going to copy this
name here I'm pass it in here and I'm passing give briefing doc we're going to import it in here but also going to pass here updates or create briefing dog like
this okay and we are done in here we import the function okay give briefing dog actually we have Keep typing error.
I'm going to head into the briefing do folder in here and then I'm going to check here the name of the function gear briefing doc. I'm copy it and then we're
briefing doc. I'm copy it and then we're going to go back in here into the roots folder. We're going to pass it in here.
folder. We're going to pass it in here.
G briefing dos. Yeah, it's correct. Now
I'm going to modify here the name of the this function and pass here briefing doc. Briefing doc roots like this. And
doc. Briefing doc roots like this. And
then we're going to head into the API v1 the TS and then we're going to pass in here cons briefing briefing doc is equal to briefing doc
roots. We're going to pass it the router
roots. We're going to pass it the router and then we're going to import the function. Let's copy it and pass it to
function. Let's copy it and pass it to the express app like this. Okay. And
then done. Okay. We are done guys. Now
it's your turn guys to try to generate a briefing dog. Okay. Now we're going to
briefing dog. Okay. Now we're going to continue in here try to test these endpoints and we already generate the briefing dog. Now we're going to move to
briefing dog. Now we're going to move to the FAQ. We're going to repeat the same
the FAQ. We're going to repeat the same process. I'm going to head into again
process. I'm going to head into again inside the notes folder. Okay. And in
here we're going to pass here FAQ and we have the FAQ pipeline and I'm going to into the pipeline folder. Okay,
we have a pipelines and we have here FAQ. Let me look for it. We have here
FAQ. Let me look for it. We have here generate FAQ. And we're going to repeat
generate FAQ. And we're going to repeat the same process. I'm going to comment this code. And then we're going to copy
this code. And then we're going to copy everything all the way to the bottom here. And then we're going to put it
here. And then we're going to put it into the function. I'm copy everything.
And I'm pass. We're going to pass a function. Pass exports a sync function.
function. Pass exports a sync function.
And then we're going to pass here generate FAQ. FAQ. And we're going to
generate FAQ. FAQ. And we're going to pass it to parameter as we did. And then
I'm passing this code. Let me go back in here. Let me cop here something. I'm cop
here. Let me cop here something. I'm cop
here this data here. Okay. I'm going to copy this. And then we're going to pass
copy this. And then we're going to pass it in here. Generate. Generate FAQ. We
are going to pass it in here. Okay. Like
this. We pass here the LLM.
Okay. Like this. pass you the llm and the splitting dock. Okay, I'm going to import here runnable. Okay, t extends runnable and then we going to go at bottom. We going to return the final
bottom. We going to return the final FAQ. I'm copy this and then I pass here
FAQ. I'm copy this and then I pass here return FAQ and guys I'm going to make a pause and then I'm going to do it real quickly so that we can move on. All
right guys, you can see that actually I've already generated the summary briefing doc the FAQ start guide and now we're going to work together on the man
map and previously we made a pause and I do that real quickly. You can see inside the not folder actually we have the
briefing doc the FAQ I've already work on it and we have the star guide. I
repeat the same process. Now I'm going to head into the pipeline folder and we have here the mindm map pipeline and in here in order to generate a mind map we
use the study guide. Once we already generate the study guide we are going to copy that and then we're going to pass it to the LLM in order to generate a mind map. And you can see if I walk you
mind map. And you can see if I walk you through this code in here you can see this is the shape that we want the LLM
return. This is the man elixir shape.
return. This is the man elixir shape.
And then in here we pass the prompt and then uh we are going to pass here the stud guide. Okay, that we want the LLM
stud guide. Okay, that we want the LLM generate a mind map about it. Now what
I'm going to do in here, I'm going to get rid of this study [clears throat] guide in here because we're going to pass it as as a parameter. Okay, I'm
going to get rid of this code and then I'm going to remove that. I'm going to copy all of this and I'm going to wrap that into a function and I'm pass here
export function and pass here export a sync function and then pass here generate pass here mind map mind map
like this and I'm going to put in this code. I'm going to go back into the
code. I'm going to go back into the generate FQ. Okay, we're going to pass
generate FQ. Okay, we're going to pass it in here. I'm going to move edit up here. We're going to copy this
here. We're going to copy this parameter. I'mma copy this and then
parameter. I'mma copy this and then we're going to go back into the mindmap ts and then we're going to pass it to this function. And here I'm going to get
this function. And here I'm going to get rid of the lm in here. I'm going to comment this and we're going to pass it here the the t extend runnable. And
we're going to pass it the lm but also the the static guide. I'm pass here this. Yeah, I'm passing the static guide
this. Yeah, I'm passing the static guide like this. And the static guide is a
like this. And the static guide is a type of string. I pass here string and we're going to import runnable class.
Okay, I'm gonna import here runnable like this. And here pass here string.
like this. And here pass here string.
And we are done. And now what I'm going to do in here, I'm going to copy the stud guide. We're going to pass it to
stud guide. We're going to pass it to the lm. And we're going to pass it in
the lm. And we're going to pass it in here. Mind map. And then is equal to
here. Mind map. And then is equal to JSON stringify. We're going to pass the
JSON stringify. We're going to pass the result here. Pass the results and then
result here. Pass the results and then we're going to return the mind map.
Okay, I'm [clears throat] passing return mind passing mind map like this. And we
are done in here. And now what I'm going to do in here, I'm going to copy the name of this function. We're going to copy that. And then we're going to head
copy that. And then we're going to head into the notes folder. I'm going create here another folder. I'm name it mind map like this. Mind map. [clears throat]
Okay, that like this and inside of it we're going to put in the controller and pass here get
do mind map thets like this and we're going to explore the function. Okay, now
let's head into the FAQ and I'm going to copy this function. C everything in here and put it into the G do mind map.ts TS and I'm going to modify here the name of
the function pass J dog do mind map like this and we're going to pass here do repository the get instance pass a dog do repo the get single dog we're going
to pass the user ID but also not ID and then I'm passing cons we're going to pass here consu pass the yeah we're going to pass here
the stud guide we're going to store that into this variable and pass study guide is equal to dog and then option chaining we going to pass here the stud guide
like this and I'm going to check if we have data if stud guide okay if is any fine okay if we don't have data I'm pass
guide I'm passing through I'm pass I'm an error for no error like this and then
no data provided no data provided to generate the study guide to generate the stud and pass here the stud guide
like this and if we have here data I'm going to call this pipeline I pass here I pass here con mind map is equal to we
going to pass here mind map is equal to a way and then pass here generates mind map we're going to pass it the llm and
here we're going to pass it the llm pass it cons lm llm is equal to llm like this and we're going to pass it the get instance and we're going to pass it the
llm but also going to pass here the star guide like this okay the llm and the star guide and once we have here the mind map we're going to store that into
the database we are going to pass here cons and pass We're going to pass a wait do repo like
this do repo updates updates mind map and we're going to pass here some property. Let me see the user ID, node
property. Let me see the user ID, node ID and also the mind map. I'm passing
user ID and node ID here and the mind map. Mind map we're going to we're going
map. Mind map we're going to we're going to pass in here. This the generated mind map like this and we're going to store that into the database and in here and once we install the mind map into
database we're going to retain it. pass
here generated mind. Yeah, I'm pass here mind stored mind map like this is equal to this. I'm going to return it. I'm
to this. I'm going to return it. I'm
copy this and then I pass here mind map like this is equal to stored man. Okay,
like this we're going to return it. And
if we already generate the mind map, we are going to return it immediately if the user need it. Okay, we aren going to eat this endpoint again. And here I'm going to modify this end pass here.
Create and pass it create or update or update mind map like this the TS.
Okay. Now we're going to copy this name.
I'm pass it to this function. And now
we're going to create another function in order to return only the mind map.
I'm going to copy content into the GDO FAQ.ts. Type everything in here. and put
FAQ.ts. Type everything in here. and put
it into the mind map. Okay. And here
I'll pass here game mind map thets and yeah like this. And here I'm pass here game mind map like this. And we going to
pass here the do repository get instance. And then pass here mind map
instance. And then pass here mind map like this. And then we're going to pass
like this. And then we're going to pass do mind map. Yeah like this. And we are done.
map. Yeah like this. And we are done.
game mind map. Now we're going to create two roots for these two controller and we're going to head into the root folder. We're going to pass here mindm
folder. We're going to pass here mindm [clears throat] map and we're going to head into the root folder. We're going
to pass here mindm map roots pass mind map roots thet. We're going to copy everything inside the g. We're going to cop everything in here and we're going
to put it and we're going to put it into the man map roots like this. And I'm
pass here game mind map. Okay, g map roots. And we're going to pass here the
roots. And we're going to pass here the note for slash mind map like this. And
here to mind map like this. And we're
going to pass here do mind map. G do
Yeah. Let me see the name here. G man
map. Okay, game mind map like this. And
we're going to pass here update. I'm
pass create updates man map like this.
Now we're going to head into the API v1 file and we're going to pass that API v1 and I'm passing cons man map mind map
like this is equal to game mind map roots. We're going to pass it to router
roots. We're going to pass it to router and we're going to copy that. We're
going to pass it to the express app like this. Pass it in here. And then we're
this. Pass it in here. And then we're going to import the game man map roots like this. And we are done guys. We just
like this. And we are done guys. We just
generate a man map. All right guys, now we're going to set up our react app.
You're going to head up to shen.com.
Click get started. Head into vit here.
And I'm going to click here and we're going to head into prompt and tap inner.
We we're going to create our react app using vit. Okay. Type npm creates vitis.
using vit. Okay. Type npm creates vitis.
And then in here you can see you're going to pass in the project name pass app. I'm passing my app here like this.
app. I'm passing my app here like this.
And then you're going to choose here react. And we going to work with react
react. And we going to work with react alongside with typ script. And then
you're going to cd into your my into your folder. And then you're going to
your folder. And then you're going to type npm install. And once you type npm install, you're going to install re react router. Okay. And in order to
react router. Okay. And in order to install react router, you're going to head up to react.com/ome.
And then in here, you're going to see at the left we have a menu. You're going to you're going to scroll a little bit.
You're going to see installation. And
then you're going to type this command npm install react router like this. And
done. And now let's set up SH CN. And in
here in order to set up SHTN you're going to copy this command. In order to install TWIN CSS you're going to copy npm install TWIN CSS at Tawin CSS for/fight
and then you're going to head into your source folder. You can see actually I've
source folder. You can see actually I've already installed my projects. You're
going to see we have the index CSS file.
And in here what you're going to do in here guys you're going to put in add import tin CSS and then you're going to scroll a little bit. You're going to you're going to head into again inside
the tsconfig.json file. You're going to
the tsconfig.json file. You're going to copy this line here. You're going to put it in there. You can see if I head into my tsconfig.json file, I've already put
my tsconfig.json file, I've already put it tsconfig.json. I've already put the
it tsconfig.json. I've already put the line in here. Do the same thing, guys.
And once done, you're going to head into again the tsconig.json
and you're going to copy this. You're
going to put it there and and then you're going to type this command npm install-d tabscript for/node and you're going to head up again inside the v.conigts file.
You're going to put you're going to import in you you're going to copy this.
Okay. And head into your vconigts and copy that in here. And once done we're going to continue. And now you're
going to type npx shot cn and lattis in it to initialize shard cn inside of our project. And you're going to choose
project. And you're going to choose yetro and then done. Once done you can copy this command here. npx shut cnatis add button. Okay. And then you're going
add button. Okay. And then you're going to copy that. And then once you tap this command you're going to see you have the components. You have here components
components. You have here components for/ UI folder in here. but also you're going to see the button and done and once you finish installing your react
app now we are going to start building our front end okay I'm typing now npm rundev all right guys as we just finished installing our react app now we're going to head into the source folder and in
here we're going to pass you the layout folder we're going to put in all layouts and I'm passing the first layout is of layout the t6 we're going to pass you
the not layout pass you not layout layout. Yeah, like this. TS6. And in
layout. Yeah, like this. TS6. And in
here, we're going to pass it to the chat layout. Chat layout.ts.
layout. Chat layout.ts.
Like this. Now, we're going to create the pages folder. We're going to put in all pages and pass it pages folder. And
inside the pages folder and pass in note, pass here the first folder and pass it off. We're going to pass here another folder. We're going to name it
another folder. We're going to name it not. And we're going to pass another
not. And we're going to pass another folder. We're going to name it chats.
folder. We're going to name it chats.
Chat like this. And we're going to have here another folder. We're going to name it router. We're going to put in all our
it router. We're going to put in all our roots like this. And now let's head into the layout folder. And we have here the off layout. And in here I'm put in this
off layout. And in here I'm put in this boiler plate off layout. I'm going to copy that. I'm going to put it into the
copy that. I'm going to put it into the chart layout. I'm going to modify here
chart layout. I'm going to modify here the name of this layout. And here I'm pass. Yeah, we're going to pass ch
pass. Yeah, we're going to pass ch layout. We're going to head into the
layout. We're going to head into the note layout. And then we're going to put
note layout. And then we're going to put in this code. And then we're going to pass here note layout. And in here guys, you can see I just pass here a div and
inside inside of this div we have another div and I pass here the outlet is where we're going to inject the page.
Okay, the contents of the page that we want to use inside this layout. Now
we're going to head into the pages folder. You can see we have here notes.
folder. You can see we have here notes.
You can see we have here off. And in
here I'm pass login page. TS6. Okay,
like this. And I'm going to head into the app thet6. I'm going to type everything in here. I'm going to put it inside the no inside the login page.
Okay, like this. And here I'm passing log login page. And I'm going to get rid of these icons. Okay. And I'm going to
get rid of these two. Okay. Let me
remove this tag and this one here. Okay.
Like this. I'm going to remove this. And
then I'm going to stay with the H1. And
then I'm going to pass it inside the div and pass here login page like this login page. And I'm going to export the login
page. And I'm going to export the login page and pass it to and pass here like this. Now we're going to create here the
this. Now we're going to create here the notes page. Yeah, let me create the chat
notes page. Yeah, let me create the chat page here. And I'm going to copy
page here. And I'm going to copy everything in here. I'm going to put it into the chat page. Pass here chat page.ts
like this. I'm put in this code and pass
like this. I'm put in this code and pass here chat page like this and I'm copy that pass it in here and here going to pass here chat page we going to head
into the note folder and pass a note page note page ts6 we going to pass in this code I'm going to head into the chat pagets the tsx we are going to cap everything
in here we're going to put it inside the notes page like this okay and then we're going to modify going to pass notes page And here for the name of the function, we're going to pass a note page. We're
going to copy that. We're going to pass it in here. Done. And now we're going to head into the router. We're going to pass index.tsx index.ts
pass index.tsx index.ts like this. And we're going to set up the
like this. And we're going to set up the router. Now, in order to set up the
router. Now, in order to set up the router, we're going to head up in here.
I'm going to copy this code in here.
We're going to pass it in here. Okay.
And let me see. We are going to import here the create browse router. I'm going
to copy that. Let me copy that here. And
then I'm passing in here. Okay. And
we're going to copy this second line.
We're going to put it inside the main.tsx. Okay. We're going to pass it
main.tsx. Okay. We're going to pass it in here. And we're going to get rid of
in here. And we're going to get rid of the app. The TS6 and pass it in here.
the app. The TS6 and pass it in here.
And I'm going to get rid of the app.ts.
I'm going to remove the page. Okay. We
aren't going to use it as the entry point. And here I'm going to copy this
point. And here I'm going to copy this line here. I'm going to pass it inside
line here. I'm going to pass it inside the render function. I'm going to copy that and we're going to pass it in here like this. Remove this like this. Oh, we
like this. Remove this like this. Oh, we
we don't copy it. I'm going to copy that. And we're going to pass it in
that. And we're going to pass it in here. Yeah, let me pass it in here like
here. Yeah, let me pass it in here like this. And we're going to create the
this. And we're going to create the router constant. Let me see if we
router constant. Let me see if we already create it. Yeah, I'm going to export the router here. And then we're going to pass it to the root provider.
Okay, let's import it and then pass in here. Now let's head into the router and
here. Now let's head into the router and in here going to import all our components in here. Now we're going to start. We're going to pass here the path
start. We're going to pass here the path and pass here for slash of and we're going to pass here the component property and pass here lazy. Okay, like
this pass component property. We're
going to pass lazy and I'm going to import the lazy function from react. We
use here laz loing. In case we visit the off, we're going to load this page.
Okay, we're going to load this page on demand and and now we going to pass you.
So the children property and the children property we're going to pass in roots. Okay, you can see this is the
roots. Okay, you can see this is the layout and layout has pages and these pages are children and I'm pass. Yeah, I'm going to pass a
I'm pass. Yeah, I'm going to pass a path. and pass here login and we are
path. and pass here login and we are going to copy this again. We're going to pass it in here. Yeah, I'm passing here.
We are going to head into the pages folder and pass a for/ of/ login page like this. And now we're going to pass the chat page and also
we're going to pass here the notes page.
I'm copy that. And then we're going to pass here chats like this. and we're
going to head into the layout folder.
We're going to pass a chat layout and I'm going to consider the the chat page is the index. Okay, pass a chat and then
chat page and I'm going to pass here index. Yeah, let's pass index is equal
index. Yeah, let's pass index is equal to true. And we're going to treat the
to true. And we're going to treat the chat page as the index. And now I'm going to copy that again. We going to pass a bottom in here. And I'm passing
nodes. We're going to head into the
nodes. We're going to head into the layer folder. We're going to pass here
layer folder. We're going to pass here not layer and pass here pages for slashnot for slash not page like this.
And we're going to treat the note page at the index and then we're going to pass here another page not found. Okay,
I'm going to copy that in here. Okay, in
case we pass a path which doesn't exist inside the router, we are going to load that page. We're going to head into the
that page. We're going to head into the pages folder and then we're going to pass you 4404 and then we're going to pass not page.
Then we're going to pass in here and once done we are going to head into the index.ts file and in here we're going to
import not fun page. Okay, pass here not fun page and we're going to copy it and we're going to pass it in here. pass it
in here and we're going to get rid of hello world like this and I'mma pass here an asterisk. Okay. Yeah, let me Yeah, this is an asterisk. This is an
asterisk. And actually we have here
asterisk. And actually we have here typing error. Okay. This syntax is not
typing error. Okay. This syntax is not allowed. Okay. Now to remove this typing
allowed. Okay. Now to remove this typing error, I'm going to pass here index.ts because we use here we we import here a
JS6 element. Okay. Now pass here T6.
JS6 element. Okay. Now pass here T6.
Okay, like this. And then we're going to remove this error. Now let's head into the K brand and we're going to type npm rundev and we are going to check that.
Now I'm going to click here and I'm pass for slashnotes like this and you can see notes and if we pass a page which doesn't exist,
we're going to get here page not found.
Okay. And some pass charts and we're going to move to the chat page. Okay.
Yeah. Let me check in here. We're going
to head into the chat page. Yeah. Chat
page. And here we should pass here chat page. You're going to see we're going to
page. You're going to see we're going to have here chat page. Okay. You can see like this. Now, let's head into the
like this. Now, let's head into the main.ts. Men. TS6. And in here, we're
main.ts. Men. TS6. And in here, we're going to import the index. CSS file. I'm
going to use side effects import.
And then we're going to pass here index.
CSS. And now, let's head into the login page. And in here guys, we're going to
page. And in here guys, we're going to import the Google icon. I have the Google icon in here. This is a PNG.
Okay. And we're going to pass it to the button. And we're going to pass a login
button. And we're going to pass a login page. We're going to pass here a a
page. We're going to pass here a a function handle Google login. And once
we click here, we're going to redirect to our back end of/g Google in order to off. We're going to pass here this div.
off. We're going to pass here this div.
And then we're going to pass here h1.
Welcome. Welcome back. And we're going to pass a sign in to continue to your account. And we're going to pass a
account. And we're going to pass a button and on click handle Google login.
And we're going to pass it the image.
And now let's see what we got here. If I
pass here of for/lo and you can see we have here a beautiful login page. And
let me see here. I should pass here lo continue with Google like this. Yeah,
let pass continue with Google like this.
And now let's check again. Okay, we have here beautiful login page. Now let's go ahead and work on the note page. And in
here guys, we're going to focus only on the logic implementation but not on writing tint CCS code. We need to speed up. Okay. And in here we're going to
up. Okay. And in here we're going to pass this. And I'm going to remove this.
pass this. And I'm going to remove this.
And I'm going to import the plus icon from Lucid React. And then we're going to have something like this. We have a car. And once we click on the car, we're
car. And once we click on the car, we're going to pop up a model in order to create a note. Now, we're going to head into the note layout. And in here, I'm
passing simple menu. And we have here link notebook alarm. And then we pass here an avatar. And here's how it looks like. Okay, this is a simple menu. Now,
like. Okay, this is a simple menu. Now,
we're going to head into the component folder. You can see we have a components
folder. You can see we have a components and we're going to pass here notes.
Okay. And in here we're going to pass here notcar nodescar.ts do yeah nodescar.ts
dot ts6 like this. And we're going to pass here.
Okay. In order to create a stateless function component. I'm tap inner and
function component. I'm tap inner and I'm pass here nodes car like this. And
in here we're going to import brand image from asset folder. You can see inside my assets folder. I have here the brand image brand.png PNG and this is the image. Okay, I'm going to use it for
the image. Okay, I'm going to use it for testing purpose and we're going to define a type notes. We pass the ID, title, date, sources, color, and image.
We're going to pass in that type note car props. We pass a property notebooks
car props. We pass a property notebooks and we pass an array of notes and we pass we pass to our component. This is
the prop note car props and we're going to pass here notebooks map to iterate through the array of nodes and then pass a div. We pass you the key and I'm going
a div. We pass you the key and I'm going to pass you the image. We're going to pass you the title, but also the date and source. And now let's go ahead
and source. And now let's go ahead inside the notes. We're going to head into the note page. And in here, we're going to import the components and pass notes car like this. And then we're
going to pass it this props and pass it not books. And then we're going to pass
not books. And then we're going to pass it an array of notes. And then this is an array of notes. And I'm going to copy that notebooks. I'm going to pass it in
that notebooks. I'm going to pass it in here. Okay. And let me get rid of this.
here. Okay. And let me get rid of this.
And I'm pass a single a single tag.
Okay. Nodes car. And now let's see what we got in here. I'm going to move in here. And then you can see we have here
here. And then you can see we have here our notes. Okay. We have here untitled
our notes. Okay. We have here untitled notebooks. Retrieve augmented
notebooks. Retrieve augmented generation. This how it's going to looks
generation. This how it's going to looks like the notes page. Okay, we are going to fetch data from the server and then we're going to pass the data to these cards. Now we going to create a model in
cards. Now we going to create a model in here. And to create a model, we are
here. And to create a model, we are going to go shut and then [clears throat] we are going to copy this code. Okay, in order to in order to use the model, okay, we're
going to cop this code. Now, in order to get this model, we are going to tap this command. I'm going to head into in here
command. I'm going to head into in here and we are going to tap npx shut cn atlaris. We are going to install cards
atlaris. We are going to install cards components. We're going to install
components. We're going to install checkbox. We're going to install label
checkbox. We're going to install label components dialog inputs instead of instead of installing a one by one components. I prefer to install all
components. I prefer to install all these components at once. Okay. You're
going to tap here npx. You're going to type here npx shut scene aladdis add car checkbox label dialog input and then you're going to tap in and done. Once
you install all these components we are going to continue. We are going to head into the component folder again and you can see actually I've already installed
them and in here we are going to pass here another folder and name it common.
Okay. Uh I'm going to name it common.
Yeah, I'm going to name it B. And inside
the base folder, I'm putting base components and pass here base model like this. Base model.ts.
this. Base model.ts.
So, what is the base model component?
The base model component is basically a model that we're going to use in order to create our model. Now, let me show you an example. We're going to head into in here and then I'm going to pass this
little model. Okay, you can see we have
little model. Okay, you can see we have a model. Let's say this is a model and
a model. Let's say this is a model and inside of it we have model content.
Okay, we have the model content div. We
have here model a a model class. Okay,
and inside of the model class we have the model title, model description. And
here we have the model body where we can put in inputs. Okay. And we have and we have also the model footer. Now, instead
of using all of these all of these stuff here, I'm going to create a component named B model. And then once we call this B model component, we're going to
pass it the T prop. We're going to pass the description, but also we're going to pass it the input like this. And you can see that we eliminate a lot of stuff
from here. We don't use all of this.
from here. We don't use all of this.
This this notes model here is much clean, okay? because we pass it only the
clean, okay? because we pass it only the title but also this but also the description is much clean guys. Now
we're going to do the same thing with the dialogue component provided by SH CN. And in here this is the alert
CN. And in here this is the alert dialog. Okay, alert dialog. Let me see
dialog. Okay, alert dialog. Let me see in here. Okay, this is an alert dialog.
in here. Okay, this is an alert dialog.
Okay, we going to use a dialog component. Okay, I'm going to move here.
component. Okay, I'm going to move here.
Let me tap here. Dialog dialog you can see at the left in here we have dialogue click here and yeah this is the dialogue
okay the dialog components now in order to use it we need to cut this code you can see we have a lot of stuff from here now I'm going to simplify this now we going to head into the base model let me
remove this from the index html file let me remove this all of this and and now let's head into the base model. And now
we're going to head into the base model.
And in here we're going to import React.
We're going to import the necessary component in order to create the dialogue. And we're going to pass the
dialogue. And we're going to pass the base model props. And we pass here the open prop. This the boolean the open the
open prop. This the boolean the open the on open change function. We're going to pass it [clears throat] the open property is boolean. And our function
returns the void tab. Pass it the title description children. Type it is react.
description children. Type it is react.
to react node pass the footer with the width and the height and these components in here has this property. If
you click here API reference they're going to take you to this page to radicscui.com and then in here we have all all of these property that we need to pass to the dialog component. You can see we
have this property in here. You can see we have here the open property. Let me
zoom a little bit. We have the open property on open chain function. We have
here the model the the model property.
This is the boolean and all of these property I copy all of this property from here guys in order to create the model. Go at radicsui.com. Okay. And in
model. Go at radicsui.com. Okay. And in
order to move there click dialog. And
then you're going to click here API reference. They're going to take you to
reference. They're going to take you to this page and you can learn more about the dialog component how it works. Now
we going to continue going to pass it the base model props and then we're going to pass the function base model and we're going to pass it this property
the open on open change title description children footer width and height and we're going to type it as the base props and we're going to pass it
dialog okay we're going to pass the open property is equal to open on open we going to call on open function on open change function and then we're going
pass the dialog contents and we're going to pass here the style, the width, max width, the height and I'm passing the ton description. We're going to pass the
ton description. We're going to pass the dialog header. We're going to pass it
dialog header. We're going to pass it title and the description. And we are going to pass here the body and pass it children. And here we're going to pass
children. And here we're going to pass the footer and dialog footer. And now in order to use this motor, we are going to head into the note folder. And in here
we're going to pass your component create and pass create nodes model.
And then we're going to learn how to use the base model. And now let's head into here and pass and pass sfc snippets in order to create in order to create a
stateless function component. Now I'm
tap inner pass here create nodes model.
Then we're going to import use from react. We're going to import here base
react. We're going to import here base model. We're going to import here the
model. We're going to import here the shut scene button and we're going to define a state open with a function set open. In order to tag the model, we're
open. In order to tag the model, we're going to pass a div and we going to pass the button and we pass a function on click event. We're going to set the open
click event. We're going to set the open property to true and in here we pass the base model. Now we're going to pass some
base model. Now we're going to pass some prop the open prop on open chain function pass set open but also taro is notebook alarm. And here we're going to
notebook alarm. And here we're going to pass the height and width. And we're
going to pass the and we're going to pass the footer prop. And inside the footer, we pass in the button. Now we
are going to try this. Okay, we're going to try this and see what we're going to get. And inside the model here and pass
get. And inside the model here and pass here and pass here contents. Yeah, like this model content here like this. Now let's
head into the notes page. And in here we're going to import these components and pass here create model. Yeah, create
note model. Create note model. And then
we're going to pass it in here. Let me
import it. And now let's try this and see what we're going to get in here and pass in notes.
Okay, let's refresh the page. You can
see we have view button. And you can see that actually pop up the model. Okay,
now let's go back inside the create note model and we're going to pass some content inside the model body and we're going to remove this content. We're
going to pass a def flex justify between matching bottom 10 and we're going to pass add sources and we're going to pass in and discover sources. Okay, pass it
right now. We're going to pass here a P
right now. We're going to pass here a P tag and we put in sources late notebook alam based its response on the information that matters most to you.
Examples marketing plans course reading research notes meeting transcripts sales document etc. And we're going to pass a div with a dashed border. Let's check in
here. We got we have here dashed border
here. We got we have here dashed border and then we're going to put in an icon to specify the area where we're going to upload an image. You can drag a file there. And then we're going to upload it
there. And then we're going to upload it inside of our system. And we're going to pass here a some text again like this.
Drag or drop or choose a file to upload.
And we're going to pass here some actions buttons. We are going to pass in
actions buttons. We are going to pass in this. We're going to pass in this div.
this. We're going to pass in this div.
And we're going to have something like this. This a car. Okay. We have a car.
this. This a car. Okay. We have a car.
And if we copy this car again, let me copy it three times. We're going to have something like this. We have here the first car, the second one, and the third
one. Okay. And in here, I'm going to cap
one. Okay. And in here, I'm going to cap here, the second, and the third car from here. And then I'm pass them in here.
here. And then I'm pass them in here.
Now, let me get rid of this car in here.
I'm going remove this one. And then I'm going to remove this one, too. And pass
this. And then we have something like this. We can upload files from Google
this. We can upload files from Google Drive.
Loading video analysis...