Maintain chat history in generative AI apps with Valkey
Integrate Valkey with LangChain
1
docker run --rm -p 6379:637 valkey/valkey
brew install valkey
. You should now be able to use the Valkey CLI (valkey-cli
).1
2
3
4
git clone https://github.com/abhirockzz/langchain-valkey-chat-history
cd langchain-valkey-chat-history
go run *.go

List
:1
2
valkey-cli keys *
valkey-cli LRANGE <enter list name> 0 -1
keys *
in production - its just for demo purposes
schema.ChatMessageHistory
interface methods in langchaingo
and uses List
data structure behind the scenes. Starting the application creates a new "chat session" is associated with a List
- each new instance will be backed by a separate List
.AddMessage
- Stores a conversation message, using LPUSHMessages
- Retrieves all the messages in a conversation using LRANGEClear
- Deletes all messages in a conversation using DEL
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.