hi, GPTIndexChatMemory just subclasses BaseChatMemory in langchain which uses pydantic, so i think you should also be able to serialize this module?
how? I don’t see a method to do it and even using pickle it fails
there is some attribute somewhere that is not hashable
Oh actually nevermind, yeah my answer above doesn't work.
the easier solution might jsut be to serialize the underlying index! index.save_to_disk
and load_from_disk
using the index class.
the memory wrapper is a light wrapper around the index anyways
that's perfect, I admit I didn-t spent time looking at it as I was busy and just asked here instead. sorry about that
I will try save_to_string and load_from_string as I-m using a database
@jerryjliu0 I got it to work, it serializes correctly and I'm able to get it back, but somehow the message history is not used by the agent
maybe I'm missing something, I thought the memory was automatically passed in all LLM calls as a chat message history?
another user also reported the same to me, and has been trying to get help in this server too @Dondo
Yeah the memory was serializing to my index but it wasn't used in ChatGPT calls
I got it working with ConversationSummaryBufferMemory, but I wonder if the llama index is more efficient. ideally ConversationSummaryBufferMemory would use the index to retrieve older memories
with ConversationSummaryBufferMemory eventually the summary will get too big, would be best to retrieve from index if the summary+message history are not related to the latest query
@jerryjliu0 what is GPTIndexChatMemory supposed to do? are there any docs about it?
hey @Tiago Freitas , super sorry for the delay. the idea of GPTIndexChatMemory is that you can use a gpt index data structure as a memory module - which theoretically should resolve your concerns around ConversationSummaryBufferMemory 🙂 If you want to return the raw text though (and not the synthesized response from index.query), make sure to set return_source=True
@jerryjliu0 that’s ok it’s open source and free 🙂
I didnt have time to debug, but without return source it didn’t seem to be working.
is there a debug mode with logging?
about the serialization, if I use a vector store database I guess there is a way to reconstruct the index and not needing to store the message history?
I am new to llama-index and need to spend some time learning the internals
in the query_kwargs dictionary in GPTIndexChatMemory, you should also be able to specify verbose=True. but we have a TODO to add better logging support