the ability to upload files like PDFs and text files is one of the major strengths of using line chain and flow wise in the previous video we had a look at creating a document chatbot using flowwise and this allowed us to upload our file using the text document uploader and we then broke that file up into chunks and we stored it in our in-memory Vector store if you are unfamiliar with Vector stores and document loaders I recommend having a look at my previous video first and then coming back to this video this solution is perfect
for very simple use cases where we want to upload a text file ad hoc and then ask the AI model questions related to the content of that file we can also easily replace the text file with a PDF document loader or anything else that we want however there is a limitation with the solution whenever we interact with our application by asking it a question this entire flow is executed which means we will upload the file we will then chunk it store it into a vector store and the model will then be able to access that
information in the vector store this might be ideal when we upload small files in our example this text file is only about 500 words but if we wanted to upload large files or multiple files the process of uploading this data chunking it and installing it in the database could take a very long time also we did not want to execute this each and every time we upload our application ideally we want to upload this data once stored in a database and then our application should simply read the data from the vector store without having to
re-light everything each and every time so therefore we will now have a look at the correct way of building production ready document chatbots this process basically involves two steps or two chat flows for the very first step we will simply upload our documentation and then store it in a vector store this process is called upsetting or ingesting data into the database we will then create a separate chat flow that is solely responsible for querying the database and that will be the main chat bot that we'll be interacting with there is another limitation to our current
solution at the moment we are storing our data in an in-memory Vector store these in-memory Vector stores will get lost whenever we reset our server this means that if I had to close our server all the data are stored in this in-memory Vector store will get lost which is also not ideal in a production system we want the data to be persisted somewhere in a proper database so in this video we will also have a look at storing our data in a pine cone database so by the end of this video we will have a
chat flow that is responsible for uploading documents and then storing the content in a Pinecone database and we will then create a second chat flow that we can use to chat to our data so let's get started the first thing we need to do is to create our account with Pinecone so go over to pinecone.io and then click on sign up for free after logging in go ahead and create a new index give your index a name I will call mine flowwise and in Dimensions enter 1536 this is the dimensions required for an openai embedding
for pod type select S1 we will stick with the starter plan and then click on create index our index is now initializing and this will be ready after a minute or two and after about a minute we can see that this in is ready when we click on this index we can see that at the moment there are zero vectors in this database vectors are basically the amount of Records available in our database let's switch back to flow wise we will now create the chat flow that will be responsible for uploading the documents and then
storing these documents in our database let's click on add new let's give our project a name by Saving and let's call it ingest documents as with any chat flow we need either an agent or a chain for this we'll go to chains and then I will use the conversational retrieval QA chain we can now assign our language model by going to chat models and we can then select the chat openai model please note that if you want you can also use the openai model Instead at this point it's really down to preference we can now
paste in our openai API key and then connect this to our chain we now also need to add our Vector store node so we can click on nodes we can go down to Vector stores and we'll select the pinecon upsert document node and we can now connect this to our chain so in this case we are now hooking our Point kind instead of a local Vector store the spine cone node requires a pine cone API key an environment value as well as the index name we called our index flow wise so we can go ahead
and enter flow wise as the index name then for the API key we need to go to point can and then click on API keys on this screen we can click on this button to copy the key value and we can then paste that into the node then for the environment we can simply copy whatever value we stored here and then paste that into this field now that we have Point cones set up in our project we need to feed it the documents so let's add a document loader by clicking on nodes we can then
go to document and louder and then select one of these loaders from this list I'll just keep it simple and select text file as I will be using the same file from the previous video and I'll go ahead and connect this node to the document attribute on the point cone node and as with the previous video we'll also add a text splitter so we'll click on nodes we'll go to text Splitters and then we'll select the recursive character text splitter node and we'll connect that as well I'm going to change the chunk size to 200
to 200 characters with the chunk overlap of 20 characters finally we also have to hook up an embedding node so under nodes we'll go to the embeddings and I'll add this openai embedding node and this also requires the openai API key which I'll paste in like so so far this is very similar to what we saw in the previous video the only change is that instead of using the local Vector store which we now know will get refreshed whenever we restart our application the only difference now is that we are using a pine cone Vector
store instead of the local Vector store which we now know gets lost when our server restarts I'm going to select my file and I'm going to save my project but what I also want to show you is what happens to our Vector store when we run our ingestion chat flow at the moment we've got the Zero Records in this database but watch what happens when we chat to this application and quite honestly it doesn't matter what we ask the AI at this point all we want to do is run this chat flow so that our
document is uploaded and then stored in the point Clan database so I'm just going to ask the AI to summarize the story and you will notice that this does take a bit of time and that is because flowwise is first uploading this document chunking it running embeddings on each of the chunks and installing those embeddings in the database eyes this process does take quite a bit of time and this is ideally why we only want to do this once but by asking this question we now know that it's definitely summarize the file that we uploaded
and if we go back to point cone we can now see that there are 20 records stored in the database now so now that we have a flow that we can run whenever we want to upload information to the database we now want to create a separate flow that will simply interact with our database so that we can ask questions on it let's do that now let's go back to the flowwise dashboard and let's create a new chat flow and let's call this document QA the name is up to you as with any chat flow
we need either an agent or a chain again I'll go with the conversational retrieval QA chain our chain needs an llm and for the llm I'll use the chat model again the choice of llm is really up to you I personally love you using these chat Halal aims as I really like the behavior of these chat gpt-like models for the llm we need to provide the openai API key we'll then connect this to our chain now for the vector store we'll do the following in nodes go to Vector stores and instead of selecting the pine
cone upset document node we'll go with this one instead this Pinecone load existing index node and we can go ahead and connect this to our chain you will now see that this node looks slightly different to the Absurd node we no longer have to provide documents as input we still need to provide an embeddings node but this is simply so that our chain can convert our question into an embedding and that will allow pinecaine to do a similarity search on the database let's add our Point can API key environment and index name the index we
called flow wise for the API key I'll just grab it from API keys and I'll do the same for the environment like so for embeddings we'll go to embeddings and we'll select the open AI embeddings node and we'll connect that to our embeddings let's also add our openai API key like so and believe it or not that's it we can save our chat flow and test it out in fact let's go back to our ingest document chat flow and open up the chat I just want to have a look at the summary of our story
and we can see that the main character of our story is called Emily and she is a talented architect let's now see if our other chat flow has a view of this information let's go back to our document QA chat flow and let's test this out let's ask the question who is Emily and take note that at this point we are not feeding this information in Via a text file but we are expecting our model to fetch this information straight from the database and as we can can see the response is correct Emily is indeed
a young woman who is a talented architect living in the city of everdale so this now means that whenever we want to update our information or add additional information we can simply run our ingest chat flow and we only have to do that once whenever we want to interact with our data all we have to do is run our document QA chat flow and lastly because we are now storing our data in a third-party production really database our data will be persisted and there's no chance of losing this data when our server resets if you
found this content useful please consider subscribing to my Channel please like this video and share it if you are fascinated by flow wise I highly recommend checking out my series on Lang chain as well where we dive into the guts of using line chain thank you very much for the support I'll see you in the next one bye bye