chat_memory = ChatMemoryBuffer.from_defaults( token_limit=3000, chat_store=chat_store, chat_store_key="user1", # <- points to what collection in the chat store to use )
from llama_index import SimpleDirectoryReader, VectorStoreIndex from llama_index.storage.chat_store import RedisChatStore from llama_index.memory import ChatMemoryBuffer chat_store = RedisChatStore(redis_url="redis://localhost:6379") memory = ChatMemoryBuffer.from_defaults(chat_store=chat_store, chat_store_key="user123") documents = SimpleDirectoryReader("./docs/examples/data/paul_graham").load_data() index = VectorStoreIndex.from_documents(documents) agent = index.as_chat_engine(memory=memory) agent.chat("What did the author go growing up?") agent.chat("Thanks!") print("agent ", agent.chat_history) print("-------") print("chat_store ", chat_store.get_messages("user123"))