Find answers from the community

Updated 3 weeks ago

Remembering User History and Conversation in a Chatbot

I have created a chatbot using llama index chatengine…Now I want to remember the user if he had previously used the chatbot and show him the last history of conversation he had

Currently, I get a new conversation I’d when new connection is made from same user. I want to remember the user, can I remember from IP or any other way and show him all the conversations he had before
@Logan M
W
L
2 comments
You can store the chat of a user at your side and then load it back when same user comes back.

Plain Text
# Extract chat history of a user
chat_history = chat_engine._memory.get()

# once the same user comes back ( using some sort of Identifier ) 
# You can either pass it in chat or set the chat memory 
resp = chat_engine.chat(message=message, chat_history=chat_history)

# OR 
chat_engine._memory.set(chat_history)
You should store the chat history behind some id, and the id should be provided in the api request
Add a reply
Sign up and join the conversation on Discord