2-Building Multi Agentic AI RAG With Vector Database

Krish Naik · Advanced ·📊 Data Analytics & Business Intelligence ·1y ago

Key Takeaways

Builds a multi-agentic AI RAG pipeline with Vector Databases using Python and the Fi framework

Full Transcript

hello all my name is Krish naak and welcome to my YouTube channel so guys uh I'm super excited to probably continue the series of agentic AI application and in this particular video we are going to build agentic AI application wherein agents will start communicating with Vector databases to probably uh ask any queries and try to get a specific kind of response okay now we are going to go ahead one step ahead already in our previous video we have discussed about how we can probably create an AI agentic application which can integrate with multiple tools here we going to use external Vector databases which will be quite amazing for learnings right uh one more amazing thing guys uh in the previous video I really got an amazing response from all of you thank you very much for supporting this specific series uh one important thing that you really need to do is that like how I kept a Target in the previous video in this video also I'll keep a Target the likes is 1200 1200 likes is the minimum likes that you really need to go ahead and and give along with that we will keep a target of 150 comments so please make sure to do this the reason is very simple I will get motivated I'll try to upload more and more videos for all of you along with this if you start interacting on these particular videos if you have lot of discussion these videos will be probably recommended to many many people out there and yes many people require this kind of videos itself okay so um let's go ahead and probably share my screen and uh I will probably talk about the problem statement now before we go ahead uh I already told you in my last class right in my last video one very important thing that uh one issue that we are getting is that to probably use the open API key right when we are trying to run this particular code and the reason was very simple because uh over here in the multii agent you know even though we were using GRS over here in the independent agent right here we are using Gro and Gro usually has open source models right llm models but here we did not gve any model over here right so that is the reason by default it was considering the open AI models right so this is the code change that you really need to do because many people had actually suggested in the comment see this is quite amazing people started giving suggestions hey you probably go ahead and give the model and the issue will get solved and there's some people also who converted this entire application into a streamly project that was the Super exciting thing for me okay so please make sure that you go ahead and update this and automatically your application will start working now the next thing what I'm actually doing is that I'm creating a PDF assistant now here I'll be creating agents that will be interacting with your vector database because this kind of examples also you need to shap okay now if I probably go and see this five data you know so they are multiple things let's say if I go ahead and see some Vector DBS there is like multiple DBS like PG Vector quadrant pine cone L DB chroma DB single store let's consider that I'm going to probably use uh PG Vector okay let's see that uh I'll go ahead and use this PG Vector this is my Vector database right now from this particular Vector database what we are basically going to do is that we first of all going to run it in our local now there are two ways how you can run it right one is directly run it uh in the form of Dockers in the docker container so here what I'm actually going to do is that I'll go ahead and run this particular command and automatically uh this particular uh Vector database will be running in my Docker so you need to have Docker desktop installed I'll be showing you step by step how things can be basically done okay now what happens in this particular Vector database later on if I upload any PDF URL right then that PDF URL content will be extracted and it will be stored in this Vector database right and then I will try to create an agent which will try to interact with this Vector database now why I'm creating this see if I show you one example you can probably explore all the other examples like quadrant pine cone Lou DB chroma DB and that is what I'm going to probably give you an assignments as we go ahead you know so that you can also go ahead and practice along with this I will also I have also started exploring one very important thing which is called as this knowledge right now what is this knowledge knowledge base is a database of information that can Agent can search to improve its responses now if I probably see over here there's something called as PDF URL now here what does this PDF URL does is that uh it reads the PDF from URLs like let's say if I'm having a PDF URL if I just give the URL it will read them convert that into Vector embedding and load them into a vector database so what I'm actually going to do I'll also use this okay I will read any PDFs I will try to convert that into vector and store in the PG Vector now this is just one example you can use anything you can use R save you can use combined you can use CSV whatever things you basically require you can actually do now see if I probably see in PDF URL here we are giving some post gr SQL uh URL right and this right now is uh will be running in my do Docker right uh if I don't want to do it from my local I can also go ahead and probably host it in some AWS or aure database and from there I can just get the link and just upload it over here okay so step by step this entire application will be created so this is what I say a agent which can interact with your vector database but initially that agent should read the content and upload it in the vector database right so that kind of chatbot we are just going to create over here okay so now let's go ahead and let's start writing the code okay so first of all I have created a file which is called as PDF assistant. py so here I have imported two like Li so let me just go ahead and hide my face so that you focus on the coding okay now along with this what I'm actually going to do I'm going to also upload one very important Library which is called as assistant now this assistant have not taught in my previous session right so in this session I'll also go ahead and show you what this assistant basically does okay assistant is just like a independent AI autonomous AI you know which will be able to assist for different different task okay so we are going to do this uh along with this uh there is also something called as PG assistant storage okay this is specifically for the storage so if I just go ahead and import this see 5. storage. assistant postgress PG assistant storage so if I go ahead and see over here there is something called a storage inside this uh inside this there is something called as post Grace and we are just going to run this PG Vector right and here you'll be able to see that we have also imported this so PG agent storage is there there is also like PG assistant storage okay and somewhere here or there it should be there inside this particular storage itself okay so for right now let's go ahead and use this uh if you want to use any other database there also multiple database which you can specifically use at the end of the day this is just going to create a session and some temporary file name where it is going to get stored but right now I'm just going to run everything into the docker so I should be able to run it okay so let's go back to my code and I have imported this along with this I told you I'm going to import PDF URL knowledge base the reason is I will read the PDF URL and try to probably read the content out of it and try to save it in a vector database okay then the kind of vector database I'm going to specifically use is PG Vector how do I get this particular class it is very simple just go to my Vector DB see in the PG vector and just go ahead and copy it see here you have URL knowledge base here you have PG Vector you can just go ahead and copy this right there is also one more variant of PG Vector that is PG Vector 2 so it is really necessary that you start seeing the documentation because in the documentation you almost have each and everything okay perfect this is done now I have imported all these libraries now the one important thing that you also need to know about this is that you need to make sure that you also install all these libraries but we'll see step by step whenever we start getting an error okay not right now but whenever we get an error we will try to probably go ahead and see it okay so this was my another library now along with this I'm going to import o okay along with this I'm going to probably go ahead and write from EnV import load. EnV and then I'm going to initialize load. okay now first thing I will just go ahead and set up my environment variable and the environment variable that I'm actually going to use is nothing but um I don't want open a API key because I'm not going to use it so instead of setting the environment I'll just go ahead and use my Gro API key because I require my Gro API key so I'll just go ahead and write Gro API key I will copy it over here and I'll set up this particular environment and I'll say hey os. getv and here I'm going to use my grock API key perfect so this I think is the most common step that we have specifically used okay now let's go back to the documentation we have to create this particular DB URL because see as soon as we run this okay run this uh command uh we should be it should be running inside our Docker with this URL okay so what I will do I will just go ahead and copy this and I'll run run this okay so in order to run it first of all you need to have your Docker desktop started okay you need to install your Docker desktop and now I will just go ahead and open one git bash okay git bash so let's open the git bash and I'll paste it over here okay so this is the paste now here you can see that error response from demon conflict PG Vector already in newed okay no worries so the problem is that I have already tried it out so I'm just going to delete this PG vector but if you're doing it for the first time you don't have to worry about it okay now I will just go ahead and paste it over here and now it should run okay and uh here I think it should be running okay so now this has started and the URL is 55322 5432 so my URL should also be set up in that way only okay so if you see over here 5532 right so I will just copy this DB URL with 5532 okay 5532 perfect uh so this is there I'll paste it over here okay I will this will be my dbrl okay now step by step we have specifically do done each and everything we have set up our DB URL and all okay over here I will not run it right now because as soon as we run because we need to also install some of the libraries that you'll be able to see uh in just some time like what are libraries I will require now I will just go ahead and create my knowledge base okay so my knowledge base will be with respect to all the PD PF URLs that I'm actually going to give because I'm saying that hey you have to probably retrieve from this many number of PDFs so here I'm just going to use my PDF URL knowledge base as I told you I'm going to use this the first parameter is something called as URLs okay now inside this URL I'm going to use one URL uh which was also available in the documentation and here this is the URL right https 5 public S3 Amazon aws.com recipes thy recipes.pdf so if I go ahead and see this URL this is what the PDF is you know so I can probably get lot of details from this what are the content see all the details like if I want to probably make this particular dish these are the ingredients and all what are health things is there how much preparation time all this information is available over here so we'll try to probably create a chat bot which will be able to interact over here okay then the next parameter that I will be using over here is my Vector DB right so my Vector DB will be nothing but my PG Vector which I have initially ized PG Vector 2 okay and I will say hey let's create a collection name over here my collection will be nothing but I will write recipes and I will say hey this is My dbor URL okay is equal to dbor URL okay so whatever URL I've actually set it over here with respect to this dbor URL that will be there okay now uh along with this what I will do as soon as I create my knowledge base as soon as we run this program we need to also load it so here here I will write knowledgebase do load okay and then uh storage is equal to PG assistant storage and here I'm just going to give my table name okay my table name let's say I'm going to write a PDF assistant okay and again this DB URL is equal to DB URL so this will basically be my PG assistant that is the postra uh whatever Vector database that I'm specifically going to use okay now this is really important because now we are going to create that assistant that we specifically require okay and uh from documentation that I have actually seen uh this is just like a function you know we specifically just create a function and we try to uh load this up okay now in order to probably explore this uh I will just go ahead and copy one code okay and here I'm not writing anything because no python code specifically normal python code is required but we are just seeing the documentation now this definition PDF assistant we are just going to create it as a function and remember this name should be same as this particular name okay new Boolean is equal to false user is equal to string is equal to user now finally we have to create this assistant so here we will be giving the same run ID uh which we have mentioned earlier okay uh and this run ID will be assigned once we start the program right then you have this user ID is equal to user knowledge base is equal to knowledge base right uh then you have the storage uh then you have this show tools uncore call is equal to True search knowledge equal to true and read chat history is equal to True with the help of this we will be enabling the assistant to read the chat history with this we are enabling the assistant to search the knowledge base and here we are also showing that hey you can specifically use the tools in the response okay now if you're running it For the First Time The Run ID is going to become none and then we assigned a assistant. run ID then we start the specific run right and then we are running this in our command line prompt okay so that is the reason we are writing ccore app markdown is equal to true and then we are running this program from here where we using this typer right the imported Library over here typer do run PDF assistant right so this is what we are specifically using over here okay so I hope uh you have got an idea with respect to this this is more about the things we are specifically doing in the documentation like this is basically referred from the docum mentation now as I said like if I run this particular code right there will be multiple issues that will probably come because I'm not installed the libraries that is required when we are using uh our Vector database right like PG Vector so we need to probably import some of the libraries for this install some of the libraries for this along with this uh you'll also be seeing that we require some more libraries like SQL Alchemy and all right so here in the requirement. txt you can see that I have put up this four different Library Li which we are going to probably install SQL Alchemy PG Vector uh uh psyc PG binary and Pi PDF Pi PDF is specifically for the PDF reading right now let me just go ahead and open my terminal okay and uh here I'm inside my VNV I will quickly go ahead and install my requirement. txt okay let me just go back or let me just open one more command prompt so that it becomes easy for me to handle because I have two two different paths right so here what I will do I will write cond activate VNV and now from here I will just go ahead and write pip install minus r requirement. txt okay so the requirement. txt is already installed for my case like I've already done this installation to test the application now I will just go ahead and run my python PDF assistant so sorry first of all I need to change my path and for that I can go back to my command prompt I'm inside my PDF assistant and then I will go ahead and write python PDF assistant. py okay so uh this is perfect now here you can see oh the loading the knowledge database it is reading this specific PDF and this PDF looks something like this you know so this is the entire PDF you know uh we can get all the ingredients all the dishes you know all everything we can specifically get from here right so so let me see okay now I'm actually getting this uh it is showing this user and all the documents have already been added in my uh Vector database so let me let's down all the dishes okay so I'm just going to asked one question so it is just going to search this knowledge base and now it has uh it is providing me all the details from that particular PDF this is quite amazing right now you can use any number of PDFs you want but the answer is quite accurate let's say that I want to probably see the ingredients okay so what are the ingredients of this dish that masam guy masan guy okay so here we are going to oh nice 300 G chicken rum 80 g this this this this roasted peanuts everything is basically coming up right this this is rich in vitamins and minerals such as Vitamin A B6 c e k these all things are there right let's say that uh I ask how to make this particular dish okay so here again it is probably going to see okay it is also giving the same ingredients like these all ingredients you can specifically use oh now this is nice to make tamarind rid juice this this this directions okay it has also given the directions now how to make it right now just imagine if I have a knowledge database of like this and I'm able to interact it you know probably I want to convert my entire GitHub repository in this per format by uploading multiple PDF storing everything and people can directly use it as a chat bot and get all the answers right this is quite amazing the main aim of this particular project was to Showcase that how we can use multiple tools to make it as a complex workflow and solve this kind of problems right isn't it quite amazing right now one assignment for you try to convert this as an end to-end project try to use streamlit uh try to convert this so that you'll be able to use a front end where you can actually give your inputs and you can probably do it right anyhow I will be providing all the information in the description of this particular video now one very important thing guys uh these all videos are crucial because whenever you go and nowadays you can work in the company people are going to definitely ask you and here my main aim is to Showcase how you can probably get started how you can probably get start thinking of complex work flows and how you can solve it right so yeah this was it from my side I hope you like this particular video I will see in the next video thank you take care bye-bye

Original Description

Materials has been upload in the dashboard https://learn.krishnaikacademy.com/l/91b8976f97 In this video we will be creating our first multi agentic ai rag with Vector Databases -------------------------------------------------------------------------------------- Get ready to excel with Agentic AI, the ultimate learning tool for personalized growth and innovation. To make the most of Agentic AI, we recommend our Advanced NLP with Generative AI Course to cover key prerequisites and ensure you're fully prepared. 🎁 Holiday Offer: Enroll in Advanced NLP with Generative AI or any live course and get 30% off with code SPECIAL30. Visit https://www.krishnaik.in/liveclasses to explore our range of courses designed to elevate your expertise. 📞 Call or Text Us on WhatsApp to Know More About Live Courses: +91-9111533440 --------------------------------------------------------------------------------------------------- Join my community channel Whatsapp channel: whatsapp.com/channel/0029Va9q4Yh2Jl8NIS1oPX01 Instagram: https://instagram.com/krishnaik06 Twitter: twitter.com/Krishnaik06 Disscord: discord.gg/Ca3P7AZ5re
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Krish Naik · Krish Naik · 0 of 60

← Previous Next →
1 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
50 Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related Reads

📰
Omnist: Canonical Schema and Data Model for JSON, YAML, TOML, and XML
Learn about Omnist, a canonical schema and data model for JSON, YAML, TOML, and XML, and how it simplifies data conversion and schema management
Dev.to · Thomas Lee
📰
Grouping and Aggregating Data Like a Pro
Master grouping and aggregating data using pandas' groupby() function to improve data analysis skills
Medium · Machine Learning
📰
Grouping and Aggregating Data Like a Pro
Master the groupby() function to efficiently group and aggregate data in Python
Medium · Programming
📰
Classroom vs Online Data Science Training in Hyderabad | Coding MastersClassroom vs Online Data…
Learn why data science is in high demand and how to get trained in Hyderabad, whether through classroom or online modes, to boost your career
Medium · Data Science
Up next
This could be the most perfect data frontend
Matt Williams
Watch →