bug fix: deal with empty pickle dict, reverse _key_id_dict changes

This commit is contained in:
fuqingxu.fqx 2024-08-19 16:03:35 +08:00 committed by jinli.yl
parent e6a0872185
commit 88946c19e2
2 changed files with 9 additions and 2 deletions

View file

@ -189,9 +189,14 @@ class LlamaIndexEsMemoryStore(BaseMemoryStore):
Returns:
MemoryNode: The converted MemoryNode with text and metadata from the NodeWithScore.
"""
key_vector = pickle.loads(text_node.metadata["key_vector"].encode('latin1'))
if text_node.metadata["key_vector"]:
key_vector = pickle.loads(text_node.metadata["key_vector"].encode('latin1'))
else:
key_vector = []
text_node.metadata["key_vector"] = key_vector
text_node.metadata["vector"] = text_node.embedding if text_node.embedding else []
text_node.metadata["score_recall"] = text_node.score
text_node.metadata["key_vector"] = key_vector
return MemoryNode(content=text_node.text, **text_node.metadata)

View file

@ -98,6 +98,8 @@ class MemoryManager(object):
self.logger.info(f"add to memory context memory id={node.memory_id} content={node.content} "
f"store_status={node.store_status} action_status={node.action_status}")
self._key_id_dict[key] = [n.memory_id for n in nodes]
if nodes:
self.logger.info(
self.logger.wrap_in_box(