Flowise: No Code ChatBot Building Platform: LangChain

This content was created by LARRUZ. This content was uploaded by LARRUZ. This is a YouTube video titled "Flowise: No Code ChatBot Building Platform: LangChain" created on June 5, 2023. It provides a tutorial on using Flowise, a no-code platform for building applications with large language models, similar to Langflow. The video covers installation, setup, and creating applications for Q&A retrieval using Flowise and LangChain components.
Chapters
Today we're going to be looking at yet another amazing project called flowise. It's a no code platform that lets you build powerful applications using large language models. Flow Wise is very similar to another great project called langflow when it comes to functionality and the interface. I already made a video on langflow, so the link is going to be in the description of the video. Check that out if you are interested. Flow Wise is written in Node js. Now it essentially gives you a graphical user interface where you can use components from LangChain to build application based on large language models. So for example, there is a simple LLM chain or you can develop apps for Q and a retrieval. Now there are example applications that you can build for translation and you can even use conversational agents with memory from LangChain. In this video I'm going to show you how to install Langflow on your local machine and then we will build a couple of applications including one for Q&A retrieval. We will provide a PDF file and then use Flow Wise to create a chain for information retrieval. If you don't mind coding and want to run everything locally without anything leaving your computer, then check on my project called Local GPT. The project is already trending on GitHub and I'm planning to add a whole bunch of features with the support from the community. So check that out. Link is going to be in the description. Okay, coming back to Flow Wise, let's walk through the installation process. So they have pretty nice GitHub repo as already has around 7,000 stars on GitHub. Okay, so first let's look at the UI. This is how the UI is going to look like. So it's a simple drag and drop interface. Now, in order to install flowise you will need to install Node js. So using this link, go to the Node JS website and depending on your operating system, you need to install it. So I have already installed it and I am using a Windows machine. So in order to test it you can simply type in NPM and just click Enter. And if it's installed properly you will see something like this. Okay, so for simple installation I'm going to be following the exact instructions here. So I already have Node JS installed, so I'm going to type in npm, then install dash G and then we want to install Flow Wise. So that's Flow Wise, click Enter and let's wait for the installation to complete. Okay, so the installation is complete. Now, if you want to start Flow Wise, you can do it in two ways. You can simply type in NPX Flow Wise Start or you can use NPX Flow Start and then give it a username and password. This is going to be good if you want to authenticate your users and that way you provide them a password and whenever you run the Flow wise app, which they will have to provide that. But in my case I'm going to simply type in the first option. So that's going to be NPX flow wise and then we will just start it. Okay, so once you started, then if you see this mesh data source has been initiated and flow service is listening at 3,000 port number right now, you actually need to type in or go to the localhost with a port 3000. I would personally like for them to actually put this here because if you're new to it, you might run this and then you don't know what what is actually happening. Now in order to access the server, simply copy this address and then paste it in your browser and just access it. Okay, so I have been playing around with it. I created a couple of apps. We will go with this. But the first thing that I'm going to do I'm going to switch to dark theme. So let's look at a few components. First there is chart flows. So every flow that you create, it's going to be here. I've been testing with it. So I have a test flow in PDF flow. We will look at this specific flow in a little bit. So then there is this marketplace where people have created their pre built flows that you can use as a template. So for example, here's a flow form R2GPT. Then there is this one for baby AGI, right? And there is even some for XAP here if you want to really automate your things. Right. So if you want to use them as a template, simply click on it and then click on Use template and it brings that flow into your new flow or they are calling it chat Flow. So you can give it a name and then start using it. But we're going to first look at how you can create one from scratch. So for that simply go to this add new and it will give you a completely blank screen. This is going to be an introductory video where we will look at different components that are available inside. Flow wise I will be creating a more detailed videos if there is interest in order to see which components or modules are available. So click on this + node and it gives you all the available things. So it has a bunch of agents that you can use. You can create different type of chains and it's actually a pretty comprehensive list. Now keep in mind this gets inspiration from LangChain. Now if you don't know what LangChain is, I would recommend check out this video. So in terms of chat models, they have Azure chat, OpenAI, then even they have Anthropic and it supports local chat models as well, for example llama, CPP or GPT for all. So this is pretty neat. And then there are document loaders so you can load different types of files. In terms of embeddings, it has support for OpenAI, Azure, OpenAI, Cohere, Hugging Face and OpenAI and it also supports different types of LLMs. So it's pretty similar to what is available inside LangChain then different types of memories. And I think it does have a prompt template. So that's pretty neat. There are some retrievers, text splitters. So we are going to be using this recursive text splitter in our example. So this is pretty awesome. And different types of vector store. In this video we are going to be building a document question and answer LLM. If you are a regular viewer of my channel, you probably have seen this diagram. So essentially we are going to upload PDF files, then it will divide it into different sub documents, right? We'll compute embeddings for each sub documents and we'll create a vector store. And then whenever a new query or question comes in, we will compute the embeddings using the same embedding models that we used for our vector store. Do a semantic search on the vector store to retrieve the most relevant documents or chunks that are inside the knowledge page or vector store and then rank those results, give those back to a generative large language model and the user will get a response. If you are new to these concepts, I would highly recommend you check out this video which goes in extreme details and explain each one of these components. Okay, the information that we are going to be providing is going to be in the form of a PDF. So we need a PDF document loader first. So simply go to Document Loaders and check out where PDFloader is. So you can simply drag it here. I'm going to zoom out a little bit so that we can see everything. In this case it lets you upload a file. Now if you simply click on it, then it will take you to your computer and you can upload your file. In this case we're going to be uploading the Constitution of the United States. Now, it expects one input, right? And there is one output the input that it expects is text splitter. So we need to provide a text splitter using which we will divide our PDF file into smaller chunks or documents. Okay, so for that we will just go back again and then we will look at text splitters. Now, in this case, I'm going to be using the recursive character splitter. Now, in order to connect this as an input, so you simply drag it here. And now you have your text splitter. Now, in terms of the overall architecture diagram, so here we are, we are simply dividing or splitting our document into different chunks. Now, by default, the size of each chunk is around 30,000 tokens, and I usually like to put an overlap. So next we need to add two components. What is going to be the embedding computation part and the second is going to be the vector store. So let's add the embeddings part. For simplicity, we're going to be simply using OpenAI's embeddings. But later on in the subsequent videos, I will show you how you can connect other types of embeddings. For example, embeddings from Hugging Face Hub, which are open source and free to use. Now, next we need to take these documents as well as the embeddings and put them together in a vector store so that we can start computing embeddings. The way you do it is we're going to be using a vector store. So let's go to the vector store portion and here are different options. So you can use Chroma DB in memory vector store, pine cone as well. And then there are View it and a couple of other options. For this simple example, I'm going to be using in memory, vectorstorm. And now in this case, we simply need to connect the chunks of documents that we created and the embedding model. So this is the OpenAI's embeddings model. And the output is going to be a memory retriever. So theoretically we created a knowledge base. Now we need to take care of the second component, which is the actual information retrieval part when somebody asks a question. So for that we are going to be creating a conversational retrieval question and answer chain. So I'm going to go to the chains part, right? And then we will look at this conversational retrieval question and answer document Q and a chain. So let's bring it here. Now it expects two inputs. One is the language model and the second one is the vector store retriever. So the vector store retriever is coming in from here. And now we need to add a Language model. And that's the language model over here. Actually, I have represented twice, so I'm going to just remove that. And so this is how it's going to look like. We'll get the results. And now we need a language model in our chain or actually in chat flow. So let's simply go here and look at different LLMs that are in here. So for this simple example, I'm going to be using the OpenAI LLM. So I'm going to bring it here and then we need to connect it. Okay, that's it. Now, in terms of the different models, I don't think it supports ChatGPT or GPT4 right now. I might be wrong, but here are the options that you see. Now, there are some additional parameters as well. For example, the max token, top probability, right batch size, timeout and things like that. You can adjust those parameters. Similarly, for the OpenAI embedding models, there are some additional parameters or you can even look at the PDF file reader, right? So there are different options that you can set. In this simple example, we're not going to change anything, but we'll keep everything to the default. Okay, now, since we're using OpenAI's models both for embedding as well as for the LLM, so we need to provide our OpenAI API key. Okay, so I copied my API key, I'm going to paste it here and also here, right? And then what you need to do is ingo and save your chat flow. So let's call it doc, underscore chat. Okay? And I'm gonna just save this, okay, Once you save it. So you will see this code sign. Now this gives you a few options. For example, if you want to embed this into an HTML file. So all you need to do is simply copy this HTML and add it in your HTML file and you'll have a chat bar. Similarly, you can use this in API calls. So, for example, here is the API URL. If you're doing it in Python right now, notice that it's using your local host, right? So in order to deploy it in production, you probably want to host it somewhere else, right? But this is how you're going to make a query. We are going to be looking at this in another video, right? Then there's a simple sample code to do this exactly in JavaScript as well. Or if you want to do it through command line. Now, in terms of other options, you can duplicate your chat flow, or if you have already exported the chat flow, you can load it as well. If you export this chat flow, it will simply create a JSON file which has all these information listed in there. Now once you create your flow, then click on save. You probably will have to wait a little bit, but then you can create on this chat sign and you can type in your question and start chatting with your documents. Now sometimes when you click on this, you will see that this is grayed out and you are not able to chat with the bot. Right. In that case, I would actually recommend you to simply go to the terminal. Right. Enter control C so it will stop your web server and start it again. Right. And go to that same process again. That seems to help. Okay, we can start chatting with the document. So let me ask it a couple of simple questions. So the first question that I'm going to ask is what is the time limit for the President? And let's see what it comes up with. So here's what it came up with. So no person should be elected to the office of the President more than twice. And no person who held the office of the President or elected as the President for more than two years of a term to which some other person was elected President shall be elected to the office of the President more than once. Okay, this is a very interesting answer, but let's see if we can actually find this in the original Constitution. Okay, so it seems like it actually simply got the answer from here and returned the whole small paragraph. That is interesting. All right, and next I asked it, according to the text of the document, how many states are in the United States since the last amendment is based on 1992? So it actually came up with the correct answer of 50 states. Now the another question I asked was what is the role of the conference Congress? And it came up with this answer. Now one thing to realize, we are using text DAVINCI003 as the LLM. That means it actually has access to the current information as well. Now in order to simply extract information from the document, we will need to do some prompt engineering. In the subsequent videos I will show you how you can design prompts so that you force the model to extract information only from the documents that you provide overall flow wise. Just like Langflow is a great no code tool that lets you build powerful applications based on large language models, I would recommend everybody to actually check both of them out. If you are looking to build your own applications based on large language models and want to figure out the feasibility, I do provide consulting services for consulting. Check out the description of the video for further details or the pinned comment. We also have a Discord server which is actually growing and there are some awesome people who are helping each other out with with different projects. I would recommend everybody to check it out if you are looking for a community of like minded people. If you like what you see on this channel and would like to support it, you can check out a couple of links in the description of the video on how to do that. As always, thanks for watching and see you in the next one.










