Flowise AI Tutorial - Long-Term Chat Memory with Upstash Redis
2024 ж. 14 Мам.
5 456 Рет қаралды
#flowise #langchain #upstash
In this video you will learn how to add a long term memory backend to your Flowise Chatbots using Upstash Redis.
☕ Buy me a coffee:
www.buymeacoffee.com/leonvanzyl
📑 Useful Links:
Upstash: upstash.com
💬 Chat with Like-Minded Individuals on Discord:
/ discord
🧠 Let me build your chatbot for you!
www.cognaitiv.ai
🕒 TIMESTAMPS:
00:00 - Introduction to Chat Memory
00:52 - Building the chatbot
02:16 - Creating an Upstash Account
03:36 - Add Upstash Credentials
04:11 - Add Upstash Rest URL
04:25 - Upstash Session ID
Thank you Leon 'soos altyd bakgat!'
First!!! This is going to be a good one 🎉
Wow. I was searching how to remember chat memoty 1 month ago. I used motorhead. Thank you for tutorial.
You're welcome 🤗
cannot wait
I love your videos!! its quite a while that i'm following your flowise series. I have a question: is possible to make the LLM ask the user a question and then use this question in the next chain? Thank you for the videos, they are great!!
Thank you 🙏. I'm not aware of a solution in Flowise for having the bot ask questions. I usually just use tools like Voiceflow or Botpress for that.
Do I have to create a new database for each Flowise workflow? If not, how does the system differentiate the same user chatting with different flows?
Hey Leon, great video as always, keep up the good work, really appreciate your lessons :) Couple questions: 1. Is this any better/different that using Zep memory? I currently use Zep which I host on Render, but I don't get a simple an interface with session ids as well as being able to see the actual conversation in the table like that. Would you say Upstash is better for this reason? 2. Would this work indefinitely and forever? Would the memory retrieval slow down overtime? If so, for chat based data, could this replace the need for a vector store? Thanks again Leon, PS: just chasing up on that email I sent to your agency ;)
Hey Hassan, thank you for your feedback 🙏. Those are very good questions and quite a lot to answer in a comment. Making note of them for future videos. Memory and Vector stores (knowledge bases) are quite different. For memory, I believe that Langchain will actually pass a summary of the chat history to the LLM, so I don't think it will affect performance or token usage that much. I could be wrong. I would still seperate the Knowledge Base from the chat memory / history though. Saw your email (the long one 😁). Will respond when I get a chance to read it all 🤣, or schedule a call.
This is awesome. Your content is really appreciated and I’m 100% obsessed with your Flowise videos. I’m hoping to get you opinion on the following. I’ve installed Flowise on an AWS ec2 instance and configured my env file to use a Postgres database also in AWS. When I connect to that db I can see motley chat flows and chat messages history in the tables. I only have a buffer memory node in a sample flow I’ve created. In terms of long term memory, is there a difference in my setup compared to what you reviwed here.
Thank you for the kind feedback. Just glad I could help. I assume you configured the postgress database in the env configuration. I haven't tried this myself, but from your message it seems that Flowise is then using the env database for it's memory.
Correct, I’ve configured my flowise .env with a Postgres database configuration which points to the AWS Postgres instance I created. It looks like my flowise app has long term memory with this setup. I’m just curious if that truly is the case. I’ll be playing around some more to test this out.
@@marioa6942 you definitely taught me something 🤗. Going to play with this myself. Thank man!
great video and explanation Leon. Could you maybe make a video where you would show us how to use the Flowise with the memory (like Upstash Redis) inside the Voiceflow? I can't seem to get the memory to work when calling the Flowise through API call in Voiceflow. I'm sure it's super simple... but I just can't figure it out. Great video again... I actually made my Render instance with Flowise folowing your other video... this is so powerful. Thank you again.
ok.. I take that back ... I just put the { "question": "something-something-1", "chatId": "myChatId-1" } in the JSON body and it worked :) Unlike the Zep memory ... that I couldn't make work inside Voiceflow ... such that it would keep the memory inside the Voiceflow. Maybe you could do something around that. just an idea. Amazing content... thank you
Hey there. Yes, I was just about to say that you need to pass the ChatID along 🤗. This goes for any application that calls Fkowise, not just Voiceflow.
just wonder which memory you recommend for the production level? i have tried Upstash and embedding Flowise app API into a app, every time I interact with the chatbot, upstash generates a new ID and creates a new container for storing chat history, it was not consistent.
Hey Leon great video! like all of the others. Question: I want to use this upstash for chatmemory for my chatbot that users are using. How can I make it that each user gets a unique "sessionID" because you used "c1" and then changed it manually or do i just leave it blank? thanks for all the great content! :D
I also wonder if there is a way to automatically create a separate ID for each new chat.
Love the videos! So if I put this live on a website, will it collect all the questions people asked?
Thank you, and yes to your question 😁
@@leonvanzyl love it and thanks for the videos. They’re amazing!
Fantastic video. Is there a way we can use a unique sessionID for each website visitor? Maybe tying the username to the sessionID or something?
Thank you! You could use JavaScript to generate a unique ID for the session.
how to get only last k of messages from Upstash to context? In langchain it is possible, but how to in Flowise?
great
Thank you 🙏
That's Great !!! Question how do you handle with multiple chat, if you chatbot is expose to your website ?
Thank you! You can pass a session ID in the API. Pass unique session IDs for the different sessions
@@leonvanzyl can you make an exemple in one of your future video ?
@@leonvanzyl How do you pass the session ID in the API?
Thanks for the video Leon 👍 Quick question: how would you limit the amount of conversation history that is used for each response (for example the last 5 messages)? I'm using upstash redis for my flowise bot but the problem is that it passes the entire conversation history to the LLM (GPT 3.5 Turbo in this case) so eventually the context gets used up as the chat history gets bigger.
I think there is a last k property that you can set, but let me confirm this. Will include it in the updated series
@@leonvanzyl cool thank you. I managed to set up the last k with zep but not upstash redis.
Hey thanks! I’m using zep at the moment with chat session ids in a bubble app self hosted but that means you can’t run the zep webui for security..Any idea of the upstash costs? And I see FW has plain REDIS…does that mean you need DB skills? What I really want is self hosted chat session memory that’s not a PITA to set up lol…
That's why I like using Upstash Redis. Easy to set up and the free tier is really generous.
Your videos are amazing. Please, could you make a video with Zep Memory, and would it be possible to use multiple memories or sessions with flowise. Thank you very much!
Thank you very much for the support! 🙏 Will look into Zep for you
So is this an alternative for Pinecone?
Good video. Do you have any video on how to how to put on the website and post-Google authentication => assign this chat memory / history to the particular user please?
Thank you 🙏. I have received a few requests to create a tutorial for this. Really need to make it happen 😁.
I plan to clone Zig Ziglar!
Do it 😁
Great video. I am about to create a google translate api node in flowise. Any advice?
Thanks! Should be simple enough - create a custom tool that calls the translate API 👍👍.
Do you prefer flowise or langflow? how can I store the conversation histories for all chats in a database?
Both tools are great and actively being improved. From my experience Flowise is slightly more advanced in terms of bring "production ready", so I'd use Flowise for client projects.
Hello, how can we update our Flowise to the latest version? Thank you
Hey. I prefer the git / developer setup. Easy to do and ensures you'll have the latest features. Check the setup section in this video: kzhead.info/sun/hLmAosd5eYJ5eYU/bejne.htmlsi=qbk5QWMgQ7yq3hyf
do you have any video tutorial on flowise with chroma db?
I don't, but it should just be a matter of adding the Chroma node to the canvas?
Hey! I don't really get it. Why it is long term and what is the difference between motorhead or zep memory where I can do the same?
The conversation is stored in a persistent database instead of buffer / temporary memory where the conversation(s) are lost when the server is restarted or Flowise upgraded. Hence long-term.
Yes good... I'm having issues self hosting zep and I have this wierd thing about not self hosting
Mostly because I am generally unqualified
We're all here to learn 👍
You got Redis, Zep and Metal. Which one is the best?
I personally found Upstash Redis to be the easiest to set up and integrate for production apps.
how do we dynamically send the new session ID rather than make C1 C2 manually
The idea is that your application should generate and store a session ID when calling the Flowise API / Embedding API. That way you can recall the session and allow the user to continue the conversation in the future.
how can we make a new unique session automatically for each user
That needs to be done outside of Flowise. The calling application will have to manage users and conversation session IDs. Might be a cool tutorial idea? 😁
this would be an awesome idea, be able to track different conversations with different users and use that data to train your llm for different clients@@leonvanzyl
@@leonvanzylyes please!
can u do tutorial on how to connect my chat bot to social media if that even possible pleaaaaaaase
For sure! I was thinking of creating a tutorial on integrating Flowise with Instagram. What you think?
yeah sure that would be great . if you can cover all the social media platforms that's even better @@leonvanzyl
What about DynamoDB? AWS is very popular a DynamoDB tutorial would be really cool!
Flowise has support for DynamoDB. Simply add the DynamoDB memory node to your project.
how can the LLM have contextual memory
It can't. The conversation is stored in a database which is seperate to the LLM. The conversation is then fetched from the DB and then past into the conversation as context when chatting to the model.
shoot, I followed everything three times over. and in the chat response, I'm getting this: (Me) hi (AI) *_Unauthorized, command was: ["lrange","c1",0,-1]_* -AND- (Me) hi (AI) *_Unauthorized, command was: ["lrange","0344952d-df2d-4bc6-9d2c-2ede304aa070",0,-1]_* - Seems like the second one has to do with Redis as this is what BlackBox spit out *-_ But I don't know what to do_-*- - ----_The `lrange` command in Redis is used to retrieve a range of elements from a list. The command takes three arguments: the key of the list, the start index, and the end index. The elements in the list are indexed from 0, where 0 is the first element, 1 is the second element, and so on. The start index is inclusive, while the end index is exclusive. This means that the element at the start index will be included in the range, while the element at the end index will not. In your case, you are trying to retrieve all elements from the list with the key "efc36c43-2ec1-42c1-9623-2773ffcc601e". The start index is 0, and the end index is -1. The end index of -1 is a special case in Redis that represents the last element of the list. Here is an example of how to use the `lrange` command in Python with the `redis` library: import redis # Create a connection to the Redis server r = redis.Redis(host='localhost', port=6379, password='your_password_here') # Retrieve all elements from the list result = r.lrange("efc36c43-2ec1-42c1-9623-2773ffcc601e", 0, -1) # Print the result print(result) Make sure to replace `'your_password_here'` with the actual password used to authenticate the Redis server. If you are still encountering the "Unauthorized" error after following these steps, please provide more information about your setup, such as the operating system, Python version, Redis version, and the contents of your Python script. This will help in diagnosing the issue further. Note: The `lrange` command will return an empty list if the key does not exist or if the key exists but is not a list. Make sure that the key "efc36c43-2ec1-42c1-9623-2773ffcc601e" exists in your Redis database and is a list. You can check this using the `exists`_
Odd. Ensure that you have the latest version of Flowise installed, and that you're using UPSTASH Redis and not the normal Redis node.
Yes, updated and that brought in the Upstash node before I asked. I'm new to all of this so I guess I'll just keep on beating on it.@@leonvanzyl