ChatCSV: Chat With Any CSV | LangChain Use-case | Streamlit App

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back I hope you are doing great now let's go through another huge case of Lang chain what if you can chat with any CSV right I created a video earlier about chat with any PDF and for a small Channel like this there were more than 27 000 views but what I decided is to create a simple stream lead app where you can upload your CSV and then have conversation with the CSP but now we are using Lang chain because before we don't know what was used behind the scene right there was open AI HR GPT kind of things but now we know after the land chain it helps us create the cool apps out of it by the way I'm planning to create many videos many educational videos If you want to get notified please be subscribed now let's go and see how we can create the similar application that you are seeing on the screen chat with any CSV how it works you can just click the link you can upload the CSV file and then we can just say how many rows and it will show us how many rows are there in that particular CSV for example let's say there is 1309 let's get started okay so now let's go and see what are the necessary pieces right first you need to create the virtual environment and install the necessary package here is the all the words all the necessary packages I will actually provide the link to the GitHub so you will know what to do I have already created the virtual environment if I just show you here I'm inside this particular folder and chat CSP it is already being created for me and then there is the secret satio ml file I will show you this now although I have the API key because I am going to rebook this anyway you need to provide the API key inside the secrets.urml file so yeah that is the thing and then there is the app and there is the utils let's go through the utils first what we need to do first is of course import the necessary packages right here I have imported many things but the main thing here is that you need to have the agents from the nag chain right from Land chain dot agent we are importing the create CSP agent I will show you the create CSV agent first and then I will also show you how you can do with this pandas data frame agent also so and then I need to have the last language model in this case I'm using the open AI let me run this code first when I run this code it fires our interactive jupyter notebook environment now what next we need to create an agent right agent create CSV agent and I passed the last language model and there is the file that means the CSV file Barber is equals to false I don't want it to display anything now I want to have the answer back that is agent.ron and I pass the query right when I pass the query and I want the answer back I save this file and now I need to have the next file that is app dot Pi what is in the app.pi I am just importing the function that I just created here get answer CSV in the app.pi and now I am creating the stream lead app right I have the header chat with any CSV and the uploaded file because we need to upload the file right it will be St dot file uploads and this is just upload a CSV file and the type will be CSV and if uploaded file is not known meaning that if there is uploaded something what we want to do is the query right the St dot text area ask any questions related to the document and the bottom we need to click the button submit then it will submit the query into the last language model and if button then we can just say Streamlight dot right and then get answer CSV and we have the uploaded file and the query that's all if I just save this what I need to do now is just open the terminal and I can just run stream lead run app.pi when I run the command it will open this in your localhost now it says chat with any CSV upload a CSV file you can just upload the CSV file Titanic CSP and now you can see how many columns are there let's see let's say how many columns rdf you can just type this and if you just click the summit it will go through the CSV and show us how many columns are there okay there are 28 columns and you can even go and say what is the data set about and let me submit this let me see it provide because I haven't provided any information about what the data set is right the data set is about passengers on a ship it went through the CSV file and then find that okay there is something related to passengers on a ship because this is the Titanic data set yeah you can ask as many questions as you want into this we can even say that how many passengers have siblings right if I submit this it is going through the CSV file and then it will provide that how many passengers okay 653 passengers have the siblings this is how it works because although we are uploading the CSV file behind the scene it is using the pandaj agent now we know it works properly right I will also show you now the next how we can run this not in the app but in the notebook or vs code itself that we get the answers right in the vs code not in the UI like this okay why I am showing you this is because when you create the applications you will first test it locally and then only you will deploy right for that what I need to have Is We I need to have the open AI key here for the local development let me run this line now I have the open AI API key which takes it takes from the secrets file now let me go here and before I was passing the CSV file what now let me just read the CSP because I have uploaded the same Titanic CSV file here what I'm going to do here is with the data frame as DF I'm going to run pd.read CSP Titan ecsp now it reads the data set now let me just read the CSV file itself right if I type DF then I can actually go here and see that okay there is 1309 rows 28 columns and so on right there is already this shape for me here I am using the data frame not the file right what I can do here is I can just comment this and then on comment the next slide which here what I am passing here is Agent equals to create pandas data frame agent before we were creating the CSP agent right create Panda's data frame agent we pass the last language model as open AIS model and then we pass the data frame instead of file now if I run this line now it says okay agent is being created now I can ask questions inside the vs code itself because before I show you how you can do in the UI right but when you are developing you will be going one by one and seeing what kind of things you are doing right now what I can do is here is the query I have okay Ctrl Z here is the query that I have already created how many rows are there in the CSV file because I just want to give you the example what I can do is I can run the query and then I can pass that query into this particular agent now instead of returning in the function I can now just highlight this part here and if I run this line here it is going to run the query for me as you can see here it is loading and now it says here there are 1309 rows in the CSV file what other questions do you want to ask here I see that there is the age column here right let us ask one one question related to is instead of how many rows are there I can pass here what's the square root of the average is meaning that it needs to go fast and find the age and then the average is right if I run this command it says that okay what's the average what's the square root of the average is and now if I select this particular code and if I run this it is now going to again do the query for me and it shows the average age first and then the square root of that average is right it's still calculating let's say okay the square root is 5.43 this is how you can quickly interact with the large language model yeah that's all for this video it was just a short video where I just want to show you that blank chain helps you create so much powerful things and here I just provided the CSV file but this is the pandas data frame right you can even past Json Excel file and other different kinds of file into the data frame and then we can query into the data frame with the large language model let me know if you want me to create some other videos related to this but I'm actually exploring the lines and documentation and it's actually fun to create useful videos that's all for this video thank you for watching and see you in the next video
Info
Channel: Data Science Basics
Views: 5,168
Rating: undefined out of 5
Keywords: openai api, code, chat ai, large language models, llm, what is large language model, chat, langchain, lang chain gradio, langchain demo, langchain tutorial, langchain openai, langchain explained, framework, openai langchain, what is langchain, langchain hugging face, langchain chat gpt, langchain tutorial python, langchain tutorial pdf, llms, chat models, prompt, chain, agents, langchain use case, autogpt with langchain, chatcsv, csv, chat with any csv, pandas, csv agent
Id: ZwxdQB9HjTU
Channel Id: undefined
Length: 9min 16sec (556 seconds)
Published: Mon May 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.