CHAT with ANY ONLINE RESOURCES using EMBEDCHAIN|STREAMLIT with MEMORY |All OPENSOURCE #ai #langchain

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video we are going to build an exciting project it's an online resources chatbot so this allows you to paste a single or multiple URL links and be able to chat with them okay so I'm going to show you how this works we are going to do that using the embed chain I have free llm and open source and an embeddings as well okay so we couldn't go through slide demo so you can actually select a multiple we can just select two links here okay right so you can paste in your link here in this case I'm demonstration purposes I'm going to do just one and I'm going to use this link right here okay I'm going to paste it here and I'm gonna hit enter all right so let's ask a question let's chat let's chat with the URL is an embedding um document right here okay so I'm gonna say my face a base where you send all right so I was um I asked a question what is Vector database and it's saying that Vector database is a type of database that stores data in a hierarchical structure where each record contain a set of values that represent the attribute of an object yeah it's quite um awkward here all right so let me ask another question I'm going to say what paste place the type of burden and matching let's see how it comes right yeah so it's giving us some answers here let's see what it's saying all right let's list the type of convert chain is saying embedded up web app native app all right it's basically I'm asking the um questions about the documents here okay all right so we are going to go through how this is built step by step okay it's pretty unexciting um project all right so let's see um okay so I already have a video on embedging I'm gonna type the link so you can look at it just to give a pretty um a view of a bad chain it's a framework that helps you to create um llm powered Bots over edit data set okay all right um so it they have some types here so the types of the and Beijing we have that one that uses the open AI Keys the llama2 they are all paid versions okay you need an access to API token but in today's video we are actually going to use the open source we're going to build the open source app so we are going to use the um open source and burdens and Aliens so we are going to use the um the old Mini from the sentence Transformers Library as the embeddings so as you can see right here from hanging face we're going to use the sentence Transformers as the embeddings right so embeddings are nothing but the representation of the texting numbers okay and we are going to use the gpt4 all as the llms all right there are open source so we do not need to set up an API key so we only need to install the embedding package and everything comes out automatically so right so it's pretty simple and straightforward all right all right so let's get into this um before we do that let's get into the code we are going to build actually build this application step by step right okay so in my um BS code I have started um startup code over here already so created the environment okay so let me just click in here and start a new terminal okay so I'm gonna attach the link to the GitHub so you can grab the code and just play with it okay all right so setup environment if you don't know how to do that in your um item on your vs code in your terminal or your coding platforms you just go and say python v e m v and zemv then hit enter and you're going to see the environment created right here okay and we need this packages to be installed so we're going to do embed chain we're going to install the scrimlet and we are going to install the scrimmage app so we're going to create a chat box right right so if you want to install the requirement you say install Dash R requirements yeah d x t and you hit enter right have that installed already okay so the next thing is let's start creating the application so we start we import streamlight.sd extremely to create a um data frame I mean the framework and the screenplay chart to create the chat box system message so we're going to be adding some memories to it so we can record the history okay from an embed chain we import the open source so this contains the uh so I know the whole is having some launching capabilities okay we have the llms the open source and the um Transformers sentence Transformers or in the open source app so everything is free pre-installed in there so we don't have to worry much about that okay all right so the next thing is to create a scrimlet app title and so all right so let's start from here I'm going to say Sable and now we say create streamlined app title and description as the online resources shut up and we put a symbol on sign of books all right and we say yes did all right we say enter multiple URL links and ask questions about embarrassment all right so now let's run this and see simulates and up the pi hit enter all right and there we have it we started initial so let's move on so the next thing we want to do now is we want to initialize the open source instance so here we say foreign initialize initialize European sauce instance right so we're gonna call it any name that we want call it so it's a see pixels up so we initialized it okay so this is what I mean looking through this real quick Okay so first of all we have installed the embedging so we import the open source app so the open source app contains all this um llms and everything in there so we don't have to really worry about that okay so now let's go back to the code and we are going to say when we initialize that we are going to get user input for urls okay we want to get the input for the URLs we're going to say URL links Ctrl STD number I'm going to input the numbers the URL link so you can see enter the number of urls okay I'm going to go ahead come on we're going to say the minimum for the minimum value is equal to one so the value is equal to one so we want the minimum value equal to one right and we are the step of one okay and we're going to say urls input three start with an empty list so we are going to create an empty list now we are going to iterate through the range of the number of links okay so we're going to trade through the number of links it's a for you are for I in the range of the number of links here we are going to say that create an input inputs right I'm going to write something you see enter URL at this so we are now going to count okay let's equal to the URL right we're going to pass in the the number okay so that when you trade through the inputs um through the links we're going to create that input text that we say enter the URL so it probably going to be counting the number of URLs that you enter okay it's going to create a text input box in there okay so a URL see every corner quality URL inputs want to do our end the URL is you're going to add URLs to be instance insults app is this here let's go for you URL in a URL input to the tool for each of the URL in the URL input so if I'm going to write a condition and say if there is the URL right I'm going to pass the and the URL to the open source app instance so we are going to say [Music] let's add okay web page URL right so so this is nothing but just adding the URL to the open source app instance okay so we are just adding any of the URL links to the instance right so it can probably um give us the answers that we need here to the conversation chart function so now we are creating a conversation chart I'm going to say compensation uh query so we're going to browse in the query so at this point we would just want to create a conversation chat so that you think it's going to be the user and the um the answers that are coming out from the models okay so it's going to be the user and the both now all right so we say conversation chart let me say resolves go to these up we are passing in the open AI in the open source app instance again all right it's not opinion app it's opinion instance so we say query to be passing the query let's see a section s date fixing the state is going to be the history on a band the query and the results right so now we are interested in the result okay so we say return results okay so we create a conversation chart and we pass in the Creator and variable called the results where we're passing the query into the open AI open source app instance sorry open it open source app is this so that's going to give you um the results and we want to keep the history right so we append the results and the query into the history so we want to return the results from the conversation okay so now we are creating we are saying if initialize section so we are initializing initialize to the states so we want to initialize it state of the conversation right so if so in the conversation we have the history generated we have the past so if history not in SD or section state section state and return this section stay history and the section state of the history okay we want to keep it a mentalist and if he generated so that is the answer from purpose it's not in St it's existed a result is not there now [Music] we are saying that unrated foreign X m so we need them about right and the next thing is if it's passed to you sexy state that's a sexiest state let's go to let's say a all right okay so now we want to display create a function to display the chart history so we create a container we're gonna have the reply container okay we're going to have the initiate that Arrow here okay and we create a container for classical container okay continue right but we have two containers now I'm going to say with okay so this is nothing but just container to hold the conversation all right so same weights or inside the container we are creating form T is equal to perform right so when we submit the form I we wanted to clear the clan submit clear the inputs when we submit so we say user inputs now in the text box hey guys so I'm doing a lot of coding so I'll take you through that when I'm done with everything but it's in a question so we're creating a question in the text box okay say and placeholder so let's put something in the placeholder and say x b products resources okay you want to say key it's equal to input all right so we only focusing on the inputs I do now submits put a button calling the submit button I'm going to say St d had to form submit button I'm going to say so when we click on that it's going to submit the form label so we're going to put something like a label [Music] we are going to name it send so that when you click on the send it's going to submit the form right and it's going to clear the inputs whenever you click on submit okay now I'm going to write a condition we're going to say so if submit so if you have the submits and the user input so once we have the submit button in the user input what we want to do now we want the output we want to create a variable all the output I'm going to pass the conversation chart in the conversation chart we put the user input okay so the conversation chart right here conversation chart right here we are going to pass this function right here that holds the query all right we're going to pass it in here I'm doing the submit button the user and that's going to hold the variable call the output okay we're now going to say SD Dot 8 session state this is state of the now Earth I'm going to append user input so once we have the submit button in the user input we also want to get the past conversation from the user input and we want to get the generated as well very simple okay so we just want this chat to be very place in a conversational way okay so we're gonna have the um the output from the user's conversation all right so whenever is generated we want to get the output and the user inputs we want to get the past conversation all right and now we are saying that okay that's why the statement so if if so I'm going to say if submit uh Okay so if you generated if the sex section state has it generated message you rated what we want to do now increase that in a container the reply container okay you want to enter it to so for I in range range to the lens range we go to the land of the states it's section state of the generated all right generated we want to do now I'm going to get a message if you want to create a message between the user and the the boots all right processes stay stay the past us as in the number is the user so this is from the user I'm going to say that to true this user and I'm going to say key is going to be a string we're gonna end that into a screen as the the user all right so we are going to say we put a style in there call it Avatar Style it's nothing but just a design something like let's see thumbs okay I think this is okay and let's create another message box okay so I think I can just copy this one edit paste it here so this time we need the generated answer and narrated read that and we don't need the user because this won't be generated in the boot Avatar we don't need this style and tops this time I want to do it Emoji so let's say an emoji as you can put whatever you want there okay and now what we're going to do now is less initialize function oh let's initialize the state sections okay so initialize Alicia ID state all right and let's display the chart it's free that history okay all right thanks all this set and quickly walk you through this all right so we import the um the libraries frame lights for the framework scrimulator to create a conversation chart embedding chain to create the um the chain the llms to grab um create the answers right so the open source app just contains everything that we need the llm the open source and the um another whole working with plant chain and also the free embeddies so sentence Transformers all right so we create a St dot titles for the title put in something like a book right and we write something like into multiple links you can put it any message you want how we initialize the open source Hub we call it open source app so we can put it in the name in a variable I call it sagbot so get user input we get a user input so the number of links that you want to put in there you say St DOT number of number input right you enter the number of links minimum value should be one the value is one step is equal to one so whenever you clicking the plus sign is going to increase the number of steps okay so now we create an input url url inputs we call it the empty list iterate through the number of links so we create a variable that's going to contain the um on the numbers that we are getting so we have the number of link is going to um count the number of links that we are getting through the iteration of the number of links we want to create the text input box so that will enable you to post in more links okay and we're going to append that to the URL input links okay so now we want to add URL links to the open source Hub instance so we say for URL in the open URL inputs right here so if there is an URL we are going to pass the open source app instance we are going to pass the links all of the links to the um the European Source up instance that's where it's going to perform the magic okay so now the conversation chat up we create a history okay we say that create a query conversation we call it conversation chat and the resource is going to be the query that we pass through the the open source app right and we're going to pass that to the results and we are going to need the the history we're going to append the query and the results to the history and then we just want to return the reset the results now we initialize this date so we have three State history generated in the past so if there is no history in this section we make it an empty list so if there is generated not in this section we could say hello ask me anything about you can put it in anything that you want to put in there so in the past so not in this section State we are going to say hey now we create um display the chart history we create a container the reply container and the um the other container okay so with the container you can name it whatever name so you only need a reply container container so with container we are going to pass in the form so when the form is submitted we declare the the question to Clay is equal to true so we say the user input the user input is going to put text created text input call for report question and placeholder something like ask me a resources right I'm gonna make sure the key is equal to true and now we create a submit button for the form and we say that we submit the button and we create a label I think it is wrong label is equal to send correct so if submit button and the user input the outputs are conversation conversation all right I should change this one here conversation conversation chat okay conversation chat so for if they're submitting the user input I'm going to say we're going to pass the user input to the conversation chart and we are going to hold that to the output and we're now going to create append the user input into the past and the output from here the user input we're going to do the output to the generated okay so now for the generated you want to create a reply container so we want to iterate through the generated and we want to create a message for the past and the generated all right and we want to put Styles there like Avatar or something okay all right uh it looks fine it looks fine and we initialize the section State and the display chart history all right so let's run it and see okay I think I had this one here let me so we run it right to looks like we have an arrow here okay let me see I think step step step should be step okay all right let's see run it again all right so we run it all right perfect Okay so you can put in any link that you want to put in here okay so I'm going to say one or you want to you can say two and let me put in this link again let's see all right okay let me go so let's see if we can hit enter let me ask a question I'm gonna say RS um again database all right perfect there you have it this is so awesome all right so under the hood I just want to make sure um so whenever you run it it creates automatically creates a database here using chroma SQL I3 so um it stores everything here and it's great it creates embeddings from everything within the uh um stores them into your database here right here all right um yeah so that's that's it I hope you like this video and please don't forget to subscribe and share see you in the next one
Info
Channel: DataInsightEdge
Views: 1,183
Rating: undefined out of 5
Keywords: Sure, chatgpt, chatbot, embedding, llm, streamlit, OpenSourceApp, Embedchain, framework, bots, dataset, OpenSource, embeddingmodel, LLMmodel, SentenceTransformers, gpt4all, apikeys, installation, package, functionality, opinionated, opensourcemodel, githubcode, tutorials, documentation, resources, Githublink, Embedchaintutorial, Embedchaindocs, SentenceTransformerslink, Streamlitdocs, Certainly, here are 30 single-word tags separated by commas: AI, technology, development, NLP, machinelearning, automation, code, open-source
Id: TqQIHWoWTDQ
Channel Id: undefined
Length: 39min 37sec (2377 seconds)
Published: Mon Aug 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.