llama_index
llama_index copied to clipboard
Implement vector memory
UPDATE
- Re-jigged vector memory to only supply list of chat messages and not handle any thing having to do with composing messages
- Added
BaseComposableMemory
andSimpleComposableMemory
for better separation of concerns- With this class, now we can pass a
VectorMemory
andChatMemoryBuffer
to aSimpleComposableMemory
which will do a simple composition on the messages that are retrieved by all of its memory sources
- With this class, now we can pass a
- Modified
vector_memory.ipynb
and added newcomposable_memory.ipynb
(added these to docs as well) - Added these classes to api reference (I think?)
OLDER
was way harder than i originally anticipated, summary of main changes:
general interface stuff:
- added
input
argument toget
function in memory - added
put_messages
to memory - replaced all
memory.set(..)
calls in the agent withmemory.put_messages
in terms of updating state - added
BaseChatStoreMemory
for all memory modules that depend on a chat store
implemented vector memory:
- track each "node" in a vector index
- each "node" is by default a group of messages, instead of a single message. this is because if we index individual messages, we'll retrieve just the user message or just the assistant message, but not both. you may end up retrieving a user message and an unrelated assistant message leading to hallucinations
- we track the current "message batch" in the chat store, to accumulate user message, then assistant/tool msgs, etc.
- we also track all message ids in a separate collection in the chat store. this is to allow us to perform deletes, which right now consists of deleting messages one by one.
-
NOTE: deletes from vector stores are hard, we do some hacks to make
delete_ref_doc
work
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB