Analyze Any CSV File Using Langchain and OpenAI | Streamlit App #langchain #chatgpt #beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we are going to create a simple application in Python that is going to use CSV as the input file I'm going to create a pandas data frame and it's going to answer some questions whenever the user input a query and we are going to do that using the open AI in the log chain right so let's get into the data so this is the data approved from kaggle and it contains the it's a card sales data okay and it includes information about different cars okay so I'm going to put that in the description below the link to the data so you can grab it right so let's get into the data into the code so you're going to import the OS you're going to import the screen blade as St import pandas.pd we're gonna need a from long tank chain dot agents you're going to import the create pandas at data frame agent okay and we're going to import the openai we are going to import the API key so from API key import API key okay so we are going to set up the environment variable and we're going to stand up to the API key so this is my API key right here it's already set up here okay so I'm going to call that here and I'm going to create the streamlit application so I'm going to define a function called app so inside the function I'm going to create a title in the description so I'm going to say sd.title I'm going to write the CSV query app and I'm going to do the St do right I'm going to write upload a CSD file and end type query to get an answer okay so I'm going to run that using the so inside a terminal I'm going to run the app so let's see the output okay so I'm gonna do how you can run it let's run let's say app file hit enter okay okay so this is the output the initial output so far yep so we say upload a CSV file and enter great to get an answer okay and this is exactly what we've done here okay so let's move forward so the next thing is to create a file upload so I'm gonna say file let me say call to delete a file uploader I'm going to say load CSV file okay we'll see I is equal to CSV okay so what because we want to do at crb file I'm just going to say specify the type of file okay and if not far I'm gonna say there's no file so what I'm going to do is to read it tsv I'm going to put in the file I'm going to write something they want to write something so I'm going to say data preview okay I'm going to say the data so I'm going to print a few lines head data.head print some few lines I'm going to create language model agents so I'm going to say click okay to create pandas data from Agents I'm going to put in the parameters let's open AI only set the temperature to zero or you can depending on the use cases you can change the temperature to so if you do it like 0.9 it means that the ram the randomness is going to vary highly anytime you run the the code okay so I'm gonna set it to zero and I'm going to say no passing the data that's in the data we'll see Firebirds true this means that anytime it runs the agent is going to break it down the processes and the way it is thinking so it's going to give me each of the steps that is I'm trying to solve the problem so if you do it you see variable to go to false it means that it's not going to display any of these it's just going to run it and give it the output yes so that you know okay and I'm going to say query so I'm going to create a query inputs go to sde dot text I'm going to do the input here with the input so you enter query next thing to do is I'm going to execute queries I'm going to say if St we're going to execute I'm going to create a button that is going to execute the query okay answer is equal to the agent I'm going to pass in the query okay we're gonna do that agents that we're going to run the query okay so it's not going to give us the answer the next thing is to write answer I'm gonna put that into trophy text home and answer okay I'm going to write in the answer so let's run it and see so I'm going to do Inlet on a file with pi so let's see okay so we're gonna browse and upload our file and the file gives us the data breakdown preview showing us The Columns that we have in the data okay so by saying that the data.head is giving us the preview of the data okay enter the query here is where we enter the query and we execute by using this code okay so let's ask a question we want to see what is the Factor be the highest is here sale value I'm going to hit execute okay so let's see what is going behind it so because we did the various is going to true it's giving us the step the thought is going through so it's giving us I should find the highest air resale value and get it manufactured and it's actually input is giving us the pandas formulas there okay so we're sorting the values here to Value ascending is equal to force giving us the head okay and it's saying the highest visible value is there Porsche Cabrio so the final answer right so that is also awesome so and it gives you the answer here so you can just vary the questions and see how it's going to execute that and you can also check the temperature you can vary that to see how it works there so this uh short tutorial so you can just go ahead and play with it thanks for watching and please don't forget to subscribe
Info
Channel: DataInsightEdge
Views: 3,608
Rating: undefined out of 5
Keywords: chatbot, language models, CSV files, OpenAI API, LangChain, agents, data-aware applications, LLMs, machine learning, natural language processing, Python, programming, data science, data analysis, data visualization, deep learning, neural networks, artificial intelligence, automation, virtual assistant, conversational AI, text-based interactions, data management, data manipulation, data exploration, data extraction, data cleaning, data modeling, data integration, ai
Id: _S2xud1UsJU
Channel Id: undefined
Length: 10min 37sec (637 seconds)
Published: Mon May 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.